diff options
author | Mustapha Lansana <Mustapha.Lansana@windriver.com> | 2014-05-27 22:02:55 -0400 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-09-26 09:09:21 -0400 |
commit | 98e1afbc185a7f87427860f4273a7285e5b6407e (patch) | |
tree | 13558f56af0e27bcebd9202ed68e3c89efb317fa | |
parent | ea4560f65862a7c94d15cfe6006f8059ab62ea74 (diff) | |
download | meta-cloud-services-98e1afbc185a7f87427860f4273a7285e5b6407e.tar.gz |
deploychef: makes chef-solo templates from openstack conf files
The current openstack build bakes a number of variables into openstack
services' configuration files at build-time. This makes it impossible
to deploy an openstack image built for one run-time environment into a
different run-time environment.
The deploychef package uses chef-solo to enable the re-use of an
openstack image in different run-time environments.
The attached patch set is deploychef package recipe and init script
files. The script deploychef.init gives us the ability to make a copy of
the postinstall script before they are tainted. This enables us to create
chef-solo templates out of the untainted postinstall scripts.
The template files are then used to recreate the postinstall script
whenever the stack needs to be reconfigured at run-time.
Signed-off-by: Mustapha Lansana <Mustapha.Lansana@windriver.com>
3 files changed, 160 insertions, 0 deletions
diff --git a/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb b/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb new file mode 100644 index 0000000..7bd7510 --- /dev/null +++ b/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb | |||
@@ -0,0 +1,133 @@ | |||
1 | # | ||
2 | # Copyright (C) 2014 Wind River Systems, Inc. | ||
3 | # | ||
4 | SUMMARY = "For the provisioning of OpenStack nodes" | ||
5 | DESCRIPTION = "There are a number of variables that are backed into Openstack \ | ||
6 | at build time, for example the ip address of compute or controller node. \ | ||
7 | This means that when a new compute or controller node boots up, it will \ | ||
8 | have an ip address that differs from its currently assigned ip address \ | ||
9 | This package facilitates the recreation or script and configuration files and their \ | ||
10 | placement in the appropriate places on the files system on a compute/controller or \ | ||
11 | all in one node at runtime" | ||
12 | |||
13 | LICENSE = "MIT" | ||
14 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ | ||
15 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
16 | |||
17 | PR = "r0" | ||
18 | |||
19 | require deploychef.inc | ||
20 | |||
21 | RDEPENDS_${PN} = "chef" | ||
22 | SRC_URI = "\ | ||
23 | file://deploychef.init \ | ||
24 | file://attributes.json \ | ||
25 | file://config.rb \ | ||
26 | file://run-postinsts \ | ||
27 | file://run-deploychef \ | ||
28 | file://service-shutdown \ | ||
29 | file://startup-list \ | ||
30 | file://shutdown-list \ | ||
31 | file://chefsolo_default_attribute.rb \ | ||
32 | file://chefsolo_default_recipe.rb \ | ||
33 | file://conf-templates/* \ | ||
34 | " | ||
35 | inherit update-rc.d identity hosts default_configs | ||
36 | |||
37 | S = "${WORKDIR}" | ||
38 | #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} | ||
40 | DEPLOYCHEF_ROOT_DIR ?= "/opt/${BPN}" | ||
41 | #Provide a mechanism for these strings to be over-written if necessary | ||
42 | COOKBOOK_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/" | ||
43 | ATTRIBUTE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/" | ||
44 | RECIPE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/" | ||
45 | TEMPLATES_CONF_DIR = "${DEPLOYCHEF_ROOT_DIR}/conf-templates/" | ||
46 | |||
47 | FILES_${PN} += " \ | ||
48 | ${DEPLOYCHEF_ROOT_DIR}/* \ | ||
49 | ${DEPLOYCHEF_ROOT_DIR}/conf-templates/* \ | ||
50 | ${DEPLOYCHEF_ROOT_DIR}/cookbooks/* \ | ||
51 | ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/* \ | ||
52 | ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/* \ | ||
53 | ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/default/* \ | ||
54 | ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/default/excluded/* \ | ||
55 | ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/* \ | ||
56 | " | ||
57 | #Read the module config files and make them into | ||
58 | #chef-solo templates | ||
59 | do_install() { | ||
60 | if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then | ||
61 | #This script will make templates out of postinst script before they | ||
62 | #have a chance to run | ||
63 | install -d ${D}${sysconfdir}/init.d | ||
64 | install -m 0755 ${S}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN} | ||
65 | |||
66 | install -d ${D}/${DEPLOYCHEF_ROOT_DIR} | ||
67 | #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 | ||
71 | 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 | ||
73 | install -m 0644 ${S}/shutdown-list ${D}/${DEPLOYCHEF_ROOT_DIR}/shutdown-list | ||
74 | 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 | ||
76 | install -m 0644 ${S}/startup-list ${D}/${DEPLOYCHEF_ROOT_DIR}/startup-list | ||
77 | #Copy the respective services configuration script files and convert them to | ||
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} | ||
83 | install -m 0644 ${S}/chefsolo_default_recipe.rb ${D}/${RECIPE_DIR}/default.rb | ||
84 | fi | ||
85 | } | ||
86 | |||
87 | do_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 | |||
99 | #Populate chefsolo attribute file and | ||
100 | #Populate deploychef.inc file used in the generation of chefsolo templates | ||
101 | for file in ${D}/${ATTRIBUTE_DIR}default.rb ${D}/${TEMPLATES_CONF_DIR}/constants.inc; do | ||
102 | sed -i s:%CONTROLLER_IP%:${CONTROLLER_IP}:g $file | ||
103 | sed -i s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g $file | ||
104 | sed -i s:%COMPUTE_IP%:${COMPUTE_IP}:g $file | ||
105 | sed -i s:%COMPUTE_HOST%:${COMPUTE_HOST}:g $file | ||
106 | sed -i s:%ADMIN_PASSWORD%:${ADMIN_PASSWORD}:g $file | ||
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 | |||
122 | #Replace the rpm-postinsts dir | ||
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 | ||
127 | done | ||
128 | } | ||
129 | |||
130 | INITSCRIPT_PACKAGES = "${BPN}" | ||
131 | INITSCRIPT_NAME_${BPN} = "${BPN}" | ||
132 | INITSCRIPT_PARAMS = "start 96 S ." | ||
133 | |||
diff --git a/meta-openstack/recipes-support/deploychef/files/deploychef.inc b/meta-openstack/recipes-support/deploychef/files/deploychef.inc new file mode 100644 index 0000000..65ea2ca --- /dev/null +++ b/meta-openstack/recipes-support/deploychef/files/deploychef.inc | |||
@@ -0,0 +1,16 @@ | |||
1 | #These variables are not defined in the services | ||
2 | #We define them here with the option for them to | ||
3 | #be overwritten in the future | ||
4 | #Nova package name, see nova recipe | ||
5 | SERVICE_USER ?= "nova" | ||
6 | #Swift test.conf | ||
7 | ADMIN_USER ?= "admin" | ||
8 | #Neutron neutron.conf | ||
9 | DEMO_USER ?= "demo" | ||
10 | DEMO_PASSWORD ?= "password" | ||
11 | #Use in ceilometer, openrc (nova& keystone) | ||
12 | OS_USERNAME ?= "admin" | ||
13 | OS_TENANT_NAME ?= "admin" | ||
14 | OS_PASSWORD ?= "password" | ||
15 | POSTINSTS_DIR ?= "rpm-postinsts" | ||
16 | |||
diff --git a/meta-openstack/recipes-support/deploychef/files/deploychef.init b/meta-openstack/recipes-support/deploychef/files/deploychef.init new file mode 100644 index 0000000..b456e35 --- /dev/null +++ b/meta-openstack/recipes-support/deploychef/files/deploychef.init | |||
@@ -0,0 +1,11 @@ | |||
1 | #!/bin/bash | ||
2 | #After this script runs, chefsolo postinsts templates | ||
3 | #script will all be in chefsolo default templates directory | ||
4 | i=%DEPLOYCHEF_ROOT_DIR%/generate-templates | ||
5 | if [ -f $i ] && $i; then | ||
6 | echo "Chefsolo templates made successfully" | ||
7 | rm -f /etc/rcS.d/S96deploychef | ||
8 | rm -f $i | ||
9 | else | ||
10 | echo "ERROR: $i failed." | ||
11 | fi | ||