title: How to configure network interfaces on Ubuntu and CentOS with Ansible variables?
body: <p>I am searching for an OS-independent version of <a href="https://github.com/linux-system-roles/network" rel="nofollow noreferrer">https://github.com/linux-system-roles/network</a>:</p>
  <ul>
  <li>It should work for Debian&gt;=10, Ubuntu&gt;=18.04 and CentOS&gt;=8</li>
  <li>It should support interface bonding</li>
  <li>The network interfaces should be configurable with host variables, similar to this:</li>
  </ul>
  <pre class="lang-yaml prettyprint-override"><code>- name: NIC Configuration 
    hosts: webservers
    vars:
      network_connections: 
        - name: ens4
          type: ethernet
          ip:
            address:
              - 172.25.250.30/24
    roles:
      - rhel-system-roles.network
  </code></pre>
  <p>Are there any roles like this?</p>
  <p>I do know the <a href="https://docs.ansible.com/ansible/2.10/collections/community/general/nmcli_module.html" rel="nofollow noreferrer">community.general.nmcli</a> module, however, the example there looks quite complicated: ansible-nmcli does not allow to configure the network via variables, instead one has to set the role parameters by hand.</p>