Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AkihiroSuda opened this issue Oct 10, 2024 · 3 comments
Open

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

AkihiroSuda opened this issue Oct 10, 2024 · 3 comments
Labels
kind/refactoring Refactoring

Comments

@AkihiroSuda
Copy link
Member

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?)

@AkihiroSuda AkihiroSuda added the kind/refactoring Refactoring label Oct 10, 2024
@jandubois
Copy link
Member

(What are those differences?)

I think the main difference is that bootcmd is running much earlier in the boot sequence (as the cloud-init-local.service). I'm not sure when that is needed though.

@afbjorklund
Copy link
Member

I'm not sure when that is needed though.

I think it originally came from this feature request:

@jandubois
Copy link
Member

I think it originally came from this feature request:

Yes, but it was proposed as just something that might be useful, without an actual need for it:

Another nice to have feature is allowing Lima users to customize cloud init’s cloud-init-local.service behavior via bootCmds, which run very early in the boot process (more info here). Users can use this feature to disable unnecessary services via systemctl (or other means, depending on the OS), or run other arbitrary commands for other reasons.

It is totally possible that nobody is using it at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/refactoring Refactoring
Projects
None yet
Development

No branches or pull requests

3 participants