Skip to content

cloud-init: unify bootcmd into per-boot script? #2719

@AkihiroSuda

Description

@AkihiroSuda

write_files:
- content: |
#!/bin/sh
set -eux
LIMA_CIDATA_MNT="/mnt/lima-cidata"
LIMA_CIDATA_DEV="/dev/disk/by-label/cidata"
mkdir -p -m 700 "${LIMA_CIDATA_MNT}"
mount -o ro,mode=0700,dmode=0700,overriderockperm,exec,uid=0 "${LIMA_CIDATA_DEV}" "${LIMA_CIDATA_MNT}"
export LIMA_CIDATA_MNT
exec "${LIMA_CIDATA_MNT}"/boot.sh
owner: root:root
path: /var/lib/cloud/scripts/per-boot/00-lima.boot.sh
permissions: '0755'
{{- if .DNSAddresses }}
# This has no effect on systems using systemd-resolved, but is used
# on e.g. Alpine to set up /etc/resolv.conf on first boot.
manage_resolv_conf: true
resolv_conf:
nameservers:
{{- range $ns := $.DNSAddresses }}
- {{$ns}}
{{- end }}
{{- end }}
{{ with .CACerts }}
ca_certs:
remove_defaults: {{ .RemoveDefaults }}
{{- if .Trusted}}
trusted:
{{- range $cert := .Trusted }}
- |
{{- range $line := $cert.Lines }}
{{ $line }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .BootCmds }}
bootcmd:
{{- range $cmd := $.BootCmds }}
- |
# We need to embed the params.env as a here-doc because /mnt/lima-cidata is not yet mounted
while read -r line; do [ -n "$line" ] && export "$line"; done <<'EOF'
{{- range $key, $val := $.Param }}
PARAM_{{ $key }}={{ $val }}
{{- end }}
EOF
{{- range $line := $cmd.Lines }}
{{ $line }}
{{- end }}
{{- end }}
{{- end }}

Is it possible to unify bootcmd into the /var/lib/cloud/scripts/per-boot scripts? (What are those differences?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions