oscar 0.2.0alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG +12 -0
- data/Gemfile +1 -0
- data/LICENSE +14 -0
- data/README.markdown +97 -0
- data/Vagrantfile +6 -0
- data/bootstrap/base/pre/set_hostname.sh +3 -0
- data/bootstrap/base/provision/install_puppet_enterprise.sh +6 -0
- data/bootstrap/master/post/relocate_puppet.sh +23 -0
- data/config/.gitignore +1 -0
- data/config/roles.yaml.dist +17 -0
- data/doc/answers/README.markdown +1 -0
- data/doc/answers/agent.txt +10 -0
- data/doc/answers/master-1.1.txt +22 -0
- data/doc/answers/master-2.0.0.txt +42 -0
- data/doc/answers/master-2.5.0.txt +36 -0
- data/doc/answers/master-db.txt +52 -0
- data/lib/oscar.rb +17 -0
- data/lib/oscar/config.rb +97 -0
- data/lib/oscar/environment.rb +28 -0
- data/lib/oscar/networking.rb +47 -0
- data/lib/oscar/node.rb +91 -0
- data/lib/oscar/schema.yaml +73 -0
- data/lib/oscar/version.rb +3 -0
- data/lib/pe_build.rb +13 -0
- data/lib/pe_build/action.rb +20 -0
- data/lib/pe_build/action/download.rb +56 -0
- data/lib/pe_build/action/unpackage.rb +70 -0
- data/lib/pe_build/command.rb +31 -0
- data/lib/pe_build/command/download.rb +8 -0
- data/lib/pe_build/command/list.rb +10 -0
- data/lib/pe_build/config.rb +30 -0
- data/lib/pe_build/provisioners.rb +9 -0
- data/lib/pe_build/provisioners/puppet_enterprise.rb +1 -0
- data/lib/pe_build/provisioners/puppet_enterprise_bootstrap.rb +138 -0
- data/lib/pe_build/version.rb +5 -0
- data/manifests/.gitignore +3 -0
- data/modules/.gitignore +2 -0
- data/oscar.gemspec +27 -0
- data/templates/answers/agent.txt.erb +10 -0
- data/templates/answers/master.txt.erb +52 -0
- metadata +175 -0
data/.gitignore
ADDED
data/CHANGELOG
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
=========
|
3
|
+
|
4
|
+
0.2.0alpha1
|
5
|
+
-----------
|
6
|
+
|
7
|
+
* vagrant-hosts has been split out into an independent gem
|
8
|
+
* Added Gemfile, gemspec.
|
9
|
+
* Cleanup around validating and extracting the PE installer tarball
|
10
|
+
* Add support for autogenerated answers files.
|
11
|
+
* Perform the GRAND RENAMING from SoupKitchen to Oscar. It's the last
|
12
|
+
rename, I promise.
|
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright 2012 Adrien Thebo
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
Instapants
|
2
|
+
==========
|
3
|
+
|
4
|
+
Create a full Puppet Enterprise environment from vagrant base boxes.
|
5
|
+
|
6
|
+
Versions
|
7
|
+
--------
|
8
|
+
|
9
|
+
Right now, the master branch of soupkitchen is going through a major rewrite.
|
10
|
+
The codebase is in flux and thus the documentation is really going to be based
|
11
|
+
on inline comments.
|
12
|
+
|
13
|
+
All of the supported behavior before the write has been tagged as version 0.0.1
|
14
|
+
and is the reference point for the following documentation.
|
15
|
+
|
16
|
+
Prerequisites
|
17
|
+
-------------
|
18
|
+
|
19
|
+
* Vagrant 1.0
|
20
|
+
* Virtualbox 4.x (4.0 strongly recommended for OSX 10.7)
|
21
|
+
|
22
|
+
Installation
|
23
|
+
------------
|
24
|
+
|
25
|
+
git clone git://github.com/adrienthebo/soupkitchen
|
26
|
+
git checkout 0.0.1
|
27
|
+
cd soupkitchen
|
28
|
+
|
29
|
+
# You'll need a config.yaml to specify how to build the environment. Contact your
|
30
|
+
# friendly neighborhood Puppet support monkey on where this is located. Place
|
31
|
+
# this file in the insta-pe directory.
|
32
|
+
wget http://your.web.server/insta-pe/config.yaml
|
33
|
+
|
34
|
+
# You'll also need the extracted universal installers for Puppet Enterprise.
|
35
|
+
# Place the extracted installers in insta-pe/files.
|
36
|
+
cd soupkitchen/files
|
37
|
+
tar xvf puppet-enterprise-X.Y.Z.tar.gz
|
38
|
+
|
39
|
+
# soupkitchen assumes the you either have all your vagrant boxes already added or
|
40
|
+
# are hosted on a webserver.
|
41
|
+
vagrant up
|
42
|
+
|
43
|
+
Configuration
|
44
|
+
-------------
|
45
|
+
|
46
|
+
Configuration is provided through a yaml file. (Yes, the vagrant config file
|
47
|
+
has a config file. Deal with it.) The top level values are all keys. You'll
|
48
|
+
have something like this:
|
49
|
+
|
50
|
+
---
|
51
|
+
# Configuration settings for Puppet Enterprise.
|
52
|
+
pe:
|
53
|
+
# The version of PE to install. Using a version of 0.0.0 disables the installation
|
54
|
+
version: 2.5.1
|
55
|
+
installer_path: /vagrant/files/puppet-enterprise-%s-all/puppet-enterprise-installer
|
56
|
+
installer:
|
57
|
+
# The program to execute to run the PE install. You can insert 'bash -x' to do a trace
|
58
|
+
# of the installation. Any string containing :version will be replaced with the current version.
|
59
|
+
executable: /vagrant/files/puppet-enterprise-:version-all/puppet-enterprise-installer
|
60
|
+
args:
|
61
|
+
# Additional arguments to pass to the installer
|
62
|
+
- "-l /root/puppet-enterprise-installer.log"
|
63
|
+
- "-D"
|
64
|
+
- "| tee /root/installer-all.log"
|
65
|
+
|
66
|
+
# Profiles are generic configurations for a basebox
|
67
|
+
profiles:
|
68
|
+
# One or more key/value pairs, where the name is the profile name and the values are hashes.
|
69
|
+
debian:
|
70
|
+
# The vagrant base box to use.
|
71
|
+
boxname: debian-6.0.4-i386
|
72
|
+
# The URL that the box can be downloaded from. This is optional
|
73
|
+
boxurl: http://your.web.server/insta-pe/debian-6.0.4-i386.box
|
74
|
+
# add more profiles as necessary
|
75
|
+
|
76
|
+
# Your actual node definitions. This is an array of hashes
|
77
|
+
nodes:
|
78
|
+
-
|
79
|
+
# name: the name of the node to address with vagrant commands
|
80
|
+
name: master
|
81
|
+
# role: one of (master, agent). Self explanatory.
|
82
|
+
role: master
|
83
|
+
# The name of the profile to use in the previous section.
|
84
|
+
profile: debian
|
85
|
+
# The IP address to assign for the host
|
86
|
+
address: 10.16.1.2
|
87
|
+
# A hash where the keys are VM port names and the values are hypervisor port names. Optional.
|
88
|
+
# You'll want to forward 443 on the master to your hypervisor for access to the PEC.
|
89
|
+
forwards:
|
90
|
+
443: 20443
|
91
|
+
|
92
|
+
You can also view the config.yaml.example in this directory.
|
93
|
+
|
94
|
+
Caveats
|
95
|
+
-------
|
96
|
+
|
97
|
+
Do not look at the Vagrantfile in this directory. You'll go blind.
|
data/Vagrantfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Update puppet.conf to add the manifestdir directive to point to the
|
2
|
+
# /manifests mount, if the directive isn't already present.
|
3
|
+
sed -i '
|
4
|
+
2 {
|
5
|
+
/manifest/ !i\
|
6
|
+
manifestdir = /manifests
|
7
|
+
}
|
8
|
+
' /etc/puppetlabs/puppet/puppet.conf
|
9
|
+
|
10
|
+
# Update puppet.conf to add the modulepath directive to point to the
|
11
|
+
# /module mount, if it hasn't already been set.
|
12
|
+
sed -i '
|
13
|
+
/modulepath/ {
|
14
|
+
/vagrant/ !s,$,:/modules,
|
15
|
+
}
|
16
|
+
' /etc/puppetlabs/puppet/puppet.conf
|
17
|
+
|
18
|
+
# Rewrite the olde site.pp config since it's not used, and warn people
|
19
|
+
# about this.
|
20
|
+
echo '# /etc/puppetlabs/puppet/manifests is not used; see /manifests.' > /etc/puppetlabs/puppet/manifests/site.pp
|
21
|
+
|
22
|
+
# Enable autosigning on the master
|
23
|
+
echo '*' > /etc/puppetlabs/puppet/autosign.conf
|
data/config/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*
|
@@ -0,0 +1 @@
|
|
1
|
+
These are reference answers files for the various versions of PE.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_install=n
|
4
|
+
q_puppet_symlinks_install=y
|
5
|
+
q_puppetagent_certname=$(hostname -s)
|
6
|
+
q_puppetagent_install=y
|
7
|
+
q_puppetagent_server=master
|
8
|
+
q_puppetmaster_install=n
|
9
|
+
q_vendor_packages_install=y
|
10
|
+
q_continue_or_reenter_master_hostname=c
|
@@ -0,0 +1,22 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_symlinks_install=y
|
3
|
+
q_puppetagent_certname=master
|
4
|
+
q_puppetagent_install=y
|
5
|
+
q_puppetagent_pluginsync=y
|
6
|
+
q_puppetagent_server=master
|
7
|
+
q_puppetdashboard_database_install=y
|
8
|
+
q_puppetdashboard_database_name=console
|
9
|
+
q_puppetdashboard_database_password=puppet
|
10
|
+
q_puppetdashboard_database_root_password=puppet
|
11
|
+
q_puppetdashboard_database_user=console
|
12
|
+
q_puppetdashboard_httpd_port=443
|
13
|
+
q_puppetdashboard_install=y
|
14
|
+
q_puppetmaster_certdnsnames=master:puppet
|
15
|
+
q_puppetmaster_certname=master
|
16
|
+
q_puppetmaster_dashboard_hostname=master
|
17
|
+
q_puppetmaster_dashboard_port=443
|
18
|
+
q_puppetmaster_install=y
|
19
|
+
q_puppetmaster_use_dashboard_classifier=y
|
20
|
+
q_puppetmaster_use_dashboard_reports=y
|
21
|
+
q_rubydevelopment_install=y
|
22
|
+
q_vendor_packages_install=y
|
@@ -0,0 +1,42 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
4
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_password=console
|
7
|
+
q_puppet_enterpriseconsole_auth_user_email=console@example.com
|
8
|
+
q_puppet_enterpriseconsole_database_install=y
|
9
|
+
q_puppet_enterpriseconsole_database_name=console
|
10
|
+
q_puppet_enterpriseconsole_database_password=console
|
11
|
+
q_puppet_enterpriseconsole_database_remote=n
|
12
|
+
q_puppet_enterpriseconsole_database_root_password=root
|
13
|
+
q_puppet_enterpriseconsole_database_user=console
|
14
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
15
|
+
q_puppet_enterpriseconsole_install=y
|
16
|
+
q_puppet_enterpriseconsole_inventory_hostname=$(hostname -s)
|
17
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
18
|
+
q_puppet_enterpriseconsole_master_hostname=$(hostname -s)
|
19
|
+
q_puppet_enterpriseconsole_smtp_host=smtp.google.com
|
20
|
+
q_puppet_enterpriseconsole_smtp_password=
|
21
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
22
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
23
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
24
|
+
q_puppet_enterpriseconsole_smtp_username=
|
25
|
+
q_puppet_symlinks_install=y
|
26
|
+
q_puppetagent_certname=$(hostname -s)
|
27
|
+
q_puppetagent_install=y
|
28
|
+
q_puppetagent_server=$(hostname -s)
|
29
|
+
q_puppetca_install=y
|
30
|
+
q_puppetmaster_certname=$(hostname -s)
|
31
|
+
q_puppetmaster_dnsaltnames=$(hostname -s),puppet,$(hostname -f),puppet.$(domainname)
|
32
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
33
|
+
q_puppetmaster_enterpriseconsole_port=443
|
34
|
+
q_puppetmaster_forward_facts=n
|
35
|
+
q_puppetmaster_install=y
|
36
|
+
q_vendor_packages_install=y
|
37
|
+
|
38
|
+
# pe 2.0 option
|
39
|
+
q_puppet_enterpriseconsole_auth_user=console
|
40
|
+
|
41
|
+
# pe 2.0 - 2.5 upgrade options
|
42
|
+
q_puppet_enterpriseconsole_setup_auth_db=y
|
@@ -0,0 +1,36 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
4
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_password=console
|
7
|
+
q_puppet_enterpriseconsole_auth_user_email=console@soupkitchen.internal
|
8
|
+
q_puppet_enterpriseconsole_database_install=y
|
9
|
+
q_puppet_enterpriseconsole_database_name=console
|
10
|
+
q_puppet_enterpriseconsole_database_password=console
|
11
|
+
q_puppet_enterpriseconsole_database_remote=n
|
12
|
+
q_puppet_enterpriseconsole_database_root_password=console
|
13
|
+
q_puppet_enterpriseconsole_database_user=console
|
14
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
15
|
+
q_puppet_enterpriseconsole_install=y
|
16
|
+
q_puppet_enterpriseconsole_inventory_hostname=$(hostname -s)
|
17
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
18
|
+
q_puppet_enterpriseconsole_master_hostname=$(hostname -s)
|
19
|
+
q_puppet_enterpriseconsole_smtp_host=localhost
|
20
|
+
q_puppet_enterpriseconsole_smtp_password=
|
21
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
22
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
23
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
24
|
+
q_puppet_enterpriseconsole_smtp_username=
|
25
|
+
q_puppet_symlinks_install=y
|
26
|
+
q_puppetagent_certname=$(hostname -s)
|
27
|
+
q_puppetagent_install=y
|
28
|
+
q_puppetagent_server=$(hostname -s)
|
29
|
+
q_puppetca_install=y
|
30
|
+
q_puppetmaster_certname=$(hostname -s)
|
31
|
+
q_puppetmaster_dnsaltnames=$(hostname -s),puppet,$(hostname -f),puppet.$(domainname)
|
32
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
33
|
+
q_puppetmaster_enterpriseconsole_port=443
|
34
|
+
q_puppetmaster_forward_facts=n
|
35
|
+
q_puppetmaster_install=y
|
36
|
+
q_vendor_packages_install=y
|
@@ -0,0 +1,52 @@
|
|
1
|
+
q_install=y
|
2
|
+
q_puppet_cloud_install=n
|
3
|
+
|
4
|
+
q_puppet_enterpriseconsole_auth_database_name=console_auth
|
5
|
+
q_puppet_enterpriseconsole_auth_database_password=console_auth
|
6
|
+
q_puppet_enterpriseconsole_auth_database_user=console_auth
|
7
|
+
q_puppet_enterpriseconsole_auth_password=console
|
8
|
+
q_puppet_enterpriseconsole_auth_user_email=console@example.com
|
9
|
+
|
10
|
+
# Use existing database
|
11
|
+
q_puppet_enterpriseconsole_database_install=n
|
12
|
+
q_puppet_enterpriseconsole_setup_db=y
|
13
|
+
|
14
|
+
q_puppet_enterpriseconsole_database_name=console
|
15
|
+
q_puppet_enterpriseconsole_database_user=console
|
16
|
+
q_puppet_enterpriseconsole_database_password=console
|
17
|
+
q_puppet_enterpriseconsole_database_remote=n
|
18
|
+
q_puppet_enterpriseconsole_database_root_password=console
|
19
|
+
|
20
|
+
q_puppet_enterpriseconsole_httpd_port=443
|
21
|
+
q_puppet_enterpriseconsole_install=y
|
22
|
+
|
23
|
+
q_puppet_enterpriseconsole_inventory_hostname=master
|
24
|
+
q_puppet_enterpriseconsole_inventory_port=8140
|
25
|
+
|
26
|
+
q_puppet_enterpriseconsole_master_hostname=master
|
27
|
+
|
28
|
+
q_puppet_enterpriseconsole_smtp_host=smtp.google.com
|
29
|
+
q_puppet_enterpriseconsole_smtp_password=
|
30
|
+
q_puppet_enterpriseconsole_smtp_port=25
|
31
|
+
q_puppet_enterpriseconsole_smtp_use_tls=n
|
32
|
+
q_puppet_enterpriseconsole_smtp_user_auth=n
|
33
|
+
q_puppet_enterpriseconsole_smtp_username=
|
34
|
+
|
35
|
+
q_puppet_symlinks_install=y
|
36
|
+
q_puppetagent_certname=master
|
37
|
+
q_puppetagent_install=y
|
38
|
+
q_puppetagent_server=master
|
39
|
+
q_puppetca_install=y
|
40
|
+
q_puppetmaster_certname=master
|
41
|
+
q_puppetmaster_dnsaltnames=master,puppet
|
42
|
+
q_puppetmaster_enterpriseconsole_hostname=localhost
|
43
|
+
q_puppetmaster_enterpriseconsole_port=443
|
44
|
+
q_puppetmaster_forward_facts=n
|
45
|
+
q_puppetmaster_install=y
|
46
|
+
q_vendor_packages_install=y
|
47
|
+
|
48
|
+
# pe 2.0 option
|
49
|
+
q_puppet_enterpriseconsole_auth_user=console
|
50
|
+
|
51
|
+
# pe 2.0 - 2.5 upgrade options
|
52
|
+
q_puppet_enterpriseconsole_setup_auth_db=y
|
data/lib/oscar.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module Oscar
|
3
|
+
|
4
|
+
def self.facehug!(directory)
|
5
|
+
env = Oscar::Environment.new
|
6
|
+
env.config.load! directory
|
7
|
+
env.run!
|
8
|
+
|
9
|
+
env
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'oscar/version'
|
14
|
+
require 'oscar/config'
|
15
|
+
require 'oscar/environment'
|
16
|
+
require 'oscar/networking'
|
17
|
+
require 'oscar/node'
|
data/lib/oscar/config.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'oscar'
|
2
|
+
require 'yaml'
|
3
|
+
require 'kwalify'
|
4
|
+
|
5
|
+
class Oscar::Config
|
6
|
+
|
7
|
+
attr_reader :data
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@data = {}
|
11
|
+
|
12
|
+
schema_path = File.expand_path(File.join(File.dirname(__FILE__), 'schema.yaml'))
|
13
|
+
schema = YAML.load_file schema_path
|
14
|
+
validator = Kwalify::Validator.new(schema)
|
15
|
+
@parser = Kwalify::Yaml::Parser.new(validator)
|
16
|
+
end
|
17
|
+
|
18
|
+
def load!(searchpath)
|
19
|
+
files = ['config.yaml', 'config'].map { |m| "#{searchpath}/#{m}" }
|
20
|
+
load_all files
|
21
|
+
end
|
22
|
+
|
23
|
+
# Recursively load any YAML files contained in the given paths.
|
24
|
+
def load_all(*paths)
|
25
|
+
paths.flatten.each do |path|
|
26
|
+
if File.file?(path) and path.match /\.yaml$/
|
27
|
+
load_file(path)
|
28
|
+
elsif File.directory? path
|
29
|
+
load_all Dir["#{path}/*"]
|
30
|
+
#else
|
31
|
+
# warn "#{path} is neither a YAML file nor a directory, ignoring it."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Load YAML from a file and merge it into the aggregated YAML
|
37
|
+
#
|
38
|
+
# @raise [TypeError] If the YAML in a given file does not match the configuration schema
|
39
|
+
def load_file(filename)
|
40
|
+
localdata = @parser.parse_file(filename)
|
41
|
+
errors = @parser.errors
|
42
|
+
|
43
|
+
if (errors and not errors.empty?)
|
44
|
+
errors.each do |err|
|
45
|
+
puts "#{filename} line #{err.linenum}, column #{err.column}, [kwalify path #{err.path}] #{err.message}"
|
46
|
+
end
|
47
|
+
raise TypeError
|
48
|
+
else
|
49
|
+
@data.merge!(localdata)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Collects all node configuration as an array of the node structured data.
|
54
|
+
#
|
55
|
+
# @return [Array<Hash<String, String>>]
|
56
|
+
def all_node_configs
|
57
|
+
names = @data["nodes"].map { |h| h['name'] }
|
58
|
+
names.map { |n| node_config(n) }
|
59
|
+
end
|
60
|
+
|
61
|
+
# Provides the structured data representation of a node.
|
62
|
+
#
|
63
|
+
# Configuration priority is 'profile' -> 'role' -> 'node'
|
64
|
+
#
|
65
|
+
# @param [String] name The name of the node to fetch
|
66
|
+
#
|
67
|
+
# @return [Hash<String, String>]
|
68
|
+
def node_config(node_name)
|
69
|
+
config = {}
|
70
|
+
|
71
|
+
unless (node_hash = @data['nodes'].find { |h| h['name'] == node_name })
|
72
|
+
raise "Node configuration for #{node_name} not found"
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check to see if the node has a profile or role. If one of those values
|
76
|
+
# do exist, try to lookup that data and merge it into the config hash.
|
77
|
+
['profile', 'role'].each do |type|
|
78
|
+
plural_type = "#{type}s"
|
79
|
+
|
80
|
+
type_name = node_hash[type] # Check to see if we have the requested type
|
81
|
+
if (type_name and type_hash = @data[plural_type].find { |t| t['name'] == type_name })
|
82
|
+
# The requested type exists in the node hash, and we were able to lookup
|
83
|
+
# the related configuration.
|
84
|
+
config.merge! type_hash
|
85
|
+
else
|
86
|
+
# The requested type exists in the node hash, but we were not able to
|
87
|
+
# lookup the related configuraion; die messily.
|
88
|
+
raise %{#{type.capitalize} configuration "#{type}" for #{node_name} not found}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Merge the node hash last so that it takes precedence
|
93
|
+
config.merge! node_hash
|
94
|
+
|
95
|
+
config
|
96
|
+
end
|
97
|
+
end
|