Search code examples
ubuntucloud-init

How Can I Run a Cloud-Init User data YAML File


I'm having this YAML file that I would like to run via cloud-init and I'm running into errors. Here is what I did:

  1. Created a folder called /myfolder-config on the root file system

  2. Copied the YAML file to this location:

 #cloud-config
ssh_pwauth: false

groups:
  - openelectrons_k3s: [openelectrons]

users:
  - name: openelectrons
    gecos: openelectrons
    sudo: ALL=(ALL) NOPASSWD:ALL
    groups: sudo
    ssh_import_id: None
    lock_passwd: true
    shell: /bin/bash
    ssh_authorized_keys:
      - <ssh-pub-key>

hostname: openelectrons-k3s-<num>

I face these error:

usage: /usr/bin/cloud-init [-h] [--version] [--file FILES] [--debug] [--force] {init,modules,single,query,dhclient-hook,features,analyze,devel,collect-logs,clean,status,schema} ...
/usr/bin/cloud-init: error: unrecognized arguments: /myfolder-config/

Any ideas as to what I'm doing wrong?


Solution

  • Any ideas as to what I'm doing wrong?

    It looks like you tried to run cloud-init /myfolder-config/, which is not how cloud-init is intended to be used.

    For help getting started with cloud-init, consider starting with a tutorial.