Use stat module instead of "test -s"

Use native ansible functionality to get information about file

Change-Id: I7888971e817e4df45a8309be1be5dbde4d6d5171
This commit is contained in:
Sergii Golovatiuk 2020-11-26 01:31:58 +01:00 committed by Jose Luis Franco
parent 8e81dd0460
commit b118353070
1 changed files with 7 additions and 4 deletions

View File

@ -261,10 +261,13 @@ outputs:
register: os_net_config_need_upgrade
when: step|int == 3
- name: Check that os-net-config has configuration
shell: test -s /etc/os-net-config/config.json
register: os_net_config_has_config
failed_when: false
when: step|int == 3
stat:
path: /etc/os-net-config/config.json
get_attributes: false
get_checksum: false
get_mime: false
register: stat_config_json
- block:
- name: Upgrade os-net-config
package: name=os-net-config state=latest
@ -276,7 +279,7 @@ outputs:
when:
- step|int == 3
- os_net_config_need_upgrade.stdout
- os_net_config_has_config.rc == 0
- stat_config_json.stat.exists
# Exclude ansible until https://github.com/ansible/ansible/issues/56636
# is available
- name: Update all packages