d4ac5df6b9fd870746496d3e65889bdfaafdf09e
[apex.git] / build / first-boot.yaml
1 heat_template_version: 2014-10-16
2
3 description: >
4   This is an example showing how you can do firstboot configuration
5   of the nodes via cloud-init.  To enable this, replace the default
6   mapping of OS::TripleO::NodeUserData in ../overcloud_resource_registry*
7
8 parameters:
9   ComputeKernelArgs:
10     description: >
11       Space seprated list of Kernel args to be update to grub.
12       The given args will be appended to existing args of GRUB_CMDLINE_LINUX in file /etc/default/grub
13       Example: "intel_iommu=on default_hugepagesz=2MB hugepagesz=2MB hugepages=2048"
14     type: string
15     default: ""
16
17 resources:
18   userdata:
19     type: OS::Heat::MultipartMime
20     properties:
21       parts:
22       - config: {get_resource: compute_kernel_args}
23
24   # Verify the logs on /var/log/cloud-init.log on the overcloud node
25   compute_kernel_args:
26     type: OS::Heat::SoftwareConfig
27     properties:
28       config:
29         str_replace:
30           template: |
31             #!/bin/bash
32             set -x
33             sed 's/^\(GRUB_CMDLINE_LINUX=".*\)"/\1 $KERNEL_ARGS"/g' -i /etc/default/grub ;
34             grub2-mkconfig -o /etc/grub2.cfg
35             hugepage_count=`echo $KERNEL_ARGS | grep -oP ' ?hugepages=\K[0-9]+'`
36             if [ -z "$hugepage_count" ]; then
37               hugepage_count=1024
38             fi
39             echo vm.hugetlb_shm_group=0 >> /usr/lib/sysctl.d/00-system.conf
40             echo vm.max_map_count=$(printf "%.0f" $(echo 2.2*$hugepage_count | bc)) >> /usr/lib/sysctl.d/00-system.conf
41             echo kernel.shmmax=$(($hugepage_count * 2 * 1024 * 1024)) >> /usr/lib/sysctl.d/00-system.conf
42             rm -f /etc/sysconfig/network-scripts/ifcfg-*
43             reboot
44           params:
45             $KERNEL_ARGS: {get_param: ComputeKernelArgs}
46
47 outputs:
48   # This means get_resource from the parent template will get the userdata, see:
49   # http://docs.openstack.org/developer/heat/template_guide/composition.html#making-your-template-resource-more-transparent
50   # Note this is new-for-kilo, an alternative is returning a value then using
51   # get_attr in the parent template instead.
52   OS::stack_id:
53     value: {get_resource: userdata}