Generalization of recursive function
[apex.git] / build / kvm4nfv-1st-boot.yaml
1 ---
2 heat_template_version: 2014-10-16
3
4 description: >
5   This is the firstboot configuration for kvmfornfv kernel of the compute nodes
6   via cloud-init. To enable this, replace the default
7   mapping of OS::TripleO::NodeUserData in ../overcloud_resource_registry*
8
9 parameters:
10   ComputeKernelArgs:
11     description: >
12       Name of the kvmfornfv kernel rpm.
13       Example: "kvmfornfv_kernel.rpm"
14     type: string
15     default: ""
16   ComputeHostnameFormat:
17     type: string
18     default: ""
19
20 resources:
21   userdata:
22     type: OS::Heat::MultipartMime
23     properties:
24       parts:
25         - config: {get_resource: compute_kernel_args}
26
27   # Verify the logs on /var/log/cloud-init.log on the overcloud node
28   compute_kernel_args:
29     type: OS::Heat::SoftwareConfig
30     properties:
31       config:
32         str_replace:
33           template: |
34             #!/bin/bash
35             set -x
36             FORMAT=$COMPUTE_HOSTNAME_FORMAT
37             if [[ -z $FORMAT ]] ; then
38               FORMAT="compute" ;
39             else
40               # Assumption: only %index% and %stackname% are
41               # the variables in Host name format
42               FORMAT=$(echo $FORMAT | sed  's/\%index\%//g');
43               FORMAT=$(echo $FORMAT | sed 's/\%stackname\%//g');
44             fi
45             if [[ $(hostname) == *$FORMAT* ]] ; then
46               yum install -y /root/$KVMFORNFV_KERNEL_RPM
47               grub2-mkconfig -o /etc/grub2.cfg
48               sleep 5
49               reboot
50             fi
51           params:
52             $KVMFORNFV_KERNEL_RPM: {get_param: ComputeKernelArgs}
53             $COMPUTE_HOSTNAME_FORMAT: {get_param: ComputeHostnameFormat}
54
55 outputs:
56   # This means get_resource from the parent template will get the userdata, see:
57   # http://docs.openstack.org/developer/heat/template_guide/composition.html#making-your-template-resource-more-transparent
58   # Note this is new-for-kilo, an alternative is returning a value then using
59   # get_attr in the parent template instead.
60   OS::stack_id:
61     value: {get_resource: userdata}