Assign a network confg with cloudinit and vSphere provider


#1

According to this page https://rancher.com/docs/rancher/v2.x/en/cluster-provisioning/rke-clusters/node-pools/vsphere/, I should be able to do this.

URL of a RancherOS cloud-config file to provision VMs with. This file allows further customization of the RancherOS operating system, such as network configuration, DNS servers, or system daemons.

I created a cloudconfig with this content:

rancher:
  network:
    interfaces:
      eth0:
        address: 172.16.0.163/22
        gateway: 172.16.0.1
        mtu: 1500
        dhcp: false
    dns:
      nameservers:
      - 172.16.0.1
      - 8.8.8.8

and put the URL into the Node Template. However, whenever I spin up a node from this template, every single thing set there is ignored. Am I missing something?


#2

The solution is to ensure that #cloud-config appears at the start of the file, so that cloudinit knows how to parse it.

The file should look like this instead:

#cloud-config
rancher:
  network:
    interfaces:
      eth0:
        address: 172.16.0.163/22
        gateway: 172.16.0.1
        mtu: 1500
        dhcp: false
    dns:
      nameservers:
      - 172.16.0.1
      - 8.8.8.8

Leaving this up in case it helps someone else.