Capture creation of BMH resources into Helm chart
[icn.git] / deploy / machines / templates / _userdata.yaml
1 {{- define "machines.userData" -}}
2 {{- if .userData -}}
3 #cloud-config
4 {{- if and .userData.name .userData.hashedPassword }}
5 users:
6 - name: {{ .userData.name }}
7   lock_passwd: False
8   passwd: {{ .userData.hashedPassword }}
9   sudo: "ALL=(ALL) NOPASSWD:ALL"
10 {{- else if .userData.hashedPassword }}
11 password: {{ .userData.hashedPassword }}
12 {{- end }}
13 chpasswd: {expire: False}
14 ssh_pwauth: True
15 fqdn: {{ .userData.fqdn }}
16 disable_root: false
17 ssh_authorized_keys:
18 - {{ .userData.sshAuthorizedKey }}
19 write_files:
20 - path: /var/lib/cloud/scripts/per-instance/set_dhcp_identifier.sh
21   # The IP address assigned to the provisioning NIC will change due to
22   # IPA using the MAC address as the client ID and systemd using a
23   # different ID.  Tell systemd to use the MAC as the client ID.  We
24   # can't do this in the network data as only the JSON format is
25   # supported by metal3, and the JSON format does not support the
26   # dhcp-identifier field.
27   owner: root:root
28   permissions: '0777'
29   content: |
30     #!/usr/bin/env bash
31     set -eux -o pipefail
32     sed -i -e '/dhcp4: true$/!b' -e 'h;s/\S.*/dhcp-identifier: mac/;H;g' /etc/netplan/50-cloud-init.yaml
33     netplan apply
34 - path: /var/lib/cloud/scripts/per-instance/set_kernel_cmdline.sh
35   # The "intel_iommu=on iommu=pt" kernel command line is necessary for
36   # QAT support.
37   owner: root:root
38   permissions: '0777'
39   content: |
40     #!/usr/bin/env bash
41     set -eux -o pipefail
42     grub_file=${1:-"/etc/default/grub"}
43     kernel_parameters="intel_iommu=on iommu=pt"
44     sed -i~ "/^GRUB_CMDLINE_LINUX=/{h;s/\(=\".*\)\"/\1 ${kernel_parameters}\"/};\${x;/^$/{s//GRUB_CMDLINE_LINUX=\"${kernel_parameters}\"/;H};x}" "$grub_file"
45     update-grub
46     reboot
47 {{ end }}
48 {{- end }}