Use file module instead of shell to remove roles
Replace the shell command that checks for and removes existing roles that were not git clones with an equivalent when clause/file module for improved idempotence when running the bootstrap-ansible script. Change-Id: Ibfef9c91bc95e75ee8a86debf718ce78454d46c5
This commit is contained in:
parent
8e94e4d322
commit
406078fddb
@ -19,14 +19,12 @@
|
||||
user: root
|
||||
tasks:
|
||||
- name: Remove target directory if required
|
||||
shell: |
|
||||
if [[ ! -d "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
|
||||
rm -rf "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}"
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
file:
|
||||
path: "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}"
|
||||
state: absent
|
||||
when:
|
||||
- item.scm == "git" or item.scm is undefined
|
||||
- "(item.path | default(role_path_default) ~ '/' ~ item.name | default(item.src | basename) ~ '/.git') is not directory"
|
||||
with_items: "{{ required_roles }}"
|
||||
|
||||
- name: Ensure the default roles directory exists
|
||||
|
Loading…
Reference in New Issue
Block a user