foreman-katello-engine 0.0.10 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/setting/katello.rb +1 -1
- data/app/views/unattended/kickstart-katello.erb +23 -21
- data/app/views/unattended/kickstart-katello_rhel.erb +92 -0
- data/app/views/unattended/snippets/{_katello_registration.erb → _subscription_manager_registration.erb} +4 -1
- data/db/migrate/20130416152224_add_katello_templates.rb +8 -3
- data/foreman-katello-engine.gemspec +1 -1
- data/lib/foreman_katello_engine/bindings.rb +15 -3
- data/test/lib/bindings_test.rb +4 -1
- data/test/lib/settings_test.rb +4 -0
- metadata +3 -2
@@ -6,7 +6,7 @@ class Setting::Katello < ::Setting
|
|
6
6
|
Setting.transaction do
|
7
7
|
[
|
8
8
|
self.set('katello_url', 'url of a Katello instance', 'https://localhost/katello'),
|
9
|
-
].compact.each { |s| self.create s.update(:category => "Setting::Katello")}
|
9
|
+
].compact.each { |s| self.create! s.update(:category => "Setting::Katello")}
|
10
10
|
end
|
11
11
|
true
|
12
12
|
end
|
@@ -1,3 +1,12 @@
|
|
1
|
+
#kind: provision
|
2
|
+
#name: Community Kickstart
|
3
|
+
#oses:
|
4
|
+
#- CentOS 5
|
5
|
+
#- CentOS 6
|
6
|
+
#- Fedora 16
|
7
|
+
#- Fedora 17
|
8
|
+
#- Fedora 18
|
9
|
+
#- Fedora 19
|
1
10
|
install
|
2
11
|
<%= @mediapath %>
|
3
12
|
lang en_US.UTF-8
|
@@ -7,11 +16,16 @@ skipx
|
|
7
16
|
network --bootproto <%= @static ? "static" : "dhcp" %> --hostname <%= @host %>
|
8
17
|
rootpw --iscrypted <%= root_pass %>
|
9
18
|
firewall --<%= @host.operatingsystem.major.to_i >= 6 ? "service=" : "" %>ssh
|
10
|
-
authconfig --useshadow --
|
19
|
+
authconfig --useshadow --passalgo=sha256 --kickstart
|
11
20
|
timezone UTC
|
21
|
+
services --disabled autofs,gpm,sendmail,cups,iptables,ip6tables,auditd,arptables_jf,xfs,pcmcia,isdn,rawdevices,hpoj,bluetooth,openibd,avahi-daemon,avahi-dnsconfd,hidd,hplip,pcscd,restorecond,mcstrans,rhnsd,yum-updatesd
|
22
|
+
|
12
23
|
<% if @host.operatingsystem.name == "Fedora" -%>
|
13
24
|
repo --name=fedora-everything --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %>
|
25
|
+
<% elsif @host.operatingsystem.family == "Redhat" %>
|
26
|
+
repo --name="Extra Packages for Enterprise Linux" --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %>
|
14
27
|
<% end -%>
|
28
|
+
|
15
29
|
<% if @host.operatingsystem.name == "Fedora" and @host.operatingsystem.major.to_i <= 16 -%>
|
16
30
|
# Bootloader exception for Fedora 16:
|
17
31
|
bootloader --append="nofb quiet splash=quiet <%=ks_console%>" <%= grub_pass %>
|
@@ -19,24 +33,24 @@ part biosboot --fstype=biosboot --size=1
|
|
19
33
|
<% else -%>
|
20
34
|
bootloader --location=mbr --append="nofb quiet splash=quiet" <%= grub_pass %>
|
21
35
|
<% end -%>
|
22
|
-
<% if @host.os.name == "RedHat" -%>
|
23
|
-
key --skip
|
24
|
-
<% end -%>
|
25
36
|
|
26
37
|
<% if @dynamic -%>
|
27
38
|
%include /tmp/diskpart.cfg
|
28
39
|
<% else -%>
|
29
40
|
<%= @host.diskLayout %>
|
30
41
|
<% end -%>
|
42
|
+
|
31
43
|
text
|
32
44
|
reboot
|
33
45
|
|
34
|
-
%packages
|
46
|
+
%packages --ignoremissing
|
35
47
|
yum
|
36
48
|
dhclient
|
37
49
|
ntp
|
38
50
|
wget
|
39
51
|
@Core
|
52
|
+
epel-release
|
53
|
+
puppet
|
40
54
|
<%= "%end\n" if @host.operatingsystem.name == "Fedora" %>
|
41
55
|
|
42
56
|
<% if @dynamic -%>
|
@@ -62,19 +76,13 @@ exec < /dev/tty3 > /dev/tty3
|
|
62
76
|
(
|
63
77
|
#update local time
|
64
78
|
echo "updating system time"
|
65
|
-
/usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] || "ntp" %>
|
79
|
+
/usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] || "0.fedora.pool.ntp.org" %>
|
66
80
|
/usr/sbin/hwclock --systohc
|
67
81
|
|
68
|
-
# install epel if we can
|
69
|
-
<%= snippet 'epel' %>
|
70
|
-
|
71
82
|
# update all the base packages from the updates repository
|
72
83
|
yum -t -y -e 0 update
|
73
84
|
|
74
|
-
<%= snippets "
|
75
|
-
|
76
|
-
# and add the puppet package
|
77
|
-
yum -t -y -e 0 install puppet
|
85
|
+
<%= snippets "subscription_manager_registration" %>
|
78
86
|
|
79
87
|
echo "Configuring puppet"
|
80
88
|
cat > /etc/puppet/puppet.conf << EOF
|
@@ -84,15 +92,9 @@ EOF
|
|
84
92
|
# Setup puppet to run on system reboot
|
85
93
|
/sbin/chkconfig --level 345 puppet on
|
86
94
|
|
87
|
-
|
88
|
-
echo "Disabling various system services"
|
89
|
-
<% %w{autofs gpm sendmail cups iptables ip6tables auditd arptables_jf xfs pcmcia isdn rawdevices hpoj bluetooth openibd avahi-daemon avahi-dnsconfd hidd hplip pcscd restorecond mcstrans rhnsd yum-updatesd}.each do |service| -%>
|
90
|
-
/sbin/chkconfig --level 345 <%= service %> off 2>/dev/null
|
91
|
-
<% end -%>
|
92
|
-
|
93
|
-
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server <%= @host.puppetmaster %> --no-daemonize
|
95
|
+
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server <%= @host.puppetmaster %> --no-daemonize
|
94
96
|
|
95
|
-
|
97
|
+
sync
|
96
98
|
|
97
99
|
# Inform the build system that we are done.
|
98
100
|
echo "Informing Foreman that we are built"
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#kind: provision
|
2
|
+
#name: Community Kickstart RHEL
|
3
|
+
#oses:
|
4
|
+
#- RedHat 5
|
5
|
+
#- RedHat 6
|
6
|
+
install
|
7
|
+
<%= @mediapath %>
|
8
|
+
lang en_US.UTF-8
|
9
|
+
selinux --permissive
|
10
|
+
keyboard us
|
11
|
+
skipx
|
12
|
+
network --bootproto <%= @static ? "static" : "dhcp" %> --hostname <%= @host %>
|
13
|
+
rootpw --iscrypted <%= root_pass %>
|
14
|
+
firewall --<%= @host.operatingsystem.major.to_i >= 6 ? "service=" : "" %>ssh
|
15
|
+
authconfig --useshadow --passalgo=sha256 --kickstart
|
16
|
+
timezone UTC
|
17
|
+
services --disabled autofs,gpm,sendmail,cups,iptables,ip6tables,auditd,arptables_jf,xfs,pcmcia,isdn,rawdevices,hpoj,bluetooth,openibd,avahi-daemon,avahi-dnsconfd,hidd,hplip,pcscd,restorecond,mcstrans,rhnsd,yum-updatesd
|
18
|
+
|
19
|
+
repo --name="Extra Packages for Enterprise Linux" --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %>
|
20
|
+
|
21
|
+
bootloader --location=mbr --append="nofb quiet splash=quiet" <%= grub_pass %>
|
22
|
+
key --skip
|
23
|
+
|
24
|
+
<% if @dynamic -%>
|
25
|
+
%include /tmp/diskpart.cfg
|
26
|
+
<% else -%>
|
27
|
+
<%= @host.diskLayout %>
|
28
|
+
<% end -%>
|
29
|
+
|
30
|
+
text
|
31
|
+
reboot
|
32
|
+
|
33
|
+
%packages --ignoremissing
|
34
|
+
yum
|
35
|
+
dhclient
|
36
|
+
ntp
|
37
|
+
wget
|
38
|
+
@Core
|
39
|
+
epel-release
|
40
|
+
puppet
|
41
|
+
|
42
|
+
<% if @dynamic -%>
|
43
|
+
%pre
|
44
|
+
<%= @host.diskLayout %>
|
45
|
+
<% end -%>
|
46
|
+
|
47
|
+
%post --nochroot
|
48
|
+
exec < /dev/tty3 > /dev/tty3
|
49
|
+
#changing to VT 3 so that we can see whats going on....
|
50
|
+
/usr/bin/chvt 3
|
51
|
+
(
|
52
|
+
cp -va /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
|
53
|
+
/usr/bin/chvt 1
|
54
|
+
) 2>&1 | tee /mnt/sysimage/root/install.postnochroot.log
|
55
|
+
|
56
|
+
%post
|
57
|
+
logger "Starting anaconda <%= @host %> postinstall"
|
58
|
+
exec < /dev/tty3 > /dev/tty3
|
59
|
+
#changing to VT 3 so that we can see whats going on....
|
60
|
+
/usr/bin/chvt 3
|
61
|
+
(
|
62
|
+
#update local time
|
63
|
+
echo "updating system time"
|
64
|
+
/usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] || "0.fedora.pool.ntp.org" %>
|
65
|
+
/usr/sbin/hwclock --systohc
|
66
|
+
|
67
|
+
# update all the base packages from the updates repository
|
68
|
+
yum -t -y -e 0 update
|
69
|
+
|
70
|
+
<%= snippets "subscription_manager_registration" %>
|
71
|
+
|
72
|
+
# and add the puppet package
|
73
|
+
yum -t -y -e 0 install puppet
|
74
|
+
|
75
|
+
echo "Configuring puppet"
|
76
|
+
cat > /etc/puppet/puppet.conf << EOF
|
77
|
+
<%= snippets "puppet.conf" %>
|
78
|
+
EOF
|
79
|
+
|
80
|
+
# Setup puppet to run on system reboot
|
81
|
+
/sbin/chkconfig --level 345 puppet on
|
82
|
+
|
83
|
+
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag --server <%= @host.puppetmaster %> --no-daemonize
|
84
|
+
|
85
|
+
sync
|
86
|
+
|
87
|
+
# Inform the build system that we are done.
|
88
|
+
echo "Informing Foreman that we are built"
|
89
|
+
wget -q -O /dev/null --no-check-certificate <%= foreman_url %>
|
90
|
+
# Sleeping an hour for debug
|
91
|
+
) 2>&1 | tee /root/install.post.log
|
92
|
+
exit 0
|
@@ -1,8 +1,11 @@
|
|
1
1
|
<% if @host.params['kt_org'] and @host.params['kt_activation_keys'] %>
|
2
2
|
# add subscription manager
|
3
3
|
yum -t -y -e 0 install subscription-manager
|
4
|
-
|
4
|
+
rpm -ivh <%= subscription_manager_configuration_url %>
|
5
5
|
|
6
6
|
echo "Registering the System"
|
7
7
|
subscription-manager register --org=<%= @host.params['kt_org']%> --name=<%= @host.name %> --activationkey=<%= @host.params['kt_activation_keys'] %>
|
8
8
|
<% end %>
|
9
|
+
<% if @host.puppetmaster %>
|
10
|
+
subscription-manager config --rhsm.baseurl=https://<%= @host.puppetmaster %>/pulp/repos
|
11
|
+
<% end %>
|
@@ -2,12 +2,17 @@ class AddKatelloTemplates < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
3
3
|
ConfigTemplate.where(:name => "Katello Kickstart Default").first_or_create!(
|
4
4
|
:template_kind_id => TemplateKind.find_by_name('provision').id,
|
5
|
-
:operatingsystem_ids => Redhat.
|
5
|
+
:operatingsystem_ids => Operatingsystem.where("name not like ? and type = ?", "Red Hat Enterprise Linux", "Redhat").map(&:id),
|
6
6
|
:template => File.read("#{ForemanKatelloEngine::Engine.root}/app/views/unattended/kickstart-katello.erb"))
|
7
|
+
|
8
|
+
ConfigTemplate.where(:name => "Katello Kickstart Default for RHEL").first_or_create!(
|
9
|
+
:template_kind_id => TemplateKind.find_by_name('provision').id,
|
10
|
+
:operatingsystem_ids => Redhat.where("name like ?", "Red Hat Enterprise Linux").map(&:id),
|
11
|
+
:template => File.read("#{ForemanKatelloEngine::Engine.root}/app/views/unattended/kickstart-katello_rhel.erb"))
|
7
12
|
|
8
|
-
ConfigTemplate.where(:name => "
|
13
|
+
ConfigTemplate.where(:name => "subscription_manager_registration").first_or_create!(
|
9
14
|
:snippet => true,
|
10
|
-
:template => File.read("#{ForemanKatelloEngine::Engine.root}/app/views/unattended/snippets/
|
15
|
+
:template => File.read("#{ForemanKatelloEngine::Engine.root}/app/views/unattended/snippets/_subscription_manager_registration.erb"))
|
11
16
|
rescue Exception => e
|
12
17
|
# something bad happened, but we don't want to break the migration process
|
13
18
|
Rails.logger.warn "Failed to migrate #{e}"
|
@@ -9,6 +9,7 @@ module ForemanKatelloEngine
|
|
9
9
|
{
|
10
10
|
:base_url => Setting['katello_url'],
|
11
11
|
:enable_validations => false,
|
12
|
+
:system => 'system_foreman',
|
12
13
|
:oauth => {
|
13
14
|
:consumer_key => Setting['oauth_consumer_key'],
|
14
15
|
:consumer_secret => Setting['oauth_consumer_secret']
|
@@ -17,15 +18,15 @@ module ForemanKatelloEngine
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def environment
|
20
|
-
KatelloApi::Resources::Environment
|
21
|
+
resource(KatelloApi::Resources::Environment)
|
21
22
|
end
|
22
23
|
|
23
24
|
def content_view
|
24
|
-
KatelloApi::Resources::ContentView
|
25
|
+
resource(KatelloApi::Resources::ContentView)
|
25
26
|
end
|
26
27
|
|
27
28
|
def activation_key
|
28
|
-
KatelloApi::Resources::ActivationKey
|
29
|
+
resource(KatelloApi::Resources::ActivationKey)
|
29
30
|
end
|
30
31
|
|
31
32
|
def activation_keys_to_subscriptions(org_label, env_label, content_view_label = nil)
|
@@ -51,6 +52,17 @@ module ForemanKatelloEngine
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
private
|
56
|
+
|
57
|
+
# configure resource client to be used to call Katello.
|
58
|
+
# We need to do this for every resoruce right now.
|
59
|
+
# We might improve this on foreman_api side later.
|
60
|
+
def resource(resource_class)
|
61
|
+
resource = resource_class.new(client_config)
|
62
|
+
resource.client.options[:headers]['HTTP_KATELLO_USER'] = User.current.login
|
63
|
+
return resource
|
64
|
+
end
|
65
|
+
|
54
66
|
end
|
55
67
|
end
|
56
68
|
|
data/test/lib/bindings_test.rb
CHANGED
@@ -4,6 +4,7 @@ require 'mocha/setup'
|
|
4
4
|
class BindingsTest < ActiveSupport::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
+
User.current = User.find_by_login('one')
|
7
8
|
Setting::Auth.load_defaults
|
8
9
|
Setting::Katello.load_defaults
|
9
10
|
end
|
@@ -12,10 +13,12 @@ class BindingsTest < ActiveSupport::TestCase
|
|
12
13
|
Setting::Katello['katello_url'] = 'https://example.com/katello'
|
13
14
|
Setting::Auth['oauth_consumer_key'] = 'key'
|
14
15
|
Setting::Auth['oauth_consumer_secret'] = 'secret'
|
15
|
-
|
16
|
+
resource = ForemanKatelloEngine::Bindings.environment
|
17
|
+
config = resource.config
|
16
18
|
assert_equal 'https://example.com/katello', config[:base_url]
|
17
19
|
assert_equal 'key', config[:oauth][:consumer_key]
|
18
20
|
assert_equal 'secret', config[:oauth][:consumer_secret]
|
21
|
+
assert_equal 'one', resource.client.options[:headers]['HTTP_KATELLO_USER']
|
19
22
|
end
|
20
23
|
|
21
24
|
test 'activation keys to subscriptions mapping' do
|
data/test/lib/settings_test.rb
CHANGED
@@ -2,6 +2,10 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class SettingsTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
+
def setup
|
6
|
+
Setting::Katello.all.each(&:destroy)
|
7
|
+
end
|
8
|
+
|
5
9
|
test "katello specific settings" do
|
6
10
|
Setting::Katello.load_defaults
|
7
11
|
assert_equal 'https://localhost/katello', Setting::Katello['katello_url']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-katello-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -63,7 +63,8 @@ files:
|
|
63
63
|
- app/views/foreman_katello_engine/activation_keys/_host_environment_select.html.erb
|
64
64
|
- app/views/foreman_katello_engine/layout/_katello_link.html.erb
|
65
65
|
- app/views/unattended/kickstart-katello.erb
|
66
|
-
- app/views/unattended/snippets/
|
66
|
+
- app/views/unattended/snippets/_subscription_manager_registration.erb
|
67
|
+
- app/views/unattended/kickstart-katello_rhel.erb
|
67
68
|
- app/assets/images/foreman_katello_engine/link.png
|
68
69
|
- app/overrides/add_activation_keys_input.rb
|
69
70
|
- app/overrides/add_katello_link.rb
|