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

[PR #2278/96c22102 backport][stable-4.10] Update CI workflow for collection testing #2281

Open
wants to merge 1 commit into
base: stable-4.10
Choose a base branch
from
Open
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
17 changes: 10 additions & 7 deletions .github/workflows/ci_automation_hub_collection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,25 @@ jobs:
- name: install ansible
run: pip3 install ansible

- name: Checkout the galaxy collection
- name: Checkout the ansible_hub collection
uses: actions/checkout@v4
with:
repository: ansible/galaxy_collection
path: galaxy_collection
repository: ansible-collections/ansible_hub
path: ansible_hub

- name: copy galaxy.yml.j2 to ansible_hub
run: |
cp dev/galaxy_collection_plays/galaxy.yml.j2 ansible_hub

- name: Build and install the collection
working-directory: galaxy_collection
working-directory: ansible_hub
run: |
# The ansible.cfg defined in the collection repository might break the test. We want the same variables for installation and running.
rm -f ansible.cfg
rm -f galaxy.yml
mv .github/files/galaxy.yml.j2 .
ansible all -i localhost, -c local -m template -a "src=galaxy.yml.j2 dest=galaxy.yml" -e collection_namespace=galaxy -e collection_name=galaxy -e collection_version=1.0.0 -e collection_repo=https://github.com/ansible/automation_hub_collection
ansible all -i localhost, -c local -m template -a "src=galaxy.yml.j2 dest=galaxy.yml" -e collection_namespace=ansible -e collection_name=hub -e collection_version=1.0.0 -e collection_repo=https://github.com/ansible-collections/ansible_hub
ansible-galaxy collection build -vvv
ansible-galaxy collection install galaxy-galaxy-1.0.0.tar.gz -vvv
ansible-galaxy collection install ansible-hub-1.0.0.tar.gz -vvv

#- name: Spin up a standalone galaxy_ng installation
# run: |
Expand Down
87 changes: 39 additions & 48 deletions dev/galaxy_collection_plays/content.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,79 @@
connection: local
gather_facts: false
collections:
- galaxy.galaxy
- ansible.hub

pre_tasks:
- name: Include variables
ansible.builtin.include_vars:
file: vars.yml

tasks:
- name: Authenticate and retrieve API token
ah_token:
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Create the automate namespace
ah_namespace:
ansible.hub.ah_namespace:
name: automate
company: Automator Inc.
email: [email protected]
description: The namespace for all things automation
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Rename automate namespace to automator
ah_namespace:
ansible.hub.ah_namespace:
name: automate
new_name: automator
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Delete the automator namespace
ah_namespace:
ansible.hub.ah_namespace:
state: absent
name: automator
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Ensure there is a galaxy namespace
ah_namespace:
name: galaxy
- name: Ensure there is a ansible namespace
ansible.hub.ah_namespace:
name: ansible
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"
state: present

- name: Upload the galaxy collection to the galaxy namespace
ah_collection:
namespace: galaxy
name: galaxy
- name: Upload the ansible hub collection to the ansible namespace
ansible.hub.ah_collection_upload:
path: "{{ ah_artifact_runner_absolute_path }}"
version: "1.0.0"
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Approve the galaxy collection
ah_approval:
namespace: galaxy
name: galaxy
- name: Approve the ansible hub collection
ansible.hub.ah_approval:
namespace: ansible
name: hub
version: "1.0.0"
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"
async: 600
poll: 10

- name: Delete the galaxy collection
ah_collection:
- name: Delete the ansible hub collection
ansible.hub.ah_collection:
state: absent
namespace: galaxy
name: galaxy
namespace: ansible
name: hub
version: "1.0.0"
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Deauthenticate
ah_token:
state: absent
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"
10 changes: 5 additions & 5 deletions dev/galaxy_collection_plays/ee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
connection: local
gather_facts: false
collections:
- galaxy.galaxy
- ansible.hub

pre_tasks:
- name: Include variables
Expand All @@ -13,13 +13,13 @@

tasks:
- name: Add redhat.io registry
ah_ee_registry:
ansible.hub.ah_ee_registry:
name: redhat
url: registry.redhat.io
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"

# Can be uncommented after AAH-2607 is resolved.
#
Expand Down Expand Up @@ -53,10 +53,10 @@
# ah_path_prefix: "{{ ah_path_prefix }}"

- name: Delete the redhat.io registry
ah_ee_registry:
ansible.hub.ah_ee_registry:
name: redhat
state: absent
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"
30 changes: 30 additions & 0 deletions dev/galaxy_collection_plays/galaxy.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
authors:
- Sean Sullivan @sean-m-sullivan
- Tom Page @Tompage1994
- David Danielsson @djdanielsson
dependencies: {}
description: Ansible content that interacts with the Ansible Automation Hub or Galaxy NG API.
documentation: https://github.com/redhat-cop/ah_configuration/blob/master/README.md
license:
- GPL-3.0-only
namespace: {{ collection_namespace }}
name: {{ collection_name }}
version: {{ collection_version }}
readme: README.md
repository: {{ collection_repo }}
issues: {{ collection_repo }}/issues
tags:
- cloud
- infrastructure
- galaxy
- ansible
- galaxy
- automation
build_ignore:
- tools
- setup.cfg
- galaxy.yml.j2
- template_galaxy.yml
- '*.tar.gz'
...
30 changes: 10 additions & 20 deletions dev/galaxy_collection_plays/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,31 @@
connection: local
gather_facts: false
collections:
- galaxy.galaxy
- ansible.hub

pre_tasks:
- name: Include variables
ansible.builtin.include_vars:
file: vars.yml

tasks:
- name: Authenticate and retrieve API token
ah_token:
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Configure community repository
ah_repository:
ansible.hub.collection_remote:
name: community
url: https://galaxy.ansible.com/api/
requirements:
- community.docker
- geerlingguy.k8s
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Sync community repository
ah_repository_sync:
ansible.hub.collection_repository_sync:
name: community
wait: false
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Deauthenticate
ah_token:
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: "{{ ah_validate_certs }}"
34 changes: 17 additions & 17 deletions dev/galaxy_collection_plays/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
connection: local
gather_facts: false
collections:
- galaxy.galaxy
- ansible.hub

pre_tasks:
- name: Include variables
Expand All @@ -13,15 +13,15 @@

tasks:
- name: Create a developers group
ah_group:
ansible.hub.ah_group:
name: developers
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Add 3 new users who are developers
ah_user:
ansible.hub.ah_user:
username: "dev_{{ item }}"
password: password!@3w6$%
first_name: Developer
Expand All @@ -31,35 +31,35 @@
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"
loop:
- red
- green
- blue

- name: Create an executives group
ah_group:
ansible.hub.ah_group:
name: executives
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Create an omnipotent role with all permissions
ah_role:
ansible.hub.ah_role:
name: galaxy.omnipotent
description: Manage anything and everything
perms: all
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"

# TODO: Add a test that permissions/roles can be added to a group after
# https://github.com/ansible/galaxy_collection/issues/179 is resolved.

- name: Create new executive users
ah_user:
ansible.hub.ah_user:
username: "{{ item }}"
password: executive!@3w6$%
is_superuser: true
Expand All @@ -70,38 +70,38 @@
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"
loop:
- ceo
- cfo
- cto

- name: Delete the red developer
ah_user:
ansible.hub.ah_user:
state: absent
username: dev_red
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"

- name: Delete the developers and executives groups
ah_group:
ansible.hub.ah_group:
state: absent
name: "{{ item }}"
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"
loop:
- developers
- executives

- name: Delete the omnipotent role
ah_role:
ansible.hub.ah_role:
state: absent
name: galaxy.omnipotent
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: "{{ ah_validate_certs }}"
Loading
Loading