Skip to content

Commit

Permalink
Add meta dependency check role (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tompage1994 authored Sep 5, 2024
1 parent 031cfec commit d97decb
Show file tree
Hide file tree
Showing 40 changed files with 177 additions and 45 deletions.
7 changes: 4 additions & 3 deletions roles/ad_hoc_command/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/ad_hoc_command_cancel/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/applications/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/bulk_host_create/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/bulk_job_launch/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/credential_input_sources/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/credential_types/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/credentials/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/execution_environments/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/filetree_create/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ galaxy_info:
collections:
- ansible.controller

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/filetree_read/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ galaxy_info:
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/groups/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/hosts/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/instance_groups/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/instances/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/inventories/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/inventory_source_update/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/inventory_sources/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/job_launch/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/job_templates/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/jobs_cancel/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/labels/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/license/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
11 changes: 11 additions & 0 deletions roles/meta_dependency_check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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.

## License

[GPL-3.0](https://github.com/redhat-cop/controller_configuration#licensing)

## Author

[Tom Page](https://github.com/Tompage1994)
55 changes: 55 additions & 0 deletions roles/meta_dependency_check/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
galaxy_info:
role_name: meta_dependency_check
author: Tom page
description: "An Ansible Role to check collection dependencies."
company: "Red Hat"

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker

# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: GPL-3.0-or-later

min_ansible_version: 2.15.0

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99

galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
...
23 changes: 23 additions & 0 deletions roles/meta_dependency_check/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# 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: 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"

...
1 change: 1 addition & 0 deletions roles/meta_dependency_check/tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
7 changes: 7 additions & 0 deletions roles/meta_dependency_check/tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Test dependency check
hosts: localhost
roles:
- meta_dependency_check

...
1 change: 1 addition & 0 deletions roles/notification_templates/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/object_diff/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ galaxy_info:
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/organizations/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/project_update/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/projects/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/roles/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/schedules/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
7 changes: 4 additions & 3 deletions roles/settings/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ collections:
- ansible.controller
- awx.awx

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/teams/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/users/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
1 change: 1 addition & 0 deletions roles/workflow_job_templates/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ dependencies:
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
- role: global_vars
- role: meta_dependency_check
...
Loading

0 comments on commit d97decb

Please sign in to comment.