summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb')
-rw-r--r--meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb264
1 files changed, 0 insertions, 264 deletions
diff --git a/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb b/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb
deleted file mode 100644
index 3c83b23..0000000
--- a/meta-openstack/recipes-support/deploychef/files/chefsolo_default_recipe.rb
+++ /dev/null
@@ -1,264 +0,0 @@
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