Comment 5 for bug 1764264

Scott Moser (smoser) wrote :

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:
 - [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 '....'