Skip to content

Commit

Permalink
add new CI workflow to test against the automation hub collection (#1795
Browse files Browse the repository at this point in the history
)

* add new CI workflow to test against the automation hub collection
* remove installation of docker-compose
* add changelog

Issue: AAH-2419

Signed-off-by: EamonTracey <[email protected]>
  • Loading branch information
EamonTracey authored Jul 20, 2023
1 parent 96d4ff8 commit 305b0a3
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci_automation_hub_collection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: Automation Hub Collection CI
on:
pull_request:
branches:
- "*"
paths-ignore:
- "CHANGES/**"
- "docs/**"
- "mkdocs.yml"
push:
branches:
- "*"
workflow_dispatch:

jobs:
automation_hub_collection:
runs-on: ubuntu-latest
steps:
- name: Checkout galaxy_ng
uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Checkout the automation hub collection
uses: actions/checkout@v3
with:
repository: ansible/automation_hub_collection
path: automation_hub_collection

- name: Build and install the collection
working-directory: automation_hub_collection
run: |
ansible all -i localhost, -c local -m template -a "src=galaxy.yml.j2 dest=galaxy.yml" -e collection_namespace=ansible -e collection_name=automation_hub -e collection_version=1.0.0 -e collection_repo=https://github.com/ansible/automation_hub_collection
ansible-galaxy collection build -vvv
ansible-galaxy collection install ansible-automation_hub-1.0.0.tar.gz -vvv
- name: Spin up a standalone galaxy_ng installation
run: |
echo "COMPOSE_PROFILE=standalone" > .compose.env
echo "DEV_SOURCE_PATH=galaxy_ng" >> .compose.env
make docker/all
./compose up -d
pip3 install --upgrade requests pyyaml
python3 dev/common/poll.py
- name: Test the user playbook
run: ansible-playbook dev/ah_collection_plays/user.yml -vvv

- name: Test the content playbook
run: ansible-playbook dev/ah_collection_plays/content.yml -vvv

- name: Test the repo playbook
run: ansible-playbook dev/ah_collection_plays/repo.yml -vvv

- name: Test the ee playbook
run: ansible-playbook dev/ah_collection_plays/ee.yml -vvv
1 change: 1 addition & 0 deletions CHANGES/2419.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New CI workflow to test against the automation hub collection
89 changes: 89 additions & 0 deletions dev/ah_collection_plays/content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
- name: Galaxy + AH Collection Tests for Content Automation
hosts: localhost
connection: local
gather_facts: false
collections:
- ansible.automation_hub

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

tasks:
- name: Authenticate and retrieve API token
ansible.automation_hub.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
ansible.automation_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 }}"

- name: Rename automate namespace to automator
ansible.automation_hub.ah_namespace:
name: automate
new_name: automator
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Delete the automator namespace
ansible.automation_hub.ah_namespace:
state: absent
name: automator
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Ensure there is an ansible namespace
ansible.automation_hub.ah_namespace:
name: ansible
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Upload the automation hub collection to the ansible namespace
ansible.automation_hub.ah_collection:
namespace: ansible
name: automation_hub
path: "{{ ah_artifact_runner_absolute_path }}"
version: "1.0.0"
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Approve the automation hub collection
ansible.automation_hub.ah_approval:
namespace: ansible
name: automation_hub
version: "1.0.0"
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

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

- name: Deauthenticate
ansible.automation_hub.ah_token:
state: absent
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
60 changes: 60 additions & 0 deletions dev/ah_collection_plays/ee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: Galaxy + AH Collection Tests for Execution Environment Automation
hosts: localhost
connection: local
gather_facts: false
collections:
- ansible.automation_hub

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

tasks:
- name: Add redhat.io registry
ansible.automation_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 }}"

- name: Index redhat.io registry
ansible.automation_hub.ah_ee_registry_index:
name: redhat
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Update aap22ee29rhel8 ee repository
ansible.automation_hub.ah_ee_repository:
name: ansible-automation-platform-22/ee-29-rhel8
description: AAP RHEL execution environment
readme: |
# RHEL execution environment
* Contains ansible
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Delete the aap22ee29rhel8 repository
ansible.automation_hub.ah_ee_repository:
name: ansible-automation-platform-22/ee-29-rhel8
state: absent
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Delete the redhat.io registry
ansible.automation_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 }}"
44 changes: 44 additions & 0 deletions dev/ah_collection_plays/repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- name: Galaxy + AH Collection Tests for Repo Automation
hosts: localhost
connection: local
gather_facts: false
collections:
- ansible.automation_hub

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

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

- name: Configure community repository
ansible.automation_hub.ah_repository:
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 }}"

- name: Sync community repository
ansible.automation_hub.ah_repository_sync:
name: community
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"

- name: Deauthenticate
ansible.automation_hub.ah_token:
ah_host: "{{ ah_host }}"
ah_token: "{{ ah_token }}"
ah_path_prefix: "{{ ah_path_prefix }}"
107 changes: 107 additions & 0 deletions dev/ah_collection_plays/user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
- name: Galaxy + AH Collection Tests for User Automation
hosts: localhost
connection: local
gather_facts: false
collections:
- ansible.automation_hub

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

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

- name: Add 3 new users who are developers
ansible.automation_hub.ah_user:
username: "dev_{{ item }}"
password: password!@3w6$%
first_name: Developer
last_name: "{{ item | capitalize }}"
groups:
- developers
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
loop:
- red
- green
- blue

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

- name: Create an omnipotent role with all permissions
ansible.automation_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 }}"

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

- name: Create new executive users
ansible.automation_hub.ah_user:
username: "{{ item }}"
password: executive!@3w6$%
is_superuser: true
email: "{{ item }}@redhat.com"
groups:
- executives
- developers
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
loop:
- ceo
- cfo
- cto

- name: Delete the red developer
ansible.automation_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 }}"

- name: Delete the developers and executives groups
ansible.automation_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 }}"
loop:
- developers
- executives

- name: Delete the omnipotent role
ansible.automation_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 }}"
5 changes: 5 additions & 0 deletions dev/ah_collection_plays/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ah_host: http://localhost:5001
ah_username: iqe_admin
ah_password: redhat
ah_path_prefix: automation-hub
ah_artifact_runner_absolute_path: /home/runner/work/galaxy_ng/galaxy_ng/automation_hub_collection/ansible-automation_hub-1.0.0.tar.gz

0 comments on commit 305b0a3

Please sign in to comment.