During my investigation in to confining cloud-init (snapcraft.yaml here), I found that I needed to add the following system-files
interface for networking configuration to run successfully (and without DENIED log messages from AppArmor):
network-extra-files:
interface: system-files
read:
# This was getting DENIED when running ip
- /etc/iproute2/rt_tables.d
# udevadm reads this, and cloud-init uses udevadm to make
# sure networking is fully applied before it goes any
# further
- /etc/systemd/network
write:
# netplan generate writes config to each of these dirs
- /run/NetworkManager/conf.d
- /run/systemd/network
- /run/udev/rules.d
In addition, for netplan generate
to run successfully, I had to add netplan.io
to my stage-packages
, and set NETPLAN_GENERATE_PATH: $SNAP/lib/netplan/generate
in the cloud-init app’s environment. My snap is using a core18
base, so ideally I would be able to use the netplan that’s shipped in there.