Cloudinit Rancher ubuntu

This has only been tested with Ubuntu 20.04 Cloudimg but should work most cloud init distros.

The example

  1. Adds "myAdminAccount" with ssh key authentication

  2. Sets network config with a specific route for a network (if needed - or else omitt it)

Make sure you change the interface name to what your distro sets it as

#cloud-config
users:
  - name: myAdminAccount
    shell: /bin/bash
    groups: wheel
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    ssh-authorized-keys:
      - <RSA MYPUBLICKEY>
write_files:
- path: /etc/netplan/qd-ens192-config.yaml
  permissions: '0644'
  content: |
    network:
        version: 2
        ethernets:
            ens192:
                dhcp4: true
                routes:                
                 - to: 172.17.1./24
                   via: 10.10.10.1

runcmd:
 - rm /etc/netplan/50-cloud-init.yaml
 - netplan generate
 - netplan apply     

Last updated