#!/usr/bin/env bash
set -eu
export LC_ALL=C

cat <<EOF
#cloud-config
---
hostname: ${NODE_HOSTNAME}

# Set SSH Key
ssh_authorized_keys:
- ${NODE_PUBLIC_KEY}

network:
  version: 2
  ethernets:
    mng:
      match:
        name: ${NODE_NET_DEVICE}*
      addresses:
        - ${NODE_ADDRESS}/${NODE_NETWORK_RANGE}
      gateway4: ${NODE_GATEWAY}
      nameservers:
        addresses: [${NODE_DNS}]

runcmd:
  - [ sh, -c, "echo '127.0.1.1  ${NODE_HOSTNAME}' >> /etc/hosts"]
EOF

#!/usr/bin/env bash
set -eu
export LC_ALL=C

cat <<EOF
#cloud-config
---
hostname: ${NODE_HOSTNAME}

# Set SSH Key
ssh_authorized_keys:
- ${NODE_PUBLIC_KEY}

network:
  config: disabled

runcmd:
  - [ rm, -f, /etc/network/interfaces.d/50-cloud-init.cfg]
  - [ rm, -f, /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg]
  - [ sh, -c, "echo 'auto ${NODE_NET_DEVICE}' >> /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg "]
  - [ sh, -c, "echo 'iface ${NODE_NET_DEVICE} inet static' >> /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg" ]
  - [ sh, -c, "echo '  address ${NODE_ADDRESS}' >> /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg" ]
  - [ sh, -c, "echo '  netmask ${NODE_NETMASK}' >> /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg" ]
  - [ sh, -c, "echo '  gateway ${NODE_GATEWAY}' >> /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg"]
  - [ sh, -c, "echo '  dns-nameservers ${NODE_DNS}' >> /etc/network/interfaces.d/${NODE_NET_DEVICE}.cfg"]
  - [ ifdown, ${NODE_NET_DEVICE} ]
  - [ ifup, ${NODE_NET_DEVICE} ]
  - [ sh, -c, "echo '127.0.1.1  ${NODE_HOSTNAME}' >> /etc/hosts"]
EOF

Revert to use network section in cloudconfig
Revert to use network section in cloudconfig
