Skip to content

Commit

Permalink
Merge pull request #152 from stackhpc/nm_remove_ens3
Browse files Browse the repository at this point in the history
Remove ens3 also from NetworkManager config
  • Loading branch information
markgoddard committed Oct 20, 2023
2 parents f331471 + c869d5c commit 6f341cd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
- interfaces_route_tables | length > 0
notify: Restart NetworkManager

# CentOS 8 cloud images ship with ifcfg files for ens3 and eth0. ifcfg-ens3
# CentOS 8/9 cloud images ship with ifcfg files for ens3 and eth0. ifcfg-ens3
# seems to be a relic from the image build process, and causes the network
# service to fail. ifcfg-eth0 is useful for most virtual machines, but if a
# cloud image is deployed on bare metal and eth0 is absent, the network service
# will fail. Remove these files if the interface does not exist or is not being
# configured.

- name: RedHat | remove invalid interface configuration
- name: RedHat | network-scripts remove invalid interface configuration
become: true
file:
path: "/etc/sysconfig/network-scripts/ifcfg-{{ item }}"
Expand All @@ -40,6 +40,20 @@
- item not in interfaces_bond_interfaces | map(attribute='bond_slaves') | flatten | list
with_items: "{{ interfaces_workaround_centos_remove }}"

- name: RedHat | network-manager remove invalid interface configuration
become: true
file:
path: "/etc/NetworkManager/system-connections/{{ item }}.nmconnection"
state: absent
when:
- item not in ansible_facts.interfaces
- item not in interfaces_ether_interfaces | map(attribute='device') | list
- item not in interfaces_bridge_interfaces | map(attribute='device') | list
- item not in interfaces_bridge_interfaces | map(attribute='ports') | flatten | list
- item not in interfaces_bond_interfaces | map(attribute='device') | list
- item not in interfaces_bond_interfaces | map(attribute='bond_slaves') | flatten | list
with_items: "{{ interfaces_workaround_centos_remove }}"

# When using NetworkManager with system-connections store, existing ifcfg files
# need to be removed, otherwise they shadow our nmconnection files. We do this
# only for interfaces that we manage in this role.
Expand Down

0 comments on commit 6f341cd

Please sign in to comment.