From 726b31f5e383e0fb41dbc9719d98215dd966d728 Mon Sep 17 00:00:00 2001 From: Hamza Date: Wed, 25 Sep 2024 17:02:21 +0200 Subject: [PATCH] Give the user the possibility to deactivate dependency check (#911) * fix typo * Give the user the possibility to deactivate dependency check * Create dependency_check_control.yml --------- Co-authored-by: Tom Page Co-authored-by: Tom Page --- .../fragments/dependency_check_control.yml | 4 ++ roles/meta_dependency_check/README.md | 2 +- roles/meta_dependency_check/defaults/main.yml | 3 ++ roles/meta_dependency_check/tasks/main.yml | 42 ++++++++++++------- 4 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 changelogs/fragments/dependency_check_control.yml create mode 100644 roles/meta_dependency_check/defaults/main.yml diff --git a/changelogs/fragments/dependency_check_control.yml b/changelogs/fragments/dependency_check_control.yml new file mode 100644 index 000000000..68ac9e1f1 --- /dev/null +++ b/changelogs/fragments/dependency_check_control.yml @@ -0,0 +1,4 @@ +--- +minor_changes: + - Add ability to disable dependency check +... diff --git a/roles/meta_dependency_check/README.md b/roles/meta_dependency_check/README.md index c47f5d5ae..73fdc32c4 100644 --- a/roles/meta_dependency_check/README.md +++ b/roles/meta_dependency_check/README.md @@ -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 diff --git a/roles/meta_dependency_check/defaults/main.yml b/roles/meta_dependency_check/defaults/main.yml new file mode 100644 index 000000000..5660c9b6c --- /dev/null +++ b/roles/meta_dependency_check/defaults/main.yml @@ -0,0 +1,3 @@ +--- +controller_dependency_check: true +... diff --git a/roles/meta_dependency_check/tasks/main.yml b/roles/meta_dependency_check/tasks/main.yml index 32d73989b..eec538e80 100644 --- a/roles/meta_dependency_check/tasks/main.yml +++ b/roles/meta_dependency_check/tasks/main.yml @@ -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" ...