Skip to content

Commit

Permalink
Give the user the possibility to deactivate dependency check
Browse files Browse the repository at this point in the history
  • Loading branch information
w4hf committed Sep 21, 2024
1 parent e6a2296 commit bca1a05
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
3 changes: 3 additions & 0 deletions roles/meta_dependency_check/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
controller_dependency_check: true
...
42 changes: 26 additions & 16 deletions roles/meta_dependency_check/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
---
# tasks file for meta_dependency_check

- name: Check awx.awx is installed
ansible.builtin.command: ansible-galaxy collection verify awx.awx
failed_when: false
changed_when: false
register: upstream_dep
- name: Print dependency check status
ansible.builtin.debug:
msg: "{{ controller_dependency_check | bool | ternary(__depdency_check_active_msg, __depdency_check_inactive_msg) }}"
vars:
__depdency_check_active_msg: 'Dependency check is active. Required collections presence will be verified.'
__depdency_check_inactive_msg: 'Dependency check is deactivated. Required collections presence will not be verified. This might cause failure in the next tasks.'

- name: Check ansible.controller is installed
ansible.builtin.command: ansible-galaxy collection verify ansible.controller
failed_when: false
changed_when: false
register: downstream_dep
- name: Dependency check block
when: controller_dependency_check | bool
block:
- name: Check awx.awx is installed
ansible.builtin.command: ansible-galaxy collection verify awx.awx
failed_when: false
changed_when: false
register: upstream_dep

- name: Ensure one is installed
ansible.builtin.fail:
msg: One of awx.awx or ansible.controller must be installed
when:
- "'ERROR!' in upstream_dep.stderr"
- "'ERROR!' in downstream_dep.stderr"
- name: Check ansible.controller is installed
ansible.builtin.command: ansible-galaxy collection verify ansible.controller
failed_when: false
changed_when: false
register: downstream_dep

- name: Ensure one is installed
ansible.builtin.fail:
msg: One of awx.awx or ansible.controller must be installed
when:
- "'ERROR!' in upstream_dep.stderr"
- "'ERROR!' in downstream_dep.stderr"

...

0 comments on commit bca1a05

Please sign in to comment.