From 35fa3175e3d2873d3a7e21cdc793e9d153df7886 Mon Sep 17 00:00:00 2001 From: Phil Sphicas Date: Fri, 12 Feb 2021 06:24:29 +0000 Subject: [PATCH] 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 --- charts/maas/templates/configmap-etc.yaml | 8 ++++++++ charts/maas/templates/etc/_commissioning.tpl | 4 ++++ charts/maas/templates/etc/_curtin.tpl | 4 ++++ charts/maas/templates/etc/_enlist.tpl | 13 +++++++++++++ charts/maas/templates/statefulset-region.yaml | 14 ++++++++++++++ charts/maas/values.yaml | 15 +++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 charts/maas/templates/etc/_commissioning.tpl create mode 100644 charts/maas/templates/etc/_curtin.tpl create mode 100644 charts/maas/templates/etc/_enlist.tpl diff --git a/charts/maas/templates/configmap-etc.yaml b/charts/maas/templates/configmap-etc.yaml index 60f12bc..09ba719 100644 --- a/charts/maas/templates/configmap-etc.yaml +++ b/charts/maas/templates/configmap-etc.yaml @@ -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 }} diff --git a/charts/maas/templates/etc/_commissioning.tpl b/charts/maas/templates/etc/_commissioning.tpl new file mode 100644 index 0000000..105d153 --- /dev/null +++ b/charts/maas/templates/etc/_commissioning.tpl @@ -0,0 +1,4 @@ +{{ "{{" }}preseed_data{{ "}}" }} +{{- range $k, $v := .Values.conf.cloudconfig.sections }} +{{ dict $k $v | toYaml | trim }} +{{- end }} diff --git a/charts/maas/templates/etc/_curtin.tpl b/charts/maas/templates/etc/_curtin.tpl new file mode 100644 index 0000000..105d153 --- /dev/null +++ b/charts/maas/templates/etc/_curtin.tpl @@ -0,0 +1,4 @@ +{{ "{{" }}preseed_data{{ "}}" }} +{{- range $k, $v := .Values.conf.cloudconfig.sections }} +{{ dict $k $v | toYaml | trim }} +{{- end }} diff --git a/charts/maas/templates/etc/_enlist.tpl b/charts/maas/templates/etc/_enlist.tpl new file mode 100644 index 0000000..0f71d9b --- /dev/null +++ b/charts/maas/templates/etc/_enlist.tpl @@ -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 }} diff --git a/charts/maas/templates/statefulset-region.yaml b/charts/maas/templates/statefulset-region.yaml index 2662e48..5426e58 100644 --- a/charts/maas/templates/statefulset-region.yaml +++ b/charts/maas/templates/statefulset-region.yaml @@ -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 diff --git a/charts/maas/values.yaml b/charts/maas/values.yaml index 57dc90f..3ea9abf 100644 --- a/charts/maas/values.yaml +++ b/charts/maas/values.yaml @@ -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: