• Uncategorized

About ubuntu : Using-a-pipe-in-cloud-init-runcmd-fails

Question Detail

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?

Question Answer

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

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.