network/tests/tasks/get_profile_stat.yml
Noriko Hosoi 34665b916d Cleaning up ansible-lint errors except '106', '303' and '403'
That is the following errors are fixed.
'206'  # Variables should have spaces before and after: {{ var_name }}
'208'  # File permissions unset or incorrect
'301'  # Commands should not change things if nothing needs doing
'305'  # Use shell only when shell functionality is required
'502'  # All tasks should be named
'601'  # Don't compare to literal True/False
'602'  # Don't compare to empty string

RHELPLAN-73471

Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
2021-04-15 20:53:53 +02:00

29 lines
966 B
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
- name: Initialize NM profile exist flag
set_fact: lsr_net_profile_exists=false
- name: stat profile file
stat:
get_attributes: false
get_checksum: false
get_mime: false
path: /etc/sysconfig/network-scripts/ifcfg-{{ profile }}
register: profile_stat
- name: Set NM profile exist flag based on the profile files
set_fact: lsr_net_profile_exists=true
when: profile_stat.stat.exists
# When certain profile is marked as absent but still up, the `nmcli connection`
# still show it with FILENAME starting with /run. Only consider profile exists
# when its FILENAME is in /etc folder
- name: Get NM profile info
shell: nmcli -f NAME,FILENAME connection show |grep {{ profile }} | grep /etc
register: nm_profile_exists
ignore_errors: yes
changed_when: false
- name: Set NM profile exist flag based on the nmcli output
set_fact: lsr_net_profile_exists=true
when: nm_profile_exists.rc == 0