foreman-katello-engine 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ require 'uri'
2
+
3
+ module ForemanKatelloEngine::KatelloUrlsHelper
4
+
5
+ def katello_url
6
+ return Setting['katello_url']
7
+ end
8
+
9
+ def katello_host
10
+ URI(katello_url).host unless katello_url.nil?
11
+ end
12
+
13
+ def katello_port
14
+ URI(katello_url).port unless katello_url.nil?
15
+ end
16
+
17
+ def subscription_manager_configuration_url
18
+ "http://#{katello_host}/pub/candlepin-cert-consumer-#{katello_host}-1.0-1.noarch.rpm"
19
+ end
20
+
21
+ end
@@ -0,0 +1,104 @@
1
+ install
2
+ <%= @mediapath %>
3
+ lang en_US.UTF-8
4
+ selinux --permissive
5
+ keyboard us
6
+ skipx
7
+ network --bootproto <%= @static ? "static" : "dhcp" %> --hostname <%= @host %>
8
+ rootpw --iscrypted <%= root_pass %>
9
+ firewall --<%= @host.operatingsystem.major.to_i >= 6 ? "service=" : "" %>ssh
10
+ authconfig --useshadow --enablemd5
11
+ timezone UTC
12
+ <% if @host.operatingsystem.name == "Fedora" -%>
13
+ repo --name=fedora-everything --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %>
14
+ <% end -%>
15
+ <% if @host.operatingsystem.name == "Fedora" and @host.operatingsystem.major.to_i <= 16 -%>
16
+ # Bootloader exception for Fedora 16:
17
+ bootloader --append="nofb quiet splash=quiet <%=ks_console%>" <%= grub_pass %>
18
+ part biosboot --fstype=biosboot --size=1
19
+ <% else -%>
20
+ bootloader --location=mbr --append="nofb quiet splash=quiet" <%= grub_pass %>
21
+ <% end -%>
22
+ <% if @host.os.name == "RedHat" -%>
23
+ key --skip
24
+ <% end -%>
25
+
26
+ <% if @dynamic -%>
27
+ %include /tmp/diskpart.cfg
28
+ <% else -%>
29
+ <%= @host.diskLayout %>
30
+ <% end -%>
31
+ text
32
+ reboot
33
+
34
+ %packages
35
+ yum
36
+ dhclient
37
+ ntp
38
+ wget
39
+ @Core
40
+ <%= "%end\n" if @host.operatingsystem.name == "Fedora" %>
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
+ <%= "%end\n" if @host.operatingsystem.name == "Fedora" %>
56
+
57
+ %post
58
+ logger "Starting anaconda <%= @host %> postinstall"
59
+ exec < /dev/tty3 > /dev/tty3
60
+ #changing to VT 3 so that we can see whats going on....
61
+ /usr/bin/chvt 3
62
+ (
63
+ #update local time
64
+ echo "updating system time"
65
+ /usr/sbin/ntpdate -sub <%= @host.params["ntp-server"] || "ntp" %>
66
+ /usr/sbin/hwclock --systohc
67
+
68
+ # install epel if we can
69
+ <%= snippet 'epel' %>
70
+
71
+ # update all the base packages from the updates repository
72
+ yum -t -y -e 0 update
73
+
74
+ <%= snippets "katello_registration" %>
75
+
76
+ # and add the puppet package
77
+ yum -t -y -e 0 install puppet
78
+
79
+ echo "Configuring puppet"
80
+ cat > /etc/puppet/puppet.conf << EOF
81
+ <%= snippets "puppet.conf" %>
82
+ EOF
83
+
84
+ # Setup puppet to run on system reboot
85
+ /sbin/chkconfig --level 345 puppet on
86
+
87
+ # Disable most things. Puppet will activate these if required.
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
94
+
95
+ sync
96
+
97
+ # Inform the build system that we are done.
98
+ echo "Informing Foreman that we are built"
99
+ wget -q -O /dev/null --no-check-certificate <%= foreman_url %>
100
+ # Sleeping an hour for debug
101
+ ) 2>&1 | tee /root/install.post.log
102
+ exit 0
103
+
104
+ <%= "%end\n" if @host.operatingsystem.name == "Fedora" -%>
@@ -0,0 +1,8 @@
1
+ <% if @host.params['kt_org'] and @host.params['kt_activation_keys'] %>
2
+ # add subscription manager
3
+ yum -t -y -e 0 install subscription-manager
4
+ yum -y install <%= subscription_manager_configuration_url %>
5
+
6
+ echo "Registering the System"
7
+ subscription-manager register --org=<%= @host.params['kt_org']%> --name=<%= @host.name %> --activationkey=<%= @host.params['kt_activation_keys'] %>
8
+ <% end %>
@@ -0,0 +1,19 @@
1
+ class AddKatelloTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ ConfigTemplate.where(:name => "Katello Kickstart Default").first_or_create!(
4
+ :template_kind_id => TemplateKind.find_by_name('provision').id,
5
+ :operatingsystem_ids => Redhat.all.map(&:id),
6
+ :template => File.read("#{ForemanKatelloEngine::Engine.root}/app/views/unattended/kickstart-katello.erb"))
7
+
8
+ ConfigTemplate.where(:name => "Subscription Manager Registration").first_or_create!(
9
+ :snippet => true,
10
+ :template => File.read("#{ForemanKatelloEngine::Engine.root}/app/views/unattended/snippets/_katello_registration.erb"))
11
+ rescue Exception => e
12
+ # something bad happened, but we don't want to break the migration process
13
+ Rails.logger.warn "Failed to migrate #{e}"
14
+ return true
15
+ end
16
+
17
+ def self.down
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ class AddKatelloPtables < ActiveRecord::Migration
2
+ def up
3
+ Ptable.create :name => "Katello Fedora Default", :layout =>"zerombr\nclearpart --all --initlabel\npart /boot --fstype ext3 --size=100 --asprimary\npart / --fstype ext3 --size=1024 --grow\npart swap --recommended"
4
+ end
5
+
6
+ def down
7
+ Ptable.where(:name => "Katello Fedora Default").first.try(:destroy)
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "foreman-katello-engine"
3
- s.version = "0.0.4"
3
+ s.version = "0.0.5"
4
4
 
