tripleo-quickstart-extras/roles/baremetal-prep-virthost/tasks/remove_ens3.yml
Sandeep Yadav c8b9b7ea2b collect only specific network facts
When running a playbook with become: true, it also runs the facts
module with sudo, so ansible_user_dir will have the value of the
root user, rather than the expected home directory of the
ansible_ssh_user.

This can create issues in further tasks as ansible cache is used,
variables like ansible_user_dir can persist when next tasks run.

~~~
fatal: [undercloud]: FAILED! => {"changed": false, "error":
"[Errno 13] Permission denied:
'/root/tripleo_undercloud_install.sh'", "msg": "Unable to
 output shell script /root/tripleo_undercloud_install.sh:
 [Errno 13] Permission denied: '/root/tripleo_undercloud_install.sh'"}
~~~

With this patch, We are modfying making two changes:-

1) Removing not required become: true as interfaces information can be
captured as normal user.

2) Modifying the setup: module to only collect particular network
fact subsets and not even the min subset.

Change-Id: Ib167b88b03f01bb8945c53cd000b5fcac85dd320
2022-04-26 15:47:28 +05:30

21 lines
476 B
YAML

---
- name: Discover if ens3 interface exists
setup:
gather_subset: "!all,!min,network"
register: net
- name: Check if ifcfg-ens3 exists
become: true
stat:
path: /etc/sysconfig/network-scripts/ifcfg-ens3
register: ens3_interface
- name: Remove the interface file
become: true
file:
path: /etc/sysconfig/network-scripts/ifcfg-ens3
state: absent
when:
- ens3_interface.stat.exists
- "'ens3' not in net.ansible_facts.ansible_interfaces"