ok so here is how i solved it
for ubuntu image you can use the netplan file located at /etc/netplan/SOMEFILE.yaml
for centos i noticed the image does not have net plan so i just wrote the interface files in my config
use the write_files to create the netplan file on ubuntu and interface files on the centos
after that use the runcmd to initialize your interfaces by running the appropriate commands
here are my config.yaml files for ubuntu and centos respectively
#cloud-config
package_upgrade: true
users:
- name: USER
groups: wheel
lock_passwd: false
passwd: PASSWORD_HASH
shell: /bin/bash
ssh_pwauth: true
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- ssh-rsa YOUR_KEY
write_files:
- path: /etc/netplan/50-cloud-init.yaml
permissions: '0644'
content: |
network:
version: 2
renderer: networkd
ethernets:
ens3:
addresses: [IP/SUBNET]
routes:
- to: NETWORK
via: NEXT_HOP
ens4:
addresses: [IP/SUBNET]
gateway4: GATEWAY
nameservers:
addresses: [DNS]
runcmd:
- [sudo, ifconfig, IFNAME, up]
- [sudo, ifconfig, IFNAME, up]
- [sudo, netplan, generate]
- [sudo, netplan, apply]
- [sudo, sed ,-i, 's/PasswordAuthentication no/PasswordAuthentication yes/g', /etc/ssh/sshd_config]
- [sudo, systemctl, restart, sshd]
#cloud-config
package_upgrade: true
users:
- name: USER
groups: wheel
lock_passwd: false
passwd: PASSWORD_HASH
shell: /bin/bash
ssh_pwauth: true
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- ssh-rsa YOUT_KEY
write_files:
- path: /etc/sysconfig/network-scripts/ifcfg-INTERFACE
permissions: '0644'
content: |
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
IPV4_FAILURE_FATAL="no"
NAME="INTERFACE"
DEVICE="INTERFACE"
ONBOOT="yes"
IPADDR="IP"
PREFIX="PREFIX"
GATEWAY="GATEWAY"
DNS1="DNS"
ZONE=ZONE
- path: /etc/sysconfig/network-scripts/ifcfg-INTERFACE
permissions: '0644'
content: |
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
NAME=INTERFACE
DEVICE=INTERFACE
ONBOOT=yes
IPADDR=IP
PREFIX=PREFIX
IPV6_PRIVACY=no
ZONE=ZONE
runcmd:
- [sudo, ifup, INTERFACE]
- [sudo, ifup, INTERFACE]
- [sudo, sed ,-i, 's/PasswordAuthentication no/PasswordAuthentication yes/g', /etc/ssh/sshd_config]
- [sudo, systemctl, restart, sshd]