summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support
diff options
context:
space:
mode:
authorMustapha Lansana <Mustapha.Lansana@windriver.com>2014-05-27 22:02:56 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-09-26 09:09:21 -0400
commiteeda01a7be07c78dac7b6ae5013524d857ceba3b (patch)
tree742c4abd9d6877d2fa1ca7f16eb917ffe5434ea7 /meta-openstack/recipes-support
parent98e1afbc185a7f87427860f4273a7285e5b6407e (diff)
downloadmeta-cloud-services-eeda01a7be07c78dac7b6ae5013524d857ceba3b.tar.gz
deploychef: configure chef-solo for deploychef package
The deploychef package uses chef-solo to reconfigure an openstack installation by converting services' configuration files to template files. The attributes file defines the constants chef-solo uses to generate configuration files/scripts. The recipe file describes how those files/scripts should be created. The config and .json files are input to chef-solo and describe location of files. Later in this series, the attributes file will be replaced by a dynamically generated attributes file. In addition, the recipe file will change to accommodate changes to deploychef in order to support openstackchef. Signed-off-by: Mustapha Lansana <Mustapha.Lansana@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-support')
-rw-r--r--meta-openstack/recipes-support/deploychef/files/attributes.json3
-rw-r--r--meta-openstack/recipes-support/deploychef/files/chefsolo_default_attribute.rb76
-rw-r--r--meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb264
-rw-r--r--meta-openstack/recipes-support/deploychef/files/config.rb29
4 files changed, 372 insertions, 0 deletions
diff --git a/meta-openstack/recipes-support/deploychef/files/attributes.json b/meta-openstack/recipes-support/deploychef/files/attributes.json
new file mode 100644
index 0000000..ac077fb
--- /dev/null
+++ b/meta-openstack/recipes-support/deploychef/files/attributes.json
@@ -0,0 +1,3 @@
1{
2 "run_list": [ "recipe[openstack::default]" ]
3}
diff --git a/meta-openstack/recipes-support/deploychef/files/chefsolo_default_attribute.rb b/meta-openstack/recipes-support/deploychef/files/chefsolo_default_attribute.rb
new file mode 100644
index 0000000..caf5af2
--- /dev/null
+++ b/meta-openstack/recipes-support/deploychef/files/chefsolo_default_attribute.rb
@@ -0,0 +1,76 @@
1#
2# Copyright (c) 2014 Wind River Systems, Inc.
3#
4# Permission is hereby granted, free of charge, to any person obtaining a copy
5# of this software and associated documentation files (the "Software"), to deal
6# in the Software without restriction, including without limitation the rights
7# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8# copies of the Software, and to permit persons to whom the Software is
9# furnished to do so, subject to the following conditions:
10#
11# The above copyright notice and this permission notice shall be included in
12# all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20# THE SOFTWARE.
21#
22#
23#These are the default values that chef-solo uses
24#to convert our template files into the respective
25#configuration and script files we want it to bake.
26#Note though that Some of which are overwritten in the recipe file(s)
27
28default["CHEFROOT_DIR"] ="%DEPLOYCHEF_ROOT_DIR%/"
29default["TEMPLATE_DIR"] ="#{node[:CHEFROOT_DIR]}cookbooks/openstack/templates/default/*"
30default["ETC_DIR"]= "%SYSCONFDIR%/"
31default["POSTINSTS_DIR"] ="#{node[:ETC_DIR]}%POSTINSTS_DIR%/"
32default["NOVA_CONF_DIR"]="#{node[:ETC_DIR]}nova/"
33default["SWIFT_CONF_DIR"]="#{node[:ETC_DIR]}swift/"
34default["CEILOMETER_CONF_DIR"]="#{node[:ETC_DIR]}ceilometer/"
35default["NEUTRON_CONF_DIR"]= "#{node[:ETC_DIR]}neutron/"
36default["NEUTRON_CORE_PLUGIN"]= "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2"
37default["OPENVSWITCH_CONF_DIR"]= "#{node[:NEUTRON_CONF_DIR]}plugins/openvswitch/"
38default["LINUXBRIDGE_CONF_DIR"]= "#{node[:NEUTRON_CONF_DIR]}plugins/linuxbridge/"
39default["KEYSTONE_CONF_DIR"]= "#{node[:ETC_DIR]}keystone/"
40default["CINDER_CONF_DIR"]= "#{node[:ETC_DIR]}cinder/"
41default["GLANCE_CONF_DIR"]= "#{node[:ETC_DIR]}glance/"
42default["CEPH_CONF_DIR"]= "#{node[:ETC_DIR]}ceph/"
43default["DB_DATADIR"]= "#{node[:ETC_DIR]}postgresql/"
44default["HEAT_CONF_DIR"]= "#{node[:ETC_DIR]}heat/"
45
46default["INITD_DIR"]= "#{node[:ETC_DIR]}init.d/"
47default["CONTROLLER_DAEMON"]= "#{node[:INITD_DIR]}nova-api"
48default["COMPUTE_DAEMON"]= "#{node[:INITD_DIR]}nova-compute"
49default["NODE_TYPE"]="compute"
50default["NODE_TYPES"]="compute controller allinone"
51default["POSTINSTS_SCRIPT"] = "run-postinsts"
52default["PREINSTS_SCRIPT"] = "service-shutdown"
53default["AUTH_PROTOCOL"] = "http"
54default["PRIVATE_IP"] = "127.0.0.1"
55
56default["CONTROLLER_IP"] = "%CONTROLLER_IP%"
57default["CONTROLLER_HOST"] = "%CONTROLLER_HOST%"
58default["COMPUTE_IP"] = "%COMPUTE_IP%"
59default["COMPUTE_HOST"] = "%COMPUTE_HOST%"
60default["ADMIN_PASSWORD"] = "%ADMIN_PASSWORD%"
61default["SERVICE_PASSWORD"] = "%SERVICE_PASSWORD%"
62default["SERVICE_TENANT_NAME"] ="%SERVICE_TENANT_NAME%"
63default["SERVICE_USER"] ="%SERVICE_USER%"
64default["SERVICE_TOKEN"] ="%SERVICE_TOKEN%"
65default["DEMO_USER"] ="%DEMO_USER%"
66default["DEMO_PASSWORD"] ="%DEMO_PASSWORD%"
67default["OS_TENANT_NAME"] ="%OS_TENANT_NAME%"
68default["OS_USERNAME"] ="%OS_USERNAME%"
69default["OS_PASSWORD"] ="%OS_PASSWORD%"
70default["DB_USER"] ="%DB_USER%"
71default["DB_PASSWORD"] ="%DB_PASSWORD%"
72default["PUBLIC_IP"] ="#{node[:CONTROLLER_IP]}"
73default["HOST_NAME"]="#{node[:CONTROLLER_HOSTS]}"
74default["PUBLIC_DOMAIN"] ="#{node[:CONTROLLER_IP]}/24"
75
76
diff --git a/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb b/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb
new file mode 100644
index 0000000..3c83b23
--- /dev/null
+++ b/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb
@@ -0,0 +1,264 @@
1# default.rb
2#
3# Copyright (c) 2014 Wind River Systems, Inc.
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to deal
7# in the Software without restriction, including without limitation the rights
8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9# copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in
13# all copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21# THE SOFTWARE.
22#
23# This is our main recipe that chef-solo bakes to configure our openstack deployment
24domain = node['hostname']
25domain += " " + node['platform']
26domain += " " + node['platform_version']
27domain += " " + node['ipaddress']
28log domain do
29 level:info
30end
31
32#This function enables us to over-ride the hostname and ipaddress
33#attributes based on the type of node installation
34#we are running on.
35def update_node_info()
36 if File.executable?(node[:CONTROLLER_DAEMON]) and \
37 File.executable?(node[:COMPUTE_DAEMON])
38 #All in one installation
39 if node[:ipaddress].length
40 node.default["CONTROLLER_IP"]=node.default["COMPUTE_IP"]=node[:ipaddress]
41 end
42 if node[:hostname].length
43 node.default["CONTROLLER_HOST"]=node.default["COMPUTE_HOST"]=node[:hostname]
44 end
45 node.default["NODE_TYPE"] ="allinone"
46 elsif File.executable?(node[:CONTROLLER_DAEMON])
47 if node[:ipaddress].length
48 node.default["CONTROLLER_IP"]=node[:ipaddress]
49 end
50 if node[:hostname].length
51 node.default["CONTROLLER_HOST"]=node[:hostname]
52 end
53 node.default["NODE_TYPE"] ="controller"
54 else
55 if node[:ipaddress].length
56 node.default["COMPUTE_IP"]=node[:ipaddress]
57 end
58 if node[:hostname].length
59 node.default["COMPUTE_HOST"]=node[:hostname]
60 end
61 node.default["NODE_TYPE"] ="compute"
62 end
63
64 node.default["PUBLIC_IP"]="#{node[:CONTROLLER_IP]}"
65 node.default["HOST_NAME"]="#{node[:CONTROLLER_HOST]}"
66 node.default["PUBLIC_DOMAIN"]="#{node[:CONTROLLER_IP]}/24"
67end
68#This fucntion loops through all the files in the templates
69#directory and create configuration or scripts files from the
70#templates using the sets of defined attributes
71def create_files_from_templates()
72 #Make it easier to move from development environment to target
73 output_dir = node[:POSTINSTS_DIR]
74 template_dir = node[:TEMPLATE_DIR]
75 #See if output directory exist if not create one
76 if not File.directory?(output_dir)
77 execute "Create #{output_dir} directory" do
78 command "mkdir -p #{output_dir}"
79 end
80 end
81 #Get the list of all template files
82 files = Dir.glob(template_dir)
83 #To ensure that the files are executed in increasing order
84 files = files.sort
85 for file in files do
86 #Exclude references to current and parent directory in search
87 next if File.directory?(file) or file == '.' or file == '..'
88 script_file = output_dir + File.basename(file)
89 script_file.gsub!(".erb","")
90 if File.file?(script_file)
91 execute "Delete file #{script_file} if present" do
92 command "rm -rf #{script_file}"
93 end
94 end
95 template script_file do
96 source File.basename(file)
97 mode 0755
98 owner node[:user]
99 group node[:user]
100 end
101 end
102end
103#This function moves the generated configuration files for
104#the respective modules to the specified module configuration directory
105#Overwriting the current configuration file in the process
106def replace_config_files(files, configDir, makeNoneExec=true)
107 #!files.strip
108 #!configDir.strip
109 if files and configDir
110 if not File.directory?(configDir)
111 execute "Create #{configDir}" do
112 command "mkdir -p #{configDir}"
113 end
114 end
115 if files.strip.include?(" ")
116 file_names = files.split
117 file_names.each do | fileName |
118 fileName=fileName.strip
119 if File.file?("#{node[:POSTINSTS_DIR]}#{fileName}")
120 execute "Move #{fileName} to #{configDir} " do
121 command "mv #{node[:POSTINSTS_DIR]}#{fileName} #{configDir}#{fileName}"
122 end
123 if makeNoneExec
124 execute "Remove execution mode on #{fileName}" do
125 command "chmod 0644 #{configDir}#{fileName}"
126 end
127 end
128 end
129 end
130 else
131 #There is only one file in the list
132 files=files.strip
133 if File.file?("#{node[:POSTINSTS_DIR]}#{files}")
134 execute "Move #{files} to #{configDir} " do
135 command "mv #{node[:POSTINSTS_DIR]}#{files} #{configDir}#{files}"
136 end
137 if makeNoneExec
138 execute "Remove execution mode on #{files}" do
139 command "chmod 0644 #{configDir}#{files}"
140 end
141 end
142 end
143 end
144 end
145end
146
147#Update hostname and ipaddress to be written to configuration files
148update_node_info
149
150#Generate scripts and cofiguration files
151create_files_from_templates
152
153#Move the configuration files to /etc/nova directory
154#and make remove execution modifier from the files
155novaConfigFiles="nova.conf openrc api-paste.ini deploy.conf"
156replace_config_files(novaConfigFiles,"#{node[:NOVA_CONF_DIR]}")
157#Move the configuration files to /etc/swift directory
158#and remove execution modifier from the files
159swiftConfigFiles="test.conf dispersion.conf proxy-server.conf"
160if node[:NODE_TYPE] == "compute"
161 files = swiftConfigFiles.split
162 files.each do | fileName |
163 fileName=fileName.strip
164 fileName ="#{node[:POSTINSTS_DIR]}#{fileName}"
165 if File.file?(fileName)
166 execute "Remove file #{fileName}" do
167 command "rm #{node[:POSTINSTS_DIR]}#{fileName}"
168 end
169 end
170 end
171else
172 replace_config_files(swiftConfigFiles,"#{node[:SWIFT_CONF_DIR]}")
173end
174#Move the configuration files to /etc/neutron directory
175#and remove execution modifier from the files
176configFiles="neutron.conf"
177replace_config_files(configFiles,"#{node[:NEUTRON_CONF_DIR]}")
178configFiles="linuxbridge_conf.ini"
179replace_config_files(configFiles,"#{node[:LINUXBRIDGE_CONF_DIR]}")
180configFiles="ovs_neutron_plugin.ini"
181replace_config_files(configFiles,"#{node[:OPENVSWITCH_CONF_DIR]}")
182
183configFiles="ceilometer.conf"
184replace_config_files(configFiles,"#{node[:CEILOMETER_CONF_DIR]}")
185
186configFiles="glance-api.conf glance-cache.conf glance-registry.conf"
187if node[:NODE_TYPE] == "compute"
188 files = configFiles.split
189 files.each do | fileName |
190 if File.file?("#{node[:POSTINSTS_DIR]}#{fileName}")
191 execute "Remove file #{fileName}" do
192 command "rm #{node[:POSTINSTS_DIR]}#{fileName}"
193 end
194 end
195 end
196else
197 replace_config_files(configFiles,"#{node[:GLANCE_CONF_DIR]}")
198end
199
200#Move the postgresql init script and make them executable
201configFiles="postgresql-init"
202replace_config_files(configFiles, "#{node[:INITD_DIR]}", false)
203
204configFiles="ceph.conf"
205replace_config_files(configFiles, "#{node[:CEPH_CONF_DIR]}")
206
207configFiles="ceph-setup"
208if node[:NODE_TYPE] == "compute"
209 if File.file?("#{node[:POSTINSTS_DIR]}#{configFiles}")
210 execute "Remove file #{configFiles}" do
211 command "rm #{node[:POSTINSTS_DIR]}#{configFiles}"
212 end
213 end
214else
215 replace_config_files(configFiles, "#{node[:INITD_DIR]}", false)
216end
217
218configFiles="keystone.conf identity.sh"
219if node[:NODE_TYPE] == "compute"
220 files = configFiles.split
221 files.each do | fileName |
222 if File.file?("#{node[:POSTINSTS_DIR]}#{fileName}")
223 execute "Remove file #{fileName}" do
224 command "rm #{node[:POSTINSTS_DIR]}#{fileName}"
225 end
226 end
227 end
228else
229 replace_config_files(configFiles, "#{node[:KEYSTONE_CONF_DIR]}")
230 #Openrc in keystone conf dir is same as that found in nova
231 execute "Copy openrc to #{node[:KEYSTONE_CONF_DIR]}" do
232 command "cp #{node[:NOVA_CONF_DIR]}openrc #{node[:KEYSTONE_CONF_DIR]}"
233 end
234end
235#cinder configurations
236configFiles="api-paste.ini.cinder cinder.conf"
237replace_config_files(configFiles, "#{node[:CINDER_CONF_DIR]}")
238
239fileName="#{node[:CINDER_CONF_DIR]}api-paste.ini.cinder"
240if File.file?(fileName)
241 execute "Rename api-paste.ini.cinder to api-paste.ini" do
242 command "mv #{node[:CINDER_CONF_DIR]}api-paste.ini.cinder #{node[:CINDER_CONF_DIR]}api-paste.ini"
243 end
244end
245#heat configuration
246configFiles="heat.conf"
247if node[:NODE_TYPE] == "compute"
248 if File.file?("#{node[:POSTINSTS_DIR]}#{configFiles}")
249 execute "Remove file #{configFiles}" do
250 command "rm #{node[:POSTINSTS_DIR]}#{configFiles}"
251 end
252 end
253else
254 replace_config_files(configFiles, "#{node[:HEAT_CONF_DIR]}")
255end
256#Move the hosts file in place
257configFiles="hosts"
258replace_config_files(configFiles,"#{node[:ETC_DIR]}")
259
260=begin
261service host[:hostname] do
262 action :restart
263endf
264=end
diff --git a/meta-openstack/recipes-support/deploychef/files/config.rb b/meta-openstack/recipes-support/deploychef/files/config.rb
new file mode 100644
index 0000000..bce20f8
--- /dev/null
+++ b/meta-openstack/recipes-support/deploychef/files/config.rb
@@ -0,0 +1,29 @@
1# config.rb
2## Copyright (c) 2014 Wind River Systems, Inc.
3##
4## Permission is hereby granted, free of charge, to any person obtaining a copy
5## of this software and associated documentation files (the "Software"), to deal
6## in the Software without restriction, including without limitation the rights
7## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8## copies of the Software, and to permit persons to whom the Software is
9## furnished to do so, subject to the following conditions:
10##
11## The above copyright notice and this permission notice shall be included in
12## all copies or substantial portions of the Software.
13#
14## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20## THE SOFTWARE.
21##
22#
23# This configuration file points chef-solo to the location
24# our our cookbooks and recipes within those cookbooks
25log_level :info
26ssl_verify_mode :verify_peer
27base_dir Dir.pwd + "/"
28file_cache_path base_dir + "cache/"
29cookbook_path base_dir + "cookbooks/"