Allow additional preseed overrides

Sometimes the ephemeral environment needs additional cloud-init data.
This change allows user-data sections to be added to the default files
in /etc/maas/preseeds: enlist, commissioning, and curtin.

For example, to resolve issues with 'apt-get update' failures during
enlistment, something like this may be necessary:
conf:
  cloudconfig:
    override: true
    sections:
      bootcmd:
        - "rm -fr /var/lib/apt/lists"

Change-Id: I817006a799003ace3f35d02507489720b0f9079b
This commit is contained in:
Phil Sphicas 2021-02-12 06:24:29 +00:00
parent ccfbd4340f
commit 35fa3175e3
6 changed files with 58 additions and 0 deletions

View File

@ -52,3 +52,11 @@ data:
{{ tuple "etc/_logrotate.conf.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
logrotate.cron: |
{{ tuple "etc/_logrotate.cron.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- if .Values.conf.cloudconfig.override }}
enlist: |+
{{ tuple "etc/_enlist.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
commissioning: |+
{{ tuple "etc/_commissioning.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
curtin: |+
{{ tuple "etc/_curtin.tpl" . | include "helm-toolkit.utils.template" | indent 4 }}
{{- end }}

View File

@ -0,0 +1,4 @@
{{ "{{" }}preseed_data{{ "}}" }}
{{- range $k, $v := .Values.conf.cloudconfig.sections }}
{{ dict $k $v | toYaml | trim }}
{{- end }}

View File

@ -0,0 +1,4 @@
{{ "{{" }}preseed_data{{ "}}" }}
{{- range $k, $v := .Values.conf.cloudconfig.sections }}
{{ dict $k $v | toYaml | trim }}
{{- end }}

View File

@ -0,0 +1,13 @@
#cloud-config
datasource:
MAAS:
timeout : 50
max_wait : 120
# there are no default values for metadata_url or oauth credentials
# If no credentials are present, non-authed attempts will be made.
metadata_url: {{ "{{" }}metadata_enlist_url{{ "}}" }}
output: {all: '| tee -a /var/log/cloud-init-output.log'}
{{- range $k, $v := .Values.conf.cloudconfig.sections }}
{{ dict $k $v | toYaml | trim }}
{{- end }}

View File

@ -155,6 +155,20 @@ spec:
subPath: ntpd.sh
readOnly: true
{{- end }}
{{- if .Values.conf.cloudconfig.override }}
- name: maas-etc
mountPath: /etc/maas/preseeds/enlist
subPath: enlist
readOnly: true
- name: maas-etc
mountPath: /etc/maas/preseeds/commissioning
subPath: commissioning
readOnly: true
- name: maas-etc
mountPath: /etc/maas/preseeds/curtin
subPath: curtin
readOnly: true
{{- end }}
{{- if $mounts_maas_region.volumeMounts }}{{ toYaml $mounts_maas_region.volumeMounts | indent 12 }}{{ end }}
volumes:
- name: host-sys-fs-cgroup

View File

@ -192,6 +192,21 @@ conf:
# Example:
# late_commands:
# install_modules_extra: ["curtin", "in-target", "--", "apt-get", "-y", "install", "linux-modules-extra-4.15.0-88-generic"]
cloudconfig:
override: false
sections: {}
# Additional user-data sections to add to the default cloud-config.
# These apply to the ephemeral environment, used during enlistment,
# commissioning, and deployment (pre-curtin).
# In particular, bootcmd may be useful:
# https://cloudinit.readthedocs.io/en/latest/topics/modules.html#bootcmd
# Example:
# conf:
# cloudconfig:
# override: true
# sections:
# bootcmd:
# - "rm -fr /var/lib/apt/lists"
drydock:
bootaction_url: null
cache: