setup cloud-init FreeBSD-14.1BASIC-CLOUDINIT network troubleshooting

hi team!
So i have my template freeBSD cloud-init almost perfect but i'm strugling to configure the network in my cloud-init.yml file
so from the website FreeBSD i got this image: https://download.freebsd.org/releas....1-RELEASE-amd64-BASIC-CLOUDINIT-ufs.qcow2.xz
i configure it:
Code:
freebsd-update fetch install

pkg search cloud-init  # search cloud-init
pkg install py39-cloud-init-24.1.4

# add this line
vi /etc/rc.conf
cloudinit_enable="YES"

pkg install doas
vi /usr/local/etc/doas.conf # add the line below
permit nopass :wheel

Now i have made a template from this new VM
build another VM and run my cloud-init.yml
but i can't setup network configuration, i have tried many config but still nothing, any clue?
Code:
#cloud-config

hostname: freebsd-cloud-instance
manage_etc_hosts: true

network:
  config:
    - type: physical
      name: vtnet0
      mac_address: 'my-mac-address'
      subnets:
        - type: static
          address: 192.168.20.14/27
          gateway: 192.168.20.1

users:
  - name: test
    groups: wheel
    doas:
    - permit nopass test
    ssh_authorized_keys:
    - ssh-rsa your-long-ssh-key.pub
   
runcmd:
  - pw lock root
thx!
 
Hi,
One thing is to configure modules, other is turn on modules :)
For example, manage_etc_hosts doesn't work if update_etc_hosts module doesn't run. So, you should have these three lines in your cloud.cfg:

Code:
manage_etc_hosts: true
cloud_init_modules:
  - update_etc_hosts

I believe that the following code in cloud.cfg resolve your problem (please, test!):
Code:
#cloud-config

hostname: freebsd-cloud-instance
manage_etc_hosts: true

network:
  config:
    - type: physical
      name: vtnet0
      mac_address: 'my-mac-address'
      subnets:
        - type: static
          address: 192.168.20.14/27
          gateway: 192.168.20.1

users:
  - name: test
    groups: wheel
    doas:
    - permit nopass test
    ssh_authorized_keys:
    - ssh-rsa your-long-ssh-key.pub
  
runcmd:
  - [ pw, lock, root ]

# The modules that run in the 'init' stage
cloud_init_modules:
  - seed_random
  - bootcmd
  - write_files
  - growpart
  - resizefs
  - set_hostname
  - update_hostname
  - update_etc_hosts
  - ca_certs
  - rsyslog
  - users_groups
  - ssh

# The modules that run in the 'config' stage
cloud_config_modules:
  - ssh_import_id
  - keyboard
  - locale
  - set_passwords
  - ntp
  - timezone
  - disable_ec2_metadata
  - runcmd

# The modules that run in the 'final' stage
cloud_final_modules:
  - package_update_upgrade_install
  - write_files_deferred
  - puppet
  - chef
  - ansible
  - mcollective
  - salt_minion
  - reset_rmc
  - scripts_vendor
  - scripts_per_once
  - scripts_per_boot
  - scripts_per_instance
  - scripts_user
  - ssh_authkey_fingerprints
  - keys_to_console
  - install_hotplug
  - phone_home
  - final_message
  - power_state_change

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
  # This will affect which distro class gets used
  distro: freebsd
  # Default user name + that default users groups (if added/used)
  default_user:
    name: freebsd
    lock_passwd: True
    gecos: freebsd
    groups: [wheel]
    ssh_authorized_keys:
      - <your-keys>
    doas:
      - permit nopass freebsd
    sudo: ["ALL=(ALL) NOPASSWD:ALL"]
    shell: /bin/tcsh
  network:
    renderers: ['freebsd']
  paths:
    run_dir: /var/run/cloud-init/
 
Back
Top