tests: Adjust profile path if necessary

If /etc/network-scripts does no exist, NeworkManger uses
/etc/NetworkManager/system-connections to store profiles. Use this
directory if necessary.
This commit is contained in:
Till Maas 2019-04-16 12:55:09 +02:00
parent 5273f55166
commit f8d325f9fa
3 changed files with 28 additions and 16 deletions

View file

@ -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

View file

@ -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

View file

@ -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