Merge "Disable introspection extras"
[apex.git] / build / first-boot.yaml
1 ---
2 heat_template_version: 2014-10-16
3
4 description: >
5   This is an example showing how you can do firstboot configuration
6   of the nodes 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       Space seprated list of Kernel args to be update to grub.
13       The given args will be appended to existing args of
14       GRUB_CMDLINE_LINUX in file /etc/default/grub
15       Example:
16         "intel_iommu=on default_hugepagesz=2MB hugepagesz=2MB hugepages=2048"
17     type: string
18     default: ""
19   KVMForNFVKernelRPM:
20     description: >
21       Name of the kvmfornfv kernel rpm.
22       Example: "kvmfornfv_kernel.rpm"
23     type: string
24     default: ""
25   ComputeHostnameFormat:
26     type: string
27     default: ""
28
29 resources:
30   userdata:
31     type: OS::Heat::MultipartMime
32     properties:
33       parts:
34         - config: {get_resource: compute_kernel_args}
35
36   # Verify the logs on /var/log/cloud-init.log on the overcloud node
37   compute_kernel_args:
38     type: OS::Heat::SoftwareConfig
39     properties:
40       config:
41         str_replace:
42           template: |
43             #!/bin/bash
44             set -x
45             need_reboot='false'
46
47             if [ -n "$KERNEL_ARGS" ]; then
48               sed 's/^\(GRUB_CMDLINE_LINUX=".*\)"/\1 $KERNEL_ARGS"/g' \
49                                             -i /etc/default/grub ;
50               grub2-mkconfig -o /etc/grub2.cfg
51               hugepage_count=$(echo $KERNEL_ARGS | \
52                                grep -oP ' ?hugepages=\K[0-9]+')
53               if [ -z "$hugepage_count" ]; then
54                 hugepage_count=1024
55               fi
56               echo vm.hugetlb_shm_group=0 >> /usr/lib/sysctl.d/00-system.conf
57               HPAGE_CT=$(printf "%.0f" $(echo 2.2*$hugepage_count | bc))
58               echo vm.max_map_count=$HPAGE_CT >> \
59                                     /usr/lib/sysctl.d/00-system.conf
60               HPAGE_CT=$(($hugepage_count * 2 * 1024 * 1024))
61               echo kernel.shmmax=$HPAGE_CT >> /usr/lib/sysctl.d/00-system.conf
62               need_reboot='true'
63             fi
64
65             if [ -n "$KVMFORNFV_KERNEL_RPM" ]; then
66               FORMAT=$COMPUTE_HOSTNAME_FORMAT
67               if [[ -z $FORMAT ]] ; then
68                 FORMAT="compute" ;
69               else
70                 # Assumption: only %index% and %stackname% are
71                 # the variables in Host name format
72                 FORMAT=$(echo $FORMAT | sed  's/\%index\%//g');
73                 FORMAT=$(echo $FORMAT | sed 's/\%stackname\%//g');
74               fi
75               if [[ $(hostname) == *$FORMAT* ]] ; then
76                 yum install -y /root/$KVMFORNFV_KERNEL_RPM
77                 grub2-mkconfig -o /etc/grub2.cfg
78                 sleep 5
79                 need_reboot='true'
80               fi
81             fi
82
83             if [ "$need_reboot" == "true" ]; then
84               reboot
85             fi
86           params:
87             $KERNEL_ARGS: {get_param: ComputeKernelArgs}
88             $KVMFORNFV_KERNEL_RPM: {get_param: KVMForNFVKernelRPM}
89             $COMPUTE_HOSTNAME_FORMAT: {get_param: ComputeHostnameFormat}
90
91 outputs:
92   OS::stack_id:
93     value: {get_resource: userdata}