Skip to content

Commit

Permalink
sanity-check: fallback when cache file is incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Mar 11, 2024
1 parent 3635a9d commit fa84f14
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions roles/sanity_check/tasks/subtasks/tags_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

- name: Ansible Tags | Load tags from cache if available
ansible.builtin.set_fact:
loaded_tags: "{{ (lookup('file', '/srv/git/sb/cache.json') | from_json)['/opt/sandbox']['tags'] + sanity_check_ansible_tags_extra }}"
loaded_tags: "{{ (lookup('file', '/srv/git/sb/cache.json') | from_json)['/opt/sandbox']['tags'] | default([]) + sanity_check_ansible_tags_extra }}"
when: cache_file_stat.stat.exists and (sanity_check_use_cache | bool)

- name: Ansible Tags | Get all available Ansible tags if cache is not available
Expand All @@ -23,12 +23,12 @@
| cut -d":" -f2 | awk '{sub(/\[/, "")sub(/\]/, "")}1' | sed -e 's/,//g' | xargs -n 1 | sort -u
register: available_ansible_tags
changed_when: false
when: loaded_tags is undefined
when: (loaded_tags is defined and ((loaded_tags | length) == (sanity_check_ansible_tags_extra | length))) or loaded_tags is undefined

- name: Ansible Tags | Set loaded tags from command if cache is not available
ansible.builtin.set_fact:
loaded_tags: "{{ available_ansible_tags.stdout_lines }}"
when: loaded_tags is undefined
when: (loaded_tags is defined and ((loaded_tags | length) == (sanity_check_ansible_tags_extra | length))) or loaded_tags is undefined

- name: Ansible Tags | Ensure valid Ansible tag(s) were provided
ansible.builtin.assert:
Expand Down

0 comments on commit fa84f14

Please sign in to comment.