From c969c8e4b97360c2ad1673efada3da9f22e76fd6 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 3 Mar 2020 14:25:43 +0100 Subject: [PATCH] add runcmd to copy autoinstall from user-data to /autoinstall.yaml --- .../includes.binary/overlay/etc/cloud/cloud.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/live-build/ubuntu-server/includes.binary/overlay/etc/cloud/cloud.cfg b/live-build/ubuntu-server/includes.binary/overlay/etc/cloud/cloud.cfg index a0cdeb44..0b897d75 100644 --- a/live-build/ubuntu-server/includes.binary/overlay/etc/cloud/cloud.cfg +++ b/live-build/ubuntu-server/includes.binary/overlay/etc/cloud/cloud.cfg @@ -116,3 +116,15 @@ system_info: primary: http://ports.ubuntu.com/ubuntu-ports security: http://ports.ubuntu.com/ubuntu-ports ssh_svcname: ssh + +runcmd: + - - "python3" + - "-c" + - | + import subprocess, sys, yaml + user_data = yaml.safe_load(subprocess.run([ + "cloud-init", "query", "userdata"], + check=True, stdout=subprocess.PIPE, encoding='utf-8').stdout) + if 'autoinstall' in user_data: + with open("/autoinstall.yaml", "w") as fp: + yaml.dump(user_data['autoinstall'], fp)