Skip to content

Commit

Permalink
Give the user the possibility to deactivate dependency check (#911)
Browse files Browse the repository at this point in the history
* fix typo

* Give the user the possibility to deactivate dependency check

* Create dependency_check_control.yml

---------

Co-authored-by: Tom Page <[email protected]>
Co-authored-by: Tom Page <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2024
1 parent ce41d8e commit 726b31f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/dependency_check_control.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- Add ability to disable dependency check
...
2 changes: 1 addition & 1 deletion roles/meta_dependency_check/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# infra.controller_configuration.meta_dependency_check

This role is designed to eb run before any roles in this collection to check that the underlying awx.awx or ansible.controller collection is installed. This is a dependency of together roles and does not need to be explicitly called.
This role is designed to be run before any roles in this collection to check that the underlying awx.awx or ansible.controller collection is installed. This is a dependency of together roles and does not need to be explicitly called.

## License

Expand Down
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 726b31f

Please sign in to comment.