How can I use a pipe to redirect the output of a command in my runcmd
section of my cloud init script? The following fails:
runcmd:
- [curl, -sk, https://example.com/packages/current/install.bash, '|', /bin/bash, -s, agent:certname=XYZ.com]
It ends up creating a script that looks like this:
'curl' '-sk' 'https://example.com/packages/current/install.bash' '|' '/bin/bash' '-s' 'agent:certname=XYZ.com'
Because the pipe becomes quoted, the script fails. How can I get around this problem?
You should look into /var/log/cloud-init. log and see what's there. Depending on your cloud-init user-data, the VM may even restart before it's done. However, the logs and cloud-init's analyze command should help figure out what's working as expected and what's not.
The entry we need to create will not need to include the username, since cloud-init is smart enough to figure out the account name from the entry information. The directive we need to use is sudo , which is aligned with our other users level directives.
Short answer: there is no supported path for running versions of cloud-init newer than 0.6. 3-0ubuntu1 on Ubuntu 12.04. However, some information on the general process may help you out. For currently supported versions of Ubuntu you can upgrade to the latest supported cloud-init with 'apt-get upgrade'.
Rather than using an array, use a single string.
runcmd:
- 'curl -sk "https://example.com/packages/current/install.bash" | /bin/bash -s, agent:certname=XYZ.com'
See also: https://www.digitalocean.com/community/questions/help-with-cloud-init-syntax-for-runcmd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With