foreman_chef 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/foreman_chef/concerns/host_action_subject.rb +4 -0
- data/app/models/foreman_chef/concerns/renderer.rb +13 -0
- data/app/views/foreman/unattended/snippets/_chef_client_bootstrap.erb +41 -0
- data/app/views/foreman/unattended/snippets/_chef_client_gem_bootstrap.erb +4 -0
- data/app/views/foreman/unattended/snippets/_chef_client_omnibus_bootstrap.erb +10 -0
- data/db/seeds.rb +30 -0
- data/lib/foreman_chef/engine.rb +6 -0
- data/lib/foreman_chef/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92676c4caa608850b55c0663e13df92cc848793
|
4
|
+
data.tar.gz: a98cd1ada786665546e6ff3113e82238fb55773d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97bb1712a25daa936b3833c44ab3b747dd9ea7e1c73b381234bc11d79c523e0dda6024a54ea91d5b0740ecf037de0e67f8d66e48273dee4ee07f50c61e60a785
|
7
|
+
data.tar.gz: fec31d07933b0cf391fff92662b07ef2ab272c0d2d4f83735e2b2e9f87d47ff400f99797621fa67ebb7150aa0edc4c12b8f5164ed90e7b9db5c32f7790f7238a
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ForemanChef
|
2
|
+
module Concerns
|
3
|
+
module Renderer
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def chef_bootstrap(host)
|
7
|
+
snippet = host.params['chef_bootstrap_template'].present? ? host.params['chef_bootstrap_template'] : 'chef-client omnibus bootstrap'
|
8
|
+
raise SecurityError, 'snippet contains not white-listed characters' unless snippet =~ /\A[a-zA-Z0-9 _-]+\Z/
|
9
|
+
"snippet '#{snippet}'"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
echo "Creating validation.pem"
|
2
|
+
mkdir /etc/chef
|
3
|
+
touch /etc/chef/validation.pem
|
4
|
+
chmod 600 /etc/chef/validation.pem
|
5
|
+
|
6
|
+
## You need to paste here foreman's private key
|
7
|
+
cat << 'EOF' > /etc/chef/validation.pem
|
8
|
+
<%= @host.params['chef_validation_private_key'] %>
|
9
|
+
EOF
|
10
|
+
|
11
|
+
echo "Configuring chef client.rb"
|
12
|
+
cat << 'EOF' > /etc/chef/client.rb
|
13
|
+
log_level :info
|
14
|
+
log_location STDOUT
|
15
|
+
chef_server_url "<%= @host.params['chef_server_url'] %>"
|
16
|
+
validation_client_name "chef-validator"
|
17
|
+
file_backup_path "/var/lib/chef"
|
18
|
+
file_cache_path "/var/cache/chef"
|
19
|
+
pid_file "/var/run/chef/client.pid"
|
20
|
+
|
21
|
+
require 'chef_handler_foreman'
|
22
|
+
foreman_server_options :url => "<%= @host.params['chef_handler_foreman_url'] %>"
|
23
|
+
foreman_facts_upload true
|
24
|
+
foreman_reports_upload true
|
25
|
+
EOF
|
26
|
+
|
27
|
+
# You may set here the default run list for all your nodes
|
28
|
+
cat << 'EOF' > /tmp/base.json
|
29
|
+
{
|
30
|
+
"run_list": ["role[default]"]
|
31
|
+
}
|
32
|
+
EOF
|
33
|
+
|
34
|
+
#first run of chef-client
|
35
|
+
echo "First run of chef-client"
|
36
|
+
/usr/local/bin/chef-client -j /tmp/base.json || /usr/bin/chef-client -j /tmp/base.json
|
37
|
+
|
38
|
+
echo "Finished, cleaning"
|
39
|
+
rm -f /tmp/base.json
|
40
|
+
# you can comment this line to keep validaton.pem (e.g. for debugging purposes)
|
41
|
+
rm -f /etc/chef/validation.pem
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# install.sh will install latest chef client version
|
2
|
+
curl -L https://www.chef.io/chef/install.sh | bash
|
3
|
+
|
4
|
+
# if you want specific version you can use something like this instead of install.sh
|
5
|
+
# yum install https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-11.10.0-1.el6.x86_64.rpm
|
6
|
+
|
7
|
+
# install foreman integration chef handler
|
8
|
+
/opt/chef/embedded/bin/gem install chef_handler_foreman
|
9
|
+
|
10
|
+
<%= snippet 'chef-client bootstrap' %>
|
data/db/seeds.rb
CHANGED
@@ -1 +1,31 @@
|
|
1
1
|
Feature.find_or_create_by_name('Chef')
|
2
|
+
|
3
|
+
# Configuration template snippets
|
4
|
+
defaults = {:vendor => "ForemanChef", :default => true, :locked => true}
|
5
|
+
|
6
|
+
templates = [
|
7
|
+
{:name => "chef-client bootstrap", :source => "snippets/_chef_client_bootstrap.erb", :snippet => true},
|
8
|
+
{:name => "chef-client omnibus bootstrap", :source => "snippets/_chef_client_omnibus_bootstrap.erb", :snippet => true},
|
9
|
+
{:name => "chef-client gem bootstrap", :source => "snippets/_chef_client_gem_bootstrap.erb", :snippet => true},
|
10
|
+
]
|
11
|
+
|
12
|
+
templates.each do |template|
|
13
|
+
template[:template] = File.read(File.join(ForemanChef::Engine.root, "app/views/foreman/unattended", template.delete(:source)))
|
14
|
+
ConfigTemplate.find_or_create_by_name(template).update_attributes(defaults.merge(template))
|
15
|
+
end
|
16
|
+
|
17
|
+
# Global parameters used in configuration snippets
|
18
|
+
parameters = [
|
19
|
+
{ :name => 'chef_handler_foreman_url', :value => SmartProxy.chef_proxies.first.try(:url) || Setting.foreman_url },
|
20
|
+
{ :name => 'chef_server_url', :value => "https://#{Socket.gethostbyname(Socket.gethostname).first}" },
|
21
|
+
{ :name => 'chef_validation_private_key', :value => 'UNSPECIFIED, you must upload your validation key here' },
|
22
|
+
{ :name => 'chef_bootstrap_template', :value => 'chef-client omnibus bootstrap' },
|
23
|
+
{ :name => 'chef_server_certificate', :value => '' },
|
24
|
+
]
|
25
|
+
|
26
|
+
parameters.each do |parameter|
|
27
|
+
existing = CommonParameter.find_by_name(parameter[:name])
|
28
|
+
unless existing
|
29
|
+
CommonParameter.create(:name => parameter[:name], :value => parameter[:value])
|
30
|
+
end
|
31
|
+
end
|
data/lib/foreman_chef/engine.rb
CHANGED
@@ -26,11 +26,13 @@ module ForemanChef
|
|
26
26
|
initializer 'foreman_chef.register_plugin', :after => :finisher_hook do |app|
|
27
27
|
Foreman::Plugin.register :foreman_chef do
|
28
28
|
requires_foreman '>= 1.4'
|
29
|
+
allowed_template_helpers :chef_bootstrap
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
initializer 'foreman_chef.chef_proxy_form' do |app|
|
33
34
|
ActionView::Base.send :include, ChefProxyForm
|
35
|
+
ActionView::Base.send :include, ForemanChef::Concerns::Renderer
|
34
36
|
end
|
35
37
|
|
36
38
|
initializer 'foreman_chef.dynflow_world', :before => 'foreman_tasks.initialize_dynflow' do |app|
|
@@ -47,5 +49,9 @@ module ForemanChef
|
|
47
49
|
::FactImporter.register_fact_importer(:foreman_chef, ForemanChef::FactImporter)
|
48
50
|
::Host::Base.send :include, ForemanChef::Concerns::HostActionSubject
|
49
51
|
end
|
52
|
+
|
53
|
+
config.after_initialize do
|
54
|
+
::Foreman::Renderer.send :include, ForemanChef::Concerns::Renderer
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
data/lib/foreman_chef/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marek Hulan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -81,11 +81,15 @@ files:
|
|
81
81
|
- app/models/foreman_chef/hostgroup_extensions.rb
|
82
82
|
- app/models/foreman_chef/host_extensions.rb
|
83
83
|
- app/models/foreman_chef/fact_importer.rb
|
84
|
+
- app/models/foreman_chef/concerns/renderer.rb
|
84
85
|
- app/models/foreman_chef/concerns/host_action_subject.rb
|
85
86
|
- app/models/setting/foreman_chef.rb
|
86
87
|
- app/lib/actions/foreman_chef/client/destroy.rb
|
87
88
|
- app/lib/actions/foreman_chef/host/destroy.rb
|
88
89
|
- app/lib/proxy_api/foreman_chef/chef_proxy.rb
|
90
|
+
- app/views/foreman/unattended/snippets/_chef_client_gem_bootstrap.erb
|
91
|
+
- app/views/foreman/unattended/snippets/_chef_client_omnibus_bootstrap.erb
|
92
|
+
- app/views/foreman/unattended/snippets/_chef_client_bootstrap.erb
|
89
93
|
- config/routes.rb
|
90
94
|
- db/migrate/20140513144804_add_chef_proxy_id_to_hostgroup.rb
|
91
95
|
- db/migrate/20140220145827_add_chef_proxy_id_to_host.rb
|