I am installing Ubuntu 20.04 server via UEFI HTTP booting, subiquity and a NoCloud data source. The actual install works and I get the base OS running.
I also need to configure some things after installation is complete, or on first boot after the installer has rebooted however.
I have tried various things in user-data
:
write_files:
- path: /target/etc/example.conf
permissions: 644
content: |
example content
- path: /target/var/lib/cloud/scripts/per-once/test.sh
permissions: 755
content: |
#!/bin/sh
date > /tmp/i_ran
date
echo test1
runcmd:
- echo test2 > /tmp/test2
- cloud-init-per once testing echo test3
- [ cloud-init-per, once, testing2, touch, /tmp/test4 ]
- [ curtin, in-target, --target=/target, --, cloud-init-per, once, testing3, touch, /tmp/testing5 ]
late-commands:
- echo test5 > /target/etc/test5.conf
- curtin in-target --target=/target -- cloud-init-per once testing9 touch /tmp/testing9
The commands run (as seen in the subiquity debug log) but nothing seems to leave a mark on the installed system. e.g. no files in /tmp
or /etc
and no messages in the post reboot logs that I have found. I have tried write_files
with, and without /target
before it.
What is the intended method to write arbitrary files on the target or run arbitrary commands after install?
I'm not sure if this is the official method but what is now working to write a file to the target system is:
I had tried that before and it didn't work but I can only assume there was some other error I missed that caused it to fail on that test.
Using
curtin in-target --target=/target -- cmd
as part of late-commands works for running commands.I haven't managed to get any of the other methods (e.g.
cloud-init-per
,write_files
) to work. This solves my immediate need however.