← Back to team overview

cloud-init team mailing list archive

Re: The documentation doesn't seem to be thorough enough

 

This isn't documented. It's really not intended for users to be
overriding things defined in cloud.cfg, but it happens enough that we
should document it.

On your cloud instance, /etc/cloud/cloud.cfg (and anything in the .d
directory) specifies what cloud-init modules are run and in what stage
of cloud-init. More about stages and modules at:
https://cloudinit.readthedocs.io/en/latest/topics/boot.html
https://cloudinit.readthedocs.io/en/latest/topics/modules.html

The "once" in the example you listed is frequency. It specifies when a
module should be run. Some modules are run every single boot, some
only once per instance, and others only once ever. Valid frequencies
are "once", "once-per-instance", and "always". By default,
users-groups is run once per instance, so this is instructing
cloud-init to run this snippet only once. It's a way of using
cloud-init to get a key into the instance as a one-time thing.

On Tue, Sep 28, 2021 at 10:50 PM Yuri Kanivetsky
<yuri.kanivetsky@xxxxxxxxx> wrote:
>
> Hi,
>
> I've run into the following... what do you call it? piece of user data?
>
> Content-Type: multipart/mixed; boundary="//"
> MIME-Version: 1.0
>
> --//
> Content-Type: text/cloud-config; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: attachment; filename="cloud-config.txt"
>
> #cloud-config
> cloud_final_modules:
> - [users-groups, once]
> users:
>   - name: username
>     ssh-authorized-keys:
>     - PublicKeypair
>
> https://aws.amazon.com/premiumsupport/knowledge-center/user-data-replace-key-pair-ec2/
>
> What is the syntax of cloud configs? The most unclear thing is once.
> Once per what? Is it documented? If I don't specify the
> cloud_final_modules key, does it change anything?
>
> Regards,
> Yuri
>
> --
> Mailing list: https://launchpad.net/~cloud-init
> Post to     : cloud-init@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~cloud-init
> More help   : https://help.launchpad.net/ListHelp


References