5
5
  s.authors = ["Katello"]
6
6
  s.date = "2013-03-04"
@@ -2,16 +2,20 @@ module ForemanKatelloEngine
2
2
  #Inherit from the Rails module of the parent app (Foreman), not the plugin.
3
3
  #Thus, inhereits from ::Rails::Engine and not from Rails::Engine
4
4
  class Engine < ::Rails::Engine
5
+ initializer "foreman_katello_engine.load_app_instance_data" do |app|
6
+ app.config.paths['db/migrate'] += ForemanKatelloEngine::Engine.paths['db/migrate'].existent
7
+ end
5
8
 
6
9
  config.after_initialize do
7
10
  require 'foreman_katello_engine/bindings'
8
11
  require 'foreman_katello_engine/settings'
12
+ require 'foreman_katello_engine/renderer'
9
13
  ForemanKatelloEngine::Settings.initialize_settings
10
14
  end
11
15
 
12
16
  initializer 'foreman_katello_engine.helper' do |app|
13
17
  ActionView::Base.send :include, ForemanKatelloEngine::HostsAndHostgroupsHelper
18
+ ActionView::Base.send :include, ForemanKatelloEngine::KatelloUrlsHelper
14
19
  end
15
-
16
20
  end
17
21
  end
@@ -0,0 +1,13 @@
1
+ require 'foreman'
2
+ require 'foreman/renderer'
3
+
4
+ module ::Foreman::Renderer
5
+ def unattended_render template
6
+ allowed_helpers = [ :foreman_url, :katello_url, :katello_host, :katello_port, :subscription_manager_configuration_url, :grub_pass, :snippet, :snippets, :ks_console, :root_pass, :multiboot, :jumpstart_path, :install_path,
7
+ :miniroot, :media_path]
8
+ allowed_variables = ({:arch => @arch, :host => @host, :osver => @osver, :mediapath => @mediapath, :static => @static,
9
+ :yumrepo => @yumrepo, :dynamic => @dynamic, :epel => @epel, :kernel => @kernel, :initrd => @initrd,
10
+ :preseed_server => @preseed_server, :preseed_path => @preseed_path })
11
+ render_safe template, allowed_helpers, allowed_variables
12
+ end
13
+ end
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/foreman_katello_engine/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
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
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -57,17 +57,24 @@ files:
57
57
  - Rakefile
58
58
  - app/controllers/activation_keys_controller.rb
59
59
  - app/helpers/foreman_katello_engine/hosts_and_hostgroups_helper.rb
60
+ - app/helpers/foreman_katello_engine/katello_urls_helper.rb
60
61
  - app/models/activation_key.rb
61
62
  - app/overrides/add_activation_keys_input.rb
62
63
  - app/views/activation_keys/_host_tab.html.erb
63
64
  - app/views/activation_keys/_host_tab_pane.html.erb
65
+ - app/views/unattended/kickstart-katello.erb
66
+ - app/views/unattended/snippets/_katello_registration.erb
64
67
  - config/routes.rb
68
+ - db/migrate/20130416152224_add_katello_templates.rb
69
+ - db/migrate/20130418105901_add_katello_ptables.rb
65
70
  - foreman-katello-engine.gemspec
66
71
  - lib/foreman-katello-engine.rb
67
72
  - lib/foreman_katello_engine.rb
68
73
  - lib/foreman_katello_engine/bindings.rb
69
74
  - lib/foreman_katello_engine/engine.rb
75
+ - lib/foreman_katello_engine/renderer.rb
70
76
  - lib/foreman_katello_engine/settings.rb
77
+ - script/rails
71
78
  - test/functional/activation_keys_controller_test.rb
72
79
  - test/lib/bindings_test.rb
73
80
  - test/lib/settings_test.rb