summaryrefslogtreecommitdiffstats
path: root/build/kvm4nfv-1st-boot.yaml
blob: 4c1aefc0cec31aa7da8780f0715b24abb15a56c8 (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
---
heat_template_version: 2014-10-16

description: >
  This is the firstboot configuration for kvmfornfv kernel of the compute nodes
  via cloud-init. To enable this, replace the default
  mapping of OS::TripleO::NodeUserData in ../overcloud_resource_registry*

parameters:
  ComputeKernelArgs:
    description: >
      Name of the kvmfornfv kernel rpm.
      Example: "kvmfornfv_kernel.rpm"
    type: string
    default: ""
  ComputeHostnameFormat:
    type: string
    default: ""

resources:
  userdata:
    type: OS::Heat::MultipartMime
    properties:
      parts:
        - config: {get_resource: compute_kernel_args}

  # Verify the logs on /var/log/cloud-init.log on the overcloud node
  compute_kernel_args:
    type: OS::Heat::SoftwareConfig
    properties:
      config:
        str_replace:
          template: |
            #!/bin/bash
            set -x
            FORMAT=$COMPUTE_HOSTNAME_FORMAT
            if [[ -z $FORMAT ]] ; then
              FORMAT="compute" ;
            else
              # Assumption: only %index% and %stackname% are
              # the variables in Host name format
              FORMAT=$(echo $FORMAT | sed  's/\%index\%//g');
              FORMAT=$(echo $FORMAT | sed 's/\%stackname\%//g');
            fi
            if [[ $(hostname) == *$FORMAT* ]] ; then
              yum install -y /root/$KVMFORNFV_KERNEL_RPM
              grub2-mkconfig -o /etc/grub2.cfg
              sleep 5
              reboot
            fi
          params:
            $KVMFORNFV_KERNEL_RPM: {get_param: ComputeKernelArgs}
            $COMPUTE_HOSTNAME_FORMAT: {get_param: ComputeHostnameFormat}

outputs:
  # This means get_resource from the parent template will get the userdata, see:
  # http://docs.openstack.org/developer/heat/template_guide/composition.html#making-your-template-resource-more-transparent
  # Note this is new-for-kilo, an alternative is returning a value then using
  # get_attr in the parent template instead.
  OS::stack_id:
    value: {get_resource: userdata}