Ansible handler: restart networking


Hello all,

relatively new to ansible, and so far working my way through successfully provisioning a cumulus switch with Ansible and the modules that are now part of Core.

Here's where i'm running into a snag:

all of the examples I see in Cumulus github and elsewhere use for example the "cl_interface" module with a handler to restart networking -- which is literally defined to restart the networking service.

as I recall, this is a destructive event in Cumulus and would result in downtime if one were to make an interface change and re-configure the switch using the ansible playbook. Is that not the case? That would not be ideal...

My understanding one should use 'ifreload -a' when making a change to an interface configuration, as this was non-destructive.

Currently in my playbook my "restart networking" handler I have it set to run 'ifreload -a' but that does not seem to be working presently -- perhaps because I need to first restart networking so that it will include the interface config files created by the "cl_interface" module.

Just curious what others are doing in the field here.

Thanks,

Will

3 replies

Hi Will,

You're right 'ifreload -a' is the preferred method over a full service networking restart. The example handlers should be using 'ifreload -a' or the Ansible service module with 'state=reloaded'. One reason the configurations might not get applied in the /etc/network/interfaces.d/ directory is if those files are not being sourced in the /etc/network/interfaces file. For example in the /etc/network/interfaces file you would have a line:
source /etc/network/interfaces.d/*
which would include and apply all the module configured files.

Shoot me a link if you have a second to the examples that are using restart and I'll clean them up.

Thanks!
-Jason
I realized after my post that I was taking 'reloaded' to be the same as 'restarted' in the examples. I went back and looked at one such example and it indeed says 'reloaded' instead.

my interfaces config has the source statement in it. i'm curious if a net-new config-push requires a 'reloaded' before 'ifreload -a' would work -- i've since changed my playbooks to use the service module with 'reloaded' state and so far so good.

Anything beyond the simplest Ansible playbook thus far has been a chore but working through it, and still by no means a linux pro, so it's taking time to wrap my brain around everything. So far have interfaces, Bridges, bonds, etc all configured, and copying over Quagga config. Now for the rest of the linux stuff like DNS, NTP, usernames, etc.

Thanks,

Will
I wrote up a couple posts on some of the Ansible basics for the switch you could use as examples: https://community.cumulusnetworks.com/cumulus/topics/ansible-switch-basics-time-zone-and-ntp https://community.cumulusnetworks.com/cumulus/topics/ansible-switch-basics-apt-setup Also for more routing configs and more Ansible ideas you can look over our github repos: https://github.com/CumulusNetworks Specifically for Ansible there is a nice demo for deploying BGP in a spine/leaf network: https://github.com/CumulusNetworks/cldemo-automation-ansible Hope those help. Jason

Reply