Search code examples
ansiblecentos7rhel7

recommended way to configure a centos-7 host with static network settings via ansible?


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 in the transition from rhel-6 to rhel-7 (namely, network-manager by default, consistent device naming by default from the kernel, 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 with ansible using the ansible_default_ipv4 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 so far is great -- but 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 ...


Solution

  • Whoops -- this question belongs on serverfault not stackoverflow ...

    https://serverfault.com/questions/666579/recommended-way-to-configure-a-centos-7-network-interface-with-static-settings-v?noredirect=1#comment814300_666579