summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb
diff options
context:
space:
mode:
authorMustapha Lansana <Mustapha.Lansana@windriver.com>2014-07-30 19:32:37 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-09-26 09:09:21 -0400
commit261f7f857503d7dcd7dcdc4c36aeff1b57194f9b (patch)
tree62bfe5adcc46479e1d864cfa79635060a0e7cdb4 /meta-openstack/recipes-support/deploychef/deploychef_0.1.bb
parent48bd378fda4db37b519742bdcf98b6a48f83b594 (diff)
downloadmeta-cloud-services-261f7f857503d7dcd7dcdc4c36aeff1b57194f9b.tar.gz
deploychef: adaptation of deploychef to support openstackchef
The deploychef package has been adapted to implement the run-time functionality required by decentralized openstackchef class. It does this by executing a script (deploychef) which instruct chef-solo to recreate configuration files from all template files placed at /opt/deploychef/cookbooks/openstack/templates/default by openstackchef class at build-time. The deploychef init script run-level is lower than run-postinsts script, which runs all openstack post-install scripts at first boot. The deploychef script makes a call to run-chefsolo script, which then creates openstack configuration files from all template files mentioned above as directed by a recipe file. This enables us to reconfigure an openstack image on first-boot, thereby, updating the image with environment variables like IP address. Like the template files above, there is a list of all default variables used by the services in an openstack installation. These variables, like the templates files above are created by the openstackchef class and saved to a file under deploychef directory at: /opt/deploychef/cookbooks/openstack/attributes/default.rb Whenever it's desired to reconfigure an openstack deployment with an updated value of any of the variables in the attributes file above, the script file run-deploychef should be executed to reconfigure the stack as shown below. cd /opt/deploychef ./run-deploychef Signed-off-by: Mustapha Lansana <Mustapha.Lansana@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-support/deploychef/deploychef_0.1.bb')
-rw-r--r--meta-openstack/recipes-support/deploychef/deploychef_0.1.bb83
1 files changed, 25 insertions, 58 deletions
diff --git a/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb b/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb
index 7bd7510..3471a2c 100644
--- a/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb
+++ b/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb
@@ -14,23 +14,20 @@ LICENSE = "MIT"
14LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ 14LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
15 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 15 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
16 16
17PR = "r0" 17PR = "r1"
18 18
19require deploychef.inc
20 19
21RDEPENDS_${PN} = "chef" 20RDEPENDS_${PN} = "chef"
22SRC_URI = "\ 21SRC_URI = "\
23 file://deploychef.init \ 22 file://deploychef.init \
24 file://attributes.json \ 23 file://attributes.json \
25 file://config.rb \ 24 file://config.rb \
25 file://default_recipe.rb \
26 file://run-openstackchef \
26 file://run-postinsts \ 27 file://run-postinsts \
27 file://run-deploychef \ 28 file://run-deploychef \
28 file://service-shutdown \ 29 file://service-shutdown \
29 file://startup-list \ 30 file://deploychef-inc \
30 file://shutdown-list \
31 file://chefsolo_default_attribute.rb \
32 file://chefsolo_default_recipe.rb \
33 file://conf-templates/* \
34 " 31 "
35inherit update-rc.d identity hosts default_configs 32inherit update-rc.d identity hosts default_configs
36 33
@@ -38,11 +35,12 @@ S = "${WORKDIR}"
38#Since this package does not need to be ran for each boot-up 35#Since this package does not need to be ran for each boot-up
39#There is no need for an init scrpt so install it in /opt/${BPN} 36#There is no need for an init scrpt so install it in /opt/${BPN}
40DEPLOYCHEF_ROOT_DIR ?= "/opt/${BPN}" 37DEPLOYCHEF_ROOT_DIR ?= "/opt/${BPN}"
38POSTINSTS_DIR ?= "rpm-postinsts"
39
41#Provide a mechanism for these strings to be over-written if necessary 40#Provide a mechanism for these strings to be over-written if necessary
42COOKBOOK_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/" 41COOKBOOK_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/"
43ATTRIBUTE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/" 42ATTRIBUTE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/"
44RECIPE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/" 43RECIPE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/"
45TEMPLATES_CONF_DIR = "${DEPLOYCHEF_ROOT_DIR}/conf-templates/"
46 44
47FILES_${PN} += " \ 45FILES_${PN} += " \
48 ${DEPLOYCHEF_ROOT_DIR}/* \ 46 ${DEPLOYCHEF_ROOT_DIR}/* \
@@ -50,8 +48,8 @@ FILES_${PN} += " \
50 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/* \ 48 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/* \
51 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/* \ 49 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/* \
52 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/* \ 50 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/* \
53 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/default/* \ 51 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/default \
54 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/default/excluded/* \ 52 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes \
55 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/* \ 53 ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/* \
56 " 54 "
57#Read the module config files and make them into 55#Read the module config files and make them into
@@ -65,65 +63,34 @@ do_install() {
65 63
66 install -d ${D}/${DEPLOYCHEF_ROOT_DIR} 64 install -d ${D}/${DEPLOYCHEF_ROOT_DIR}
67 #Copy the template configuration scripts to image directory 65 #Copy the template configuration scripts to image directory
68 cp -r ${S}/conf-templates ${D}/${DEPLOYCHEF_ROOT_DIR}
69 install -m 0755 ${S}/generate-templates ${D}/${DEPLOYCHEF_ROOT_DIR}
70 install -m 0644 ${S}/config.rb ${D}/${DEPLOYCHEF_ROOT_DIR}/config.rb 66 install -m 0644 ${S}/config.rb ${D}/${DEPLOYCHEF_ROOT_DIR}/config.rb
71 install -m 0644 ${S}/attributes.json ${D}/${DEPLOYCHEF_ROOT_DIR}/attributes.json 67 install -m 0644 ${S}/attributes.json ${D}/${DEPLOYCHEF_ROOT_DIR}/attributes.json
72 install -m 0644 ${S}/run-postinsts ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts 68 install -m 0755 ${S}/run-postinsts ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts
73 install -m 0644 ${S}/shutdown-list ${D}/${DEPLOYCHEF_ROOT_DIR}/shutdown-list 69 install -m 0755 ${S}/run-openstackchef ${D}/${DEPLOYCHEF_ROOT_DIR}/run-openstackchef
74 install -m 0755 ${S}/run-deploychef ${D}/${DEPLOYCHEF_ROOT_DIR}/run-deploychef 70 install -m 0755 ${S}/run-deploychef ${D}/${DEPLOYCHEF_ROOT_DIR}/run-deploychef
75 install -m 0644 ${S}/service-shutdown ${D}/${DEPLOYCHEF_ROOT_DIR}/service-shutdown 71 install -m 0755 ${S}/service-shutdown ${D}/${DEPLOYCHEF_ROOT_DIR}/service-shutdown
76 install -m 0644 ${S}/startup-list ${D}/${DEPLOYCHEF_ROOT_DIR}/startup-list 72 install -m 0644 ${S}/deploychef-inc ${D}/${DEPLOYCHEF_ROOT_DIR}/deploychef-inc
77 #Copy the respective services configuration script files and convert them to 73 #Copy the chefsolo recipe file to chefsolo recipe folder
78 #chefsolo recipes
79 install -d ${D}/${ATTRIBUTE_DIR}
80 install -m 0644 ${S}/chefsolo_default_attribute.rb ${D}/${ATTRIBUTE_DIR}/default.rb
81
82 install -d ${D}/${RECIPE_DIR} 74 install -d ${D}/${RECIPE_DIR}
83 install -m 0644 ${S}/chefsolo_default_recipe.rb ${D}/${RECIPE_DIR}/default.rb 75 install -m 0644 ${S}/default_recipe.rb ${D}/${RECIPE_DIR}/default.rb
84 fi 76 fi
85} 77}
86 78
87do_install_append() { 79do_install_append() {
88 sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g ${D}/${sysconfdir}/init.d/${BPN}
89 #Replace all the place holders in the respective files
90 sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g ${D}/${ATTRIBUTE_DIR}default.rb
91 sed -i s:%SYSCONFDIR%:${sysconfdir}:g ${D}/${ATTRIBUTE_DIR}default.rb
92 sed -i s:%SYSCONFDIR%:${sysconfdir}:g ${D}/${DEPLOYCHEF_ROOT_DIR}/generate-templates
93 sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g ${D}/${DEPLOYCHEF_ROOT_DIR}/generate-templates
94 #chef-solo requires location of script files to be absolute, provide absolute path
95 sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g ${D}/${DEPLOYCHEF_ROOT_DIR}/service-shutdown
96 sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts
97 sed -i s:%PACKAGE_NAME%:${BPN}:g ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts
98 80
99 #Populate chefsolo attribute file and 81 #Replace all required placeholders
100 #Populate deploychef.inc file used in the generation of chefsolo templates 82 for file in "${D}/${DEPLOYCHEF_ROOT_DIR}/run-deploychef \
101 for file in ${D}/${ATTRIBUTE_DIR}default.rb ${D}/${TEMPLATES_CONF_DIR}/constants.inc; do 83 ${D}/${DEPLOYCHEF_ROOT_DIR}/service-shutdown \
102 sed -i s:%CONTROLLER_IP%:${CONTROLLER_IP}:g $file 84 ${D}/${DEPLOYCHEF_ROOT_DIR}/deploychef-inc \
103 sed -i s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g $file 85 ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts \
104 sed -i s:%COMPUTE_IP%:${COMPUTE_IP}:g $file 86 ${D}/${DEPLOYCHEF_ROOT_DIR}/run-openstackchef \
105 sed -i s:%COMPUTE_HOST%:${COMPUTE_HOST}:g $file 87 ${D}/${RECIPE_DIR}/default.rb \
106 sed -i s:%ADMIN_PASSWORD%:${ADMIN_PASSWORD}:g $file 88 ${D}/${sysconfdir}/init.d/${BPN} "; do
107 sed -i s:%ADMIN_USER%:${ADMIN_USER}:g $file
108 sed -i s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g $file
109 sed -i s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g $file
110 sed -i s:%SERVICE_USER%:${SERVICE_USER}:g $file
111 sed -i s:%SERVICE_TOKEN%:${SERVICE_TOKEN}:g $file
112 sed -i s:%DEMO_USER%:${DEMO_USER}:g $file
113 sed -i s:%DEMO_PASSWORD%:${DEMO_PASSWORD}:g $file
114 sed -i s:%OS_TENANT_NAME%:${OS_TENANT_NAME}:g $file
115 sed -i s:%OS_USERNAME%:${OS_USERNAME}:g $file
116 sed -i s:%OS_PASSWORD%:${OS_PASSWORD}:g $file
117 sed -i s:%DB_NAME%:${DB_NAME}:g $file
118 sed -i s:%DB_USER%:${DB_USER}:g $file
119 sed -i s:%DB_PASSWORD%:${DB_PASSWORD}:g $file
120 done
121 89
122 #Replace the rpm-postinsts dir 90 sed -i s:%SYSCONFDIR%:${sysconfdir}:g $file
123 for file in "${D}/${ATTRIBUTE_DIR}default.rb \
124 ${D}/${DEPLOYCHEF_ROOT_DIR}/run-deploychef \
125 ${D}/${DEPLOYCHEF_ROOT_DIR}/generate-templates"; do
126 sed -i s:%POSTINSTS_DIR%:${POSTINSTS_DIR}:g $file 91 sed -i s:%POSTINSTS_DIR%:${POSTINSTS_DIR}:g $file
92 sed -i s:%PACKAGE_NAME%:${BPN}:g $file
93 sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g $file
127 done 94 done
128} 95}
129 96