debops / ansible-ifupdown

Manage network interface configuration in /etc/network/interfaces
GNU General Public License v3.0
25 stars 14 forks source link

Delete artifacts of interfaces not managed any more #72

Open murinicanor opened 7 years ago

murinicanor commented 7 years ago

if i create a bridge using debops.ifupdown

        ifupdown__interfaces: {                                                                                                              
          'foobar': {
            type: bridge,
            inet: 'static',
            address: '10.2.2.2/25' }
          }

and later remove that bridge, the interface-file does not get removed from /etc/network/interfaces.config.d (and /etc/network/interfaces.d). maybe the directory should be purged before interface-files are being created

drybjed commented 7 years ago

The debops.ifupdown role is designed to be used as a dependency by other Ansible/DebOps roles. It means, that there might be configuration in the /etc/network/interfaces.d/ directory which is not entirely known by the role at any given moment, and that's why the role does not clear these directories on each run.

If you want to remove an interface from a host correctly, you first need to mark it for removal by Ansible. Don't remove it from inventory, but add state: "absent" key to its configuration; that way Ansible will know that it should remove the interface on the next run. If you remove the configuration of a given interface from the inventory, Ansible doesn't know about that interface at all, and doesn't touch it.