From f551e07637c36ecca7b5b48451a3659caba6dd5b Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Thu, 13 Aug 2020 10:37:12 -0700 Subject: [PATCH] base: use linux system roles network role for hosts that define network_connections This is VASTLY better than the hack we have in base now to try and setup ifcfg files. It uses a standard role that has lots of options and does the right thing with NetworkManager. Ideally we would switch everything to this, but lets try it here first to see. It should work with bridges, etc as well. Signed-off-by: Kevin Fenzi --- .../buildhw-a64-01.iad2.fedoraproject.org | 23 +++++++++++++++++++ roles/base/meta/main.yml | 1 + roles/base/tasks/main.yml | 7 +++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/inventory/host_vars/buildhw-a64-01.iad2.fedoraproject.org b/inventory/host_vars/buildhw-a64-01.iad2.fedoraproject.org index 8a88c96a45..47532ede18 100644 --- a/inventory/host_vars/buildhw-a64-01.iad2.fedoraproject.org +++ b/inventory/host_vars/buildhw-a64-01.iad2.fedoraproject.org @@ -3,3 +3,26 @@ gw: 10.3.170.254 eth1_ip: 10.3.170.121 eth1_ipv4_gw: 10.3.170.254 datacenter: iad2 + +network_connections: + - name: eth0 + state: down + type: ethernet + - name: eth1 + state: up + type: ethernet + autoconnect: yes + ip: + address: 10.3.170.121/24 + gateway4: 10.3.170.254 + dns: + - 10.3.163.33 + - 10.3.163.34 + dns_search: + - iad2.fedoraproject.org + - fedoraproject.org + dhcp4: no + auto6: no + - name: eth2 + state: down + type: ethernet diff --git a/roles/base/meta/main.yml b/roles/base/meta/main.yml index 8fc4b3b56f..316aceb00e 100644 --- a/roles/base/meta/main.yml +++ b/roles/base/meta/main.yml @@ -1,5 +1,6 @@ --- dependencies: + - { role: linux-system-roles.network, when: network_connections is defined } - { role: basessh } - { role: chrony } - { role: dnf-automatic } diff --git a/roles/base/tasks/main.yml b/roles/base/tasks/main.yml index 24d4f59c23..97f00b0fd5 100644 --- a/roles/base/tasks/main.yml +++ b/roles/base/tasks/main.yml @@ -29,7 +29,7 @@ # XXX fixme # a datacenter 'fact' from setup - name: /etc/resolv.conf copy: src={{ item }} dest=/etc/resolv.conf - when: not nm_controlled_resolv + when: not nm_controlled_resolv or not network_connections is defined with_first_found: - "{{ resolvconf }}" - resolv.conf/{{ inventory_hostname }} @@ -59,7 +59,7 @@ ini_file: dest=/etc/NetworkManager/NetworkManager.conf section=main option=dns value=none notify: - restart NetworkManager - when: ansible_distribution_major_version|int >=7 and ansible_distribution == 'RedHat' and nmclitest is success and ( not ansible_ifcfg_blocklist) and not nm_controlled_resolv + when: ansible_distribution_major_version|int >=7 and ansible_distribution == 'RedHat' and nmclitest is success and ( not ansible_ifcfg_blocklist) and not nm_controlled_resolv and ( not network_connections is defined ) tags: - config - resolvconf @@ -70,7 +70,7 @@ ini_file: dest=/etc/NetworkManager/NetworkManager.conf section=main option=dns value=none notify: - restart NetworkManager - when: ansible_distribution_major_version|int >=29 and ansible_distribution == 'Fedora' and nmclitest is success and ( not ansible_ifcfg_blocklist) and not nm_controlled_resolv + when: ansible_distribution_major_version|int >=29 and ansible_distribution == 'Fedora' and nmclitest is success and ( not ansible_ifcfg_blocklist) and not nm_controlled_resolv and ( not network_connections is defined ) tags: - config - resolvconf @@ -106,6 +106,7 @@ - nmclitest is success - not ansible_ifcfg_blocklist - ansible_ifcfg_allowlist is not defined or item in ansible_ifcfg_allowlist + - not network_connections is defined tags: - config - ifcfg