Re: cloud init documentation ?
- Reply: mike tancsa : "Re: cloud init documentation ?"
- In reply to: mike tancsa : "cloud init documentation ?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 25 Jul 2024 22:57:17 UTC
On Wed, 24 Jul 2024, at 19:08, mike tancsa wrote: > I gave the cloud-init image a spin, but beyond adding some users, I am > not able to get packages added or even runcmd or bootcmd to execute. > This is using the FreeBSD-14.1-RELEASE-amd64-BASIC-CLOUDINIT-zfs.raw > image from the FreeBSD download directory. Where can I find > documentation on what is supported ? > > Is there also a way to test the config beyond deploying and seeing if it > works or not ? > > ---Mike hi Mike cloudinit is somewhat cryptic. Please post whatever cloud-config or user-data file you're using, what cloud provider, what cloudinit version is in your freebsd image. With the caveat that I've not specifcally used these CLOUDINIT images, here's what I know about cloudinit itself on FreeBSD. For cloudinit to work, you have to have a DataSource that provides user data to cloudinit. Virtualbox or bhyve don't do this automatically. You can test via qemu, or via jail, but you need to set up a DataSource, either on the network, or on the local filesystem (good for testing). Here's a qemu example: https://docs.cloud-init.io/en/latest/howto/run_cloud_init_locally.html For jails, see https://people.freebsd.org/~dch/posts/2024-07-25-cloudinit/ for details, and let me know if anything is awry. TLDR: install jail, add cloudinit, add 3 files, zfs snapshot, restart jail (or restart both dsidentify, and cloudinit) # /usr/local/etc/cloud/cloud.cfg.d/00_nocloud.cfg datasource_list: ['NoCloud'] datasource: NoCloud: seedfrom: file:///root/cloud/ network: config: disabled timeout: 1 # /root/cloud/meta-data empty file or just copy what your cloud issues # /root/cloud/user-data #cloud-config ... your stuff here I have tested all of these against cloud-init-23.3 from ports quarterly: ```yaml #cloud-config # deploy ssh key to primary user # create a new account, one true shell, sudo, join wheel users: - default - name: ansible groups: wheel shell: /bin/sh sudo: 'ALL=(ALL) NOPASSWD:ALL' ssh_authorized_keys: - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJZ0cNlRkFRRleUZhFjIZYJ2p7h7wNWvODGBLEzfSfvr # touch an arbitrary file very early on write_files: - content: | awesome path: /var/tmp/cloudinit_was_here # run an arbitrary command which happens after that bootcmd: - echo excellent | tee -a /var/tmp/cloudinit_was_here # run an arbitrary command later on runcmd: - echo fantastic | tee -a /var/tmp/cloudinit_was_here packages: - www/gurl ``` this gives the expected (sorted) output in /var/tmp/cloudinit_was_here: awesome excellent fantastic latest cloudinit 24.2 also works, but now bootcmd runs before write_files, so the above output is missing 'excellent', and there are some issues in handling datasources, because the dsidentify tool that handles that is written in shell, and cannot process valid yaml. In my experience, every cloudinit release has minor breakage. Mina has made extensive progress over the last couple of years improving FreeBSD support, with upstream. We should actively support nuageinit (merci bapt@) in FreeBSD src, which is missing the following features used above: - bootcmd (early cmd) - runcmd (late cmd) - packages - write_files - fetching metadata from e.g. http://169.254.169.254/ style urls [nuageinit]: https://cgit.freebsd.org/src/commit/?id=16a6da44e28d [cloudinit]: https://github.com/canonical/cloud-init/issues?q=freebsd A+ Dave