diff --git a/tests/tasks/assert-profile_absent.yml b/tests/tasks/assert-profile_absent.yml index 2695041..e7a6fde 100644 --- a/tests/tasks/assert-profile_absent.yml +++ b/tests/tasks/assert-profile_absent.yml @@ -1,13 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- name: set variable - set_fact: - profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }} -- name: stat profile file - stat: - path: "{{ profile_path }}" - register: profile_stat - +- include: get-profile_stat.yml - name: "assert that profile '{{ profile }}' is absent" assert: that: not profile_stat.stat.exists diff --git a/tests/tasks/assert-profile_present.yml b/tests/tasks/assert-profile_present.yml index 57a9f4b..c84c080 100644 --- a/tests/tasks/assert-profile_present.yml +++ b/tests/tasks/assert-profile_present.yml @@ -1,13 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause --- -- name: set variable - set_fact: - profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }} -- name: stat profile file - stat: - path: "{{ profile_path }}" - register: profile_stat - +- include: get-profile_stat.yml - name: "assert that profile '{{ profile }}' is present" assert: that: profile_stat.stat.exists diff --git a/tests/tasks/get-profile_stat.yml b/tests/tasks/get-profile_stat.yml new file mode 100644 index 0000000..bd33a32 --- /dev/null +++ b/tests/tasks/get-profile_stat.yml @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +--- +- name: "Get stat for network-scripts" + stat: + get_attributes: false + get_checksum: false + get_mime: false + path: "/etc/sysconfig/network-scripts" + register: network_scripts_stat +- name: Set profile path (network-scripts) + set_fact: + profile_path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }} + when: + - network_scripts_stat.stat.exists +- name: Set profile path (NetworkManager system-connections) + set_fact: + profile_path: /etc/NetworkManager/system-connections/{{ profile }} + when: + - not network_scripts_stat.stat.exists +- name: stat profile file + stat: + get_attributes: false + get_checksum: false + get_mime: false + path: "{{ profile_path }}" + register: profile_stat