summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/deploychef/deploychef_0.1.bb
blob: 623753811a1438fcc60ae5f0508580ba2e64763c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#
# Copyright (C) 2014 Wind River Systems, Inc.
#
SUMMARY = "For the provisioning of OpenStack nodes"
DESCRIPTION = "There are a number of variables that are baked into Openstack \
at build time, for example the ip address of a compute or controller node. \
This means that when a new compute or controller node boots up, it will \
have an ip address that differs from its currently assigned ip address \
This package facilitates the recreation of openstack script and \ 
configuration files, as well as their placement in the appropriate directories on \
the files system on a compute/controller/allinone node at runtime"

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

PR = "r1"


RDEPENDS_${PN} = "chef"
SRC_URI = "\
    file://deploychef.init  \
    file://attributes.json  \
    file://config.rb \
    file://default_recipe.rb \
    file://run-openstackchef \
    file://run-postinsts \
    file://run-deploychef \
    file://service-shutdown \
    file://deploychef-inc \
    "
inherit update-rc.d identity hosts default_configs

S = "${WORKDIR}"
#Since this package does not need to be ran for each boot-up
#There is no need for an init scrpt so install it in /opt/${BPN}
DEPLOYCHEF_ROOT_DIR ?= "/opt/${BPN}"
POSTINSTS_DIR ?= "rpm-postinsts"

#Provide a mechanism for these strings to be over-written if necessary
COOKBOOK_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/"
ATTRIBUTE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/"
RECIPE_DIR = "${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/"

FILES_${PN} += " \
    ${DEPLOYCHEF_ROOT_DIR}/* \
    ${DEPLOYCHEF_ROOT_DIR}/conf-templates/* \
    ${DEPLOYCHEF_ROOT_DIR}/cookbooks/* \
    ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/recipes/* \
    ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/* \
    ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/templates/default \
    ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes \
    ${DEPLOYCHEF_ROOT_DIR}/cookbooks/openstack/attributes/* \
    "
#Read the module config files and make them into
#chef-solo templates
do_install() {
    if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
        #This script will make templates out of postinst script before they
        #have a chance to run
        install -d ${D}${sysconfdir}/init.d
        install -m 0755 ${S}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN}

        install -d ${D}/${DEPLOYCHEF_ROOT_DIR}
        #Copy the template configuration scripts to image directory
        install -m 0644 ${S}/config.rb ${D}/${DEPLOYCHEF_ROOT_DIR}/config.rb
        install -m 0644 ${S}/attributes.json ${D}/${DEPLOYCHEF_ROOT_DIR}/attributes.json
        install -m 0755 ${S}/run-postinsts ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts
        install -m 0755 ${S}/run-openstackchef ${D}/${DEPLOYCHEF_ROOT_DIR}/run-openstackchef
        install -m 0755 ${S}/run-deploychef  ${D}/${DEPLOYCHEF_ROOT_DIR}/run-deploychef
        install -m 0755 ${S}/service-shutdown  ${D}/${DEPLOYCHEF_ROOT_DIR}/service-shutdown
        install -m 0644 ${S}/deploychef-inc  ${D}/${DEPLOYCHEF_ROOT_DIR}/deploychef-inc
        #Copy the chefsolo recipe file to chefsolo recipe folder
        install -d ${D}/${RECIPE_DIR}
        install -m 0644 ${S}/default_recipe.rb  ${D}/${RECIPE_DIR}/default.rb
    fi
}

do_install_append() {

    #Replace all required placeholders
    for file in "${D}/${DEPLOYCHEF_ROOT_DIR}/run-deploychef \ 
        ${D}/${DEPLOYCHEF_ROOT_DIR}/service-shutdown \
        ${D}/${DEPLOYCHEF_ROOT_DIR}/deploychef-inc \
        ${D}/${DEPLOYCHEF_ROOT_DIR}/run-postinsts \
        ${D}/${DEPLOYCHEF_ROOT_DIR}/run-openstackchef \
        ${D}/${RECIPE_DIR}/default.rb \
        ${D}/${sysconfdir}/init.d/${BPN} "; do

        sed -i s:%SYSCONFDIR%:${sysconfdir}:g $file
        sed -i s:%POSTINSTS_DIR%:${POSTINSTS_DIR}:g $file
        sed -i s:%PACKAGE_NAME%:${BPN}:g $file
        sed -i s:%DEPLOYCHEF_ROOT_DIR%:${DEPLOYCHEF_ROOT_DIR}:g $file
    done
}

INITSCRIPT_PACKAGES = "${BPN}"
INITSCRIPT_NAME_${BPN} = "${BPN}"
INITSCRIPT_PARAMS = "start 96 S ."