After I manually edit /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
, how do I tell cloud-init
to update /etc/netplan/50-cloud-init.yaml
? In other words, it doesn't make sense to manually update both files; what's the standard process to re-apply the netplan?
In recent Ubuntu, netplan is the default way of configuring network adapters. I want a static IP on one of mine, and there are some guides on how to do that. Some point you to editing 50-cloud-init.yaml. But that file has an ominous warning:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
One answer on askubuntu references this and has the user do just so. (Note it has the renderer set to networkd.)
Which approach is right? Do they both work?
Most confusing, what does "persist across an instance" mean? The settings persist just fine across a reboot. When would I expect to lose settings in 50-cloud-init.yaml?
I've installed Ubuntu Server 18.04, and instead of the old /etc/network/interfaces
, it seems that my network configuration now lives in a series of YAML files in /etc/netplan
, of which the only one I actually have is /etc/netplan/50-cloud-init.yaml
:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens3:
addresses: []
dhcp4: true
dhcp6: true
nameservers: {}
optional: true
ens4:
addresses: []
dhcp4: true
dhcp6: true
nameservers: {}
optional: true
version: 2
That seems to have been generated by cloud-init
, from /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
:
network:
ethernets:
ens3:
addresses: []
dhcp4: true
dhcp6: true
nameservers: {}
optional: true
ens4:
addresses: []
dhcp4: true
dhcp6: true
nameservers: {}
optional: true
version: 2
What's the right way to edit this configuration and apply the changes to the running machine? The comment in the Netplan file suggested to me that it's ephemeral and generated on reboot by cloud-init
, so I should edit cloud-init
's config. But even after editing it and rebooting, I don't see any changes to the Netplan file, and I definitely don't know how to apply the cloud-init
config changes manually. And upon reading the comment again, now it seems to me that it's talking about changes not persisting across destruction and recreation of the machine, which would seem to go without saying. So clearly I'm misunderstanding something.
So my question is:
Where in the new
cloud-init
/netplan
system am I supposed to be putting manual network configuration?How do I apply changes I make in
/etc/netplan
?How do I apply changes I make in
/etc/cloud/cloud.cfg.d
?
Installing Ubuntu Server 18.04, I see the networking config in /etc/netplan has a .yml file that talks about CloudInit and networking configuration not persisting across instances.
I have read https://help.ubuntu.com/community/CloudInit but am unsure what the exact use case for CloudInit would be, and why it would be on by default. My server is not on AWS nor any cloud platform.
So I've disabled this with /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg as per the comment at the start of the config file, and assigned a simple static IP and that works fine.
To be clear: I am not asking how to disable it (I have done that, and am happy with the result). I just don't understand the reason for its existence, nor can I make that out from the documentation for it. Is it intended to replace DHCP in some way?
I have a fully-configured instance and an image from that for an autoscaling group. When autoscaling new instances from this image, it calls cloud-init. cloud-init changes the hostname and breaks fstab.
I want to prevent cloud-init from starting on instance launch.