How to edit /etc/network/interfaces (with Ansible) correctly

Hello Proxmox community,

I'm currently trying to manage network interfaces in Proxmox VE using Ansible, and I'm running into a problem where the changes I make don't persist as I would expect. I have read the official Proxmox documentation and am aware that Proxmox VE does not write changes directly to /etc/network/interfaces, but rather uses a temporary file /etc/network/interfaces.new, which allows for bulk changes and the ability to ensure correctness before applying.

However, the same documentation suggests that if manual changes are made directly to the /etc/network/interfaces file, those changes can be applied by running ifreload -a. I have tried this method, but after making direct changes to the file, it seems that Proxmox VE still wants to overwrite it with the contents of /etc/network/interfaces.new, even after using ifreload -a.

I would like to clarify the correct procedure for modifying network interfaces with Ansible in this context. Should I edit /etc/network/interfaces directly, or should I instead modify /etc/network/interfaces.new and then somehow force a reload?
 
Applying changes to
/etc/network/interfaces directly is one of the recommended way of doing changes, make sure you run ifreload -a afterwards.
 
Last edited:
Note that we only write changes to /etc/network/interfaces.new when changes are made via the REST API or the web ui, those were probably a leftover from somewhere else.