recommended way to statically configure network interfaces on centos-7 with ansible?

732 views
Skip to first unread message

breatheoften

unread,
Feb 10, 2015, 4:34:12 PM2/10/15
to ansible...@googlegroups.com

I'm new to ansible and a little googling hasn't lead me quickly towards the right solution to my question.

What's the 'with the grain' way to assign static network settings to a centos-7 host with ansible. I feel like this must be a pretty common need -- and there must be a lot of people with questions about the right approach to take after all the changes to the network configuration system that comes with transitioning from rhel-6 to rhel-7 (namely: network-manager by default, consistent device naming from the kernel by default, systemd).

Prior to ansible I had been uninstalling network-manager and manually configuring hosts via /etc/init.d/network-scripts/ifcfg-* files -- I think I could do the same thing -- generating the correct ifcfg-* file using the ansible_default_ipv4['interface'] fact ...?

    "ansible_default_ipv4": {
        "address": <snip>,
        "alias": "enp3s0",
        "gateway": <snip>,
        "interface": "enp3s0",
        "macaddress": <snip>,
        "mtu": 1500,
        "netmask": "255.255.255.128",
        "network": <snip>,
        "type": "ether"
    }

Ansible far is so great and for this I want to make sure I'm not going unnecessarily against the ansible grain. I'm willing to not uninstall network-manager if there are good ways to manage the network-manager mediated interface configuration through ansible ...


Giovanni Tirloni

unread,
Feb 11, 2015, 5:05:01 AM2/11/15
to ansible...@googlegroups.com
On Tue, 10 Feb 2015 13:34 -0800, breatheoften <cohe...@gmail.com>
wrote:
> Prior to ansible I had been uninstalling network-manager and manually
> configuring hosts via /etc/init.d/network-scripts/ifcfg-* files -- I
> think
> I could do the same thing -- generating the correct ifcfg-* file using
> the
> ansible_default_ipv4['interface'] fact ...?

Hi Ben,

Yes, I believe that would be an acceptable solution since I don't see
any module for that specifically yet.

You could use the template module to deploy the ifcfg-* files based on
the variables, as you suggested.

http://docs.ansible.com/template_module.html
http://docs.ansible.com/service_module.html

Regards,
Giovanni
Reply all
Reply to author
Forward
0 new messages