0

I'm currently trying to create a pve template for Ubuntu 20.04, I've managed to get everything working apart from that I can't seem to extend my netplan config (which adds keys that make networking work as a whole)

I've tried the following:

  • Attempted to use write_files to add an additional file called 60-routes.yaml - Issue: the config is only applied if I manually run a netplan apply after logging into SSH after cloud-init finishes. Here is my write_files config.

  • Including the above, I tried to use both runcmd & bootcmd (seperately) to apply the new config file. Issue: These commands seem to run before the write_files is executed, as my network still only works after manually applying as aforementioned.

Here is the additional netplan config I'm trying to add, where "HIDDEN" is replaced with values that I can confirm work:

network:
  version: 2
  ethernets:
    eth0:
      gateway4: HIDDEN
      routes:
      - to: 0.0.0.0/0
        via: HIDDEN
        on-link: true

If anyone can guide me in the correct direction on how to extend cloud-init's netplan config I'd greatly appreciate it, thanks!

viction
  • 3
  • 2

1 Answers1

1

I'm sure you've already tried this, so I don't think I can help you.
This code works fine for me.

write_files:
 - path: /etc/netplan/99-custom.yaml
   content: |
    network:
      ethernets:
        enp6s0:
          dhcp4: false
          addresses: [192.xxx.yyy.zzz/24]
          gateway4: 192.xxx.yyy.1
          nameservers:
            addresses:
              - 192.xxx.yyy.1
              - 1.1.1.1
              - 8.8.8.8
      version: 2
runcmd:
  - sudo netplan apply
YANNO
  • 11
  • 1
  • This post may help you to solve the problem. kvm virtualization - how to add network configuration to cloud init image to run a kvm image - Server Fault https://serverfault.com/questions/988054/how-to-add-network-configuration-to-cloud-init-image-to-run-a-kvm-image – YANNO Jul 10 '21 at 03:01
  • Hi, I have tried this and it seems to have worked fine but its not the solution I am after, as I ideally dont want to have to use a seperate cloudinit config for each VM so I can specify its ip. – viction Jul 11 '21 at 13:28