Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give the user the possibility to deactivate dependency check #911

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"

...
Loading