cloud-init

How to properly pass parameters with dash to cloud-init-per in cloud-init


I stumbled upon the following issue if I try to pass command with extra flags like argument (with dash) the cloud-init-per tries to intepret them like their own I don't see option to escape like -- or ---

bootcmd:
- [cloud-init-per, once, mkdir, -m, 0755, -p, /etc/samba]

Result (in /var/log/cloud-init-output.log):

/usr/bin/cloud-init-per: 63: -m: not found

Has anyone found solution for it ? The examples in the doc does not resolve this kind of issues. They use example with mkfs for instance [mkfs.ext4, /dev/vdb]

For instance I tried:

[cloud-init-per, once, ---, mkdir, -m, 0755, -p, /etc/samba]    

result:

mkdir: invalid mode ‘493’

Solution

  • 0755 is being translated by the yaml parser as a number rather than a string.

    #cloud-config
    bootcmd:
    - [cloud-init-per, once, --, mkdir, -m, "0755", -p, /etc/samba]
    

    should do what you expect.