on a mostly unrelated note, you're kind of relying on an implementation detail of cloud-init's runcmd behavior.
runcmd: ['set -xe', "mkdir -p '/var/lib/juju'\ncat > '/var/lib/juju/MAASmachine.txt' << 'EOF'\n'hostname: nuc7\n'\nEOF\nchmod 0755 '/var/lib/juju/MAASmachine.txt'", 'set -xe', ..]
I'd much rather see that as:
runcmd:
- [sh, '-c', 'set -xe\nmkdir -p\ncat >'/var/lib/...']
the difference being that you are assuming the 'set -xe' from the first entry in runcmd changes the state of the shell that is interpreting 'mkdir -p'.
I'd like to make a change in the future for your command to essentially get invoked as:
sh -c 'set -xe'
sh -c 'mkdir -p ...'
sh -c '....'
on a mostly unrelated note, you're kind of relying on an implementation detail of cloud-init's runcmd behavior. juju'\ncat > '/var/lib/ juju/MAASmachin e.txt' << 'EOF'\n'hostname: nuc7\n'\nEOF\nchmod 0755 '/var/lib/ juju/MAASmachin e.txt'" , 'set -xe', ..]
runcmd: ['set -xe', "mkdir -p '/var/lib/
I'd much rather see that as:
runcmd:
- [sh, '-c', 'set -xe\nmkdir -p\ncat >'/var/lib/...']
the difference being that you are assuming the 'set -xe' from the first entry in runcmd changes the state of the shell that is interpreting 'mkdir -p'.
I'd like to make a change in the future for your command to essentially get invoked as:
sh -c 'set -xe'
sh -c 'mkdir -p ...'
sh -c '....'