diff options
author | Mustapha Lansana <Mustapha.Lansana@windriver.com> | 2014-05-27 22:02:56 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-09-26 09:09:21 -0400 |
commit | eeda01a7be07c78dac7b6ae5013524d857ceba3b (patch) | |
tree | 742c4abd9d6877d2fa1ca7f16eb917ffe5434ea7 /meta-openstack/recipes-support/deploychef | |
parent | 98e1afbc185a7f87427860f4273a7285e5b6407e (diff) | |
download | meta-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/deploychef')
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 | |||
28 | default["CHEFROOT_DIR"] ="%DEPLOYCHEF_ROOT_DIR%/" | ||
29 | default["TEMPLATE_DIR"] ="#{node[:CHEFROOT_DIR]}cookbooks/openstack/templates/default/*" | ||
30 | default["ETC_DIR"]= "%SYSCONFDIR%/" | ||
31 | default["POSTINSTS_DIR"] ="#{node[:ETC_DIR]}%POSTINSTS_DIR%/" | ||
32 | default["NOVA_CONF_DIR"]="#{node[:ETC_DIR]}nova/" | ||
33 | default["SWIFT_CONF_DIR"]="#{node[:ETC_DIR]}swift/" | ||
34 | default["CEILOMETER_CONF_DIR"]="#{node[:ETC_DIR]}ceilometer/" | ||
35 | default["NEUTRON_CONF_DIR"]= "#{node[:ETC_DIR]}neutron/" | ||
36 | default["NEUTRON_CORE_PLUGIN"]= "neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2" | ||
37 | default["OPENVSWITCH_CONF_DIR"]= "#{node[:NEUTRON_CONF_DIR]}plugins/openvswitch/" | ||
38 | default["LINUXBRIDGE_CONF_DIR"]= "#{node[:NEUTRON_CONF_DIR]}plugins/linuxbridge/" | ||
39 | default["KEYSTONE_CONF_DIR"]= "#{node[:ETC_DIR]}keystone/" | ||
40 | default["CINDER_CONF_DIR"]= "#{node[:ETC_DIR]}cinder/" | ||
41 | default["GLANCE_CONF_DIR"]= "#{node[:ETC_DIR]}glance/" | ||
42 | default["CEPH_CONF_DIR"]= "#{node[:ETC_DIR]}ceph/" | ||
43 | default["DB_DATADIR"]= "#{node[:ETC_DIR]}postgresql/" | ||
44 | default["HEAT_CONF_DIR"]= "#{node[:ETC_DIR]}heat/" | ||
45 | |||
46 | default["INITD_DIR"]= "#{node[:ETC_DIR]}init.d/" | ||
47 | default["CONTROLLER_DAEMON"]= "#{node[:INITD_DIR]}nova-api" | ||
48 | default["COMPUTE_DAEMON"]= "#{node[:INITD_DIR]}nova-compute" | ||
49 | default["NODE_TYPE"]="compute" | ||
50 | default["NODE_TYPES"]="compute controller allinone" | ||
51 | default["POSTINSTS_SCRIPT"] = "run-postinsts" | ||
52 | default["PREINSTS_SCRIPT"] = "service-shutdown" | ||
53 | default["AUTH_PROTOCOL"] = "http" | ||
54 | default["PRIVATE_IP"] = "127.0.0.1" | ||
55 | |||
56 | default["CONTROLLER_IP"] = "%CONTROLLER_IP%" | ||
57 | default["CONTROLLER_HOST"] = "%CONTROLLER_HOST%" | ||
58 | default["COMPUTE_IP"] = "%COMPUTE_IP%" | ||
59 | default["COMPUTE_HOST"] = "%COMPUTE_HOST%" | ||
60 | default["ADMIN_PASSWORD"] = "%ADMIN_PASSWORD%" | ||
61 | default["SERVICE_PASSWORD"] = "%SERVICE_PASSWORD%" | ||
62 | default["SERVICE_TENANT_NAME"] ="%SERVICE_TENANT_NAME%" | ||
63 | default["SERVICE_USER"] ="%SERVICE_USER%" | ||
64 | default["SERVICE_TOKEN"] ="%SERVICE_TOKEN%" | ||
65 | default["DEMO_USER"] ="%DEMO_USER%" | ||
66 | default["DEMO_PASSWORD"] ="%DEMO_PASSWORD%" | ||
67 | default["OS_TENANT_NAME"] ="%OS_TENANT_NAME%" | ||
68 | default["OS_USERNAME"] ="%OS_USERNAME%" | ||
69 | default["OS_PASSWORD"] ="%OS_PASSWORD%" | ||
70 | default["DB_USER"] ="%DB_USER%" | ||
71 | default["DB_PASSWORD"] ="%DB_PASSWORD%" | ||
72 | default["PUBLIC_IP"] ="#{node[:CONTROLLER_IP]}" | ||
73 | default["HOST_NAME"]="#{node[:CONTROLLER_HOSTS]}" | ||
74 | default["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 | ||
24 | domain = node['hostname'] | ||
25 | domain += " " + node['platform'] | ||
26 | domain += " " + node['platform_version'] | ||
27 | domain += " " + node['ipaddress'] | ||
28 | log domain do | ||
29 | level:info | ||
30 | end | ||
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. | ||
35 | def 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" | ||
67 | end | ||
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 | ||
71 | def 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 | ||
102 | end | ||
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 | ||
106 | def 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 | ||
145 | end | ||
146 | |||
147 | #Update hostname and ipaddress to be written to configuration files | ||
148 | update_node_info | ||
149 | |||
150 | #Generate scripts and cofiguration files | ||
151 | create_files_from_templates | ||
152 | |||
153 | #Move the configuration files to /etc/nova directory | ||
154 | #and make remove execution modifier from the files | ||
155 | novaConfigFiles="nova.conf openrc api-paste.ini deploy.conf" | ||
156 | replace_config_files(novaConfigFiles,"#{node[:NOVA_CONF_DIR]}") | ||
157 | #Move the configuration files to /etc/swift directory | ||
158 | #and remove execution modifier from the files | ||
159 | swiftConfigFiles="test.conf dispersion.conf proxy-server.conf" | ||
160 | if 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 | ||
171 | else | ||
172 | replace_config_files(swiftConfigFiles,"#{node[:SWIFT_CONF_DIR]}") | ||
173 | end | ||
174 | #Move the configuration files to /etc/neutron directory | ||
175 | #and remove execution modifier from the files | ||
176 | configFiles="neutron.conf" | ||
177 | replace_config_files(configFiles,"#{node[:NEUTRON_CONF_DIR]}") | ||
178 | configFiles="linuxbridge_conf.ini" | ||
179 | replace_config_files(configFiles,"#{node[:LINUXBRIDGE_CONF_DIR]}") | ||
180 | configFiles="ovs_neutron_plugin.ini" | ||
181 | replace_config_files(configFiles,"#{node[:OPENVSWITCH_CONF_DIR]}") | ||
182 | |||
183 | configFiles="ceilometer.conf" | ||
184 | replace_config_files(configFiles,"#{node[:CEILOMETER_CONF_DIR]}") | ||
185 | |||
186 | configFiles="glance-api.conf glance-cache.conf glance-registry.conf" | ||
187 | if 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 | ||
196 | else | ||
197 | replace_config_files(configFiles,"#{node[:GLANCE_CONF_DIR]}") | ||
198 | end | ||
199 | |||
200 | #Move the postgresql init script and make them executable | ||
201 | configFiles="postgresql-init" | ||
202 | replace_config_files(configFiles, "#{node[:INITD_DIR]}", false) | ||
203 | |||
204 | configFiles="ceph.conf" | ||
205 | replace_config_files(configFiles, "#{node[:CEPH_CONF_DIR]}") | ||
206 | |||
207 | configFiles="ceph-setup" | ||
208 | if 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 | ||
214 | else | ||
215 | replace_config_files(configFiles, "#{node[:INITD_DIR]}", false) | ||
216 | end | ||
217 | |||
218 | configFiles="keystone.conf identity.sh" | ||
219 | if 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 | ||
228 | else | ||
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 | ||
234 | end | ||
235 | #cinder configurations | ||
236 | configFiles="api-paste.ini.cinder cinder.conf" | ||
237 | replace_config_files(configFiles, "#{node[:CINDER_CONF_DIR]}") | ||
238 | |||
239 | fileName="#{node[:CINDER_CONF_DIR]}api-paste.ini.cinder" | ||
240 | if 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 | ||
244 | end | ||
245 | #heat configuration | ||
246 | configFiles="heat.conf" | ||
247 | if 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 | ||
253 | else | ||
254 | replace_config_files(configFiles, "#{node[:HEAT_CONF_DIR]}") | ||
255 | end | ||
256 | #Move the hosts file in place | ||
257 | configFiles="hosts" | ||
258 | replace_config_files(configFiles,"#{node[:ETC_DIR]}") | ||
259 | |||
260 | =begin | ||
261 | service host[:hostname] do | ||
262 | action :restart | ||
263 | endf | ||
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 | ||
25 | log_level :info | ||
26 | ssl_verify_mode :verify_peer | ||
27 | base_dir Dir.pwd + "/" | ||
28 | file_cache_path base_dir + "cache/" | ||
29 | cookbook_path base_dir + "cookbooks/" | ||