Skip to content

Commit

Permalink
Collection Integration Tests
Browse files Browse the repository at this point in the history
No-Issue
  • Loading branch information
appuk committed Feb 10, 2024
1 parent f6619a1 commit 7d41bf1
Show file tree
Hide file tree
Showing 11 changed files with 806 additions and 0 deletions.
Binary file not shown.
120 changes: 120 additions & 0 deletions dev/galaxy_collection_plays_integration_tests/content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
- name: Collection tests - Content
hosts: localhost
connection: local
gather_facts: false
ignore_errors: true
collections:
- galaxy.galaxy

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

- name: Include dispatch vars
ansible.builtin.include_vars:
file: vars/dispatch_vars.yml

tasks:
- name: Create the automate namespace
ah_namespace:
name: automate
company: Automator Inc.
email: automator@redhat.com
description: The namespace for all things automation
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

- name: Rename automate namespace to automator
ah_namespace:
name: automate
new_name: automator
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: false

- name: Delete the automator namespace
ah_namespace:
state: absent
name: automator
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: false

- name: Ensure there is a galaxy namespace
ah_namespace:
name: galaxy
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: false

- name: Ensure there is a infra namespace
ah_namespace:
name: infra
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
ah_path_prefix: "{{ ah_path_prefix }}"
validate_certs: false

- name: Creates directory
ansible.builtin.file:
path: "{{ ah_configuration_working_dir }}"
state: directory

- name: Download Tower tarball
ansible.builtin.get_url:
url: https://galaxy.ansible.com/download/infra-controller_configuration-2.4.0.tar.gz
dest: "{{ ah_configuration_working_dir }}/infra-controller_configuration-2.4.0.tar.gz"
mode: '0440'

- name: Upload Tower collection to automation hub
ah_collection_upload:
path: "{{ ah_configuration_working_dir }}/infra-controller_configuration-2.4.0.tar.gz"
wait: true
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

- name: Approve the galaxy collection
timeout: 60
ah_approval:
namespace: infra
name: controller_configuration
version: "2.4.0"
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

- name: Delete the galaxy collection
ah_collection:
state: absent
namespace: infra
name: controller_configuration
version: "2.4.0"
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

- name: Publish Collections
ansible.builtin.include_role:
name: publish
vars:
ah_collections:
- collection_name: cisco.iosxr
git_url: https://github.com/ansible-collections/cisco.iosxr
ah_auto_approve: true
validate_certs: false

19 changes: 19 additions & 0 deletions dev/galaxy_collection_plays_integration_tests/dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Collection tests - Dispatch role
hosts: localhost
connection: local
gather_facts: false
ignore_errors: true
collections:
- galaxy.galaxy

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

- name: Include dispatch vars
ansible.builtin.include_vars:
file: vars/dispatch_vars.yml
roles:
- galaxy.galaxy.dispatch
74 changes: 74 additions & 0 deletions dev/galaxy_collection_plays_integration_tests/ee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
- name: Collection tests - EE
hosts: localhost
connection: local
gather_facts: false
ignore_errors: true
collections:
- galaxy.galaxy

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

tasks:
- name: Add redhat.io registry
ah_ee_registry:
name: redhat
url: https://registry.redhat.io
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

- name: create a repo
ah_ee_repository:
name: ansible-automation-platform-19/ee-29-rhel8
description: AAP RHEL execution environment
registry: redhat
upstream_name: redhat
readme: |
# RHEL execution environment
* Contains ansible
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

- name: Index redhat.io registry
ah_ee_registry_index:
name: redhat
wait: true
timeout: 300
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Registry Sync
ah_ee_registry_sync:
name: redhat
wait: true
timeout: 300
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Repo Sync
ah_ee_repository_sync:
name: ansible-automation-platform-19/ee-29-rhel8
wait: true
timeout: 300
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Delete the redhat.io registry
ah_ee_registry:
name: redhat
state: absent
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"
validate_certs: false

106 changes: 106 additions & 0 deletions dev/galaxy_collection_plays_integration_tests/ee_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
- name: Collection tests - EE Image
hosts: localhost
connection: local
become: false
gather_facts: false
ignore_errors: true
collections:
- galaxy.galaxy
vars:
repository: test-namespace/ee-minimal-rhel8
tag: latest
fake_image: quay.io/ansible/http-test-container:2.0.0
pre_tasks:
- name: Include variables
ansible.builtin.include_vars:
file: vars/vars.yml

tasks:
- name: Ensure a small container image is available
ansible.builtin.command:
cmd: "podman pull {{ fake_image }}"
changed_when: true

- name: Ensure the image has the correct tag
ansible.builtin.command:
cmd: "podman tag {{ fake_image }} {{ hub_host }}/{{ repository }}:{{ tag }}"
changed_when: true

- name: Ensure the image is pushed in private automation hub
ansible.builtin.command:
cmd: "podman push --tls-verify=false --remove-signatures
--creds={{ ah_username }}:{{ ah_password }}
{{ hub_host }}/{{ repository }}:{{ tag }}"
changed_when: true

# Preparing a README file
- name: Ensure a temporary file exists
ansible.builtin.tempfile:
register: tempfile

- name: Ensure some contents are stored in the temporary file
ansible.builtin.copy:
dest: "{{ tempfile['path'] }}"
mode: 0600
content: |
# Mi entorno de ejecución
* bullet 1
* bullet 2
- name: Create repository
ah_ee_repository:
name: ansible-automation-platform-19/ee-29-rhel8
registry: redhat
upstream_name: redhat
state: present
description: Supported execution environment
include_tags: latest
readme: |
# My execution environment
* bullet 1
* bullet 2
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Tag image
ah_ee_image:
name: ansible-automation-platform-19/ee-29-rhel8:latest
state: present
append: false
tags:
- v2
- "2.0"
- prod1
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Append Tags to image
ah_ee_image:
name: ansible-automation-platform-19/ee-29-rhel8:2.0.0-15
state: present
append: true
tags:
- prod2
- prod2.0
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Remove image
ah_ee_image:
name: ansible-automation-platform-19/ee-29-rhel8:2.0.0-15
state: absent
ah_host: "{{ ah_host }}"
ah_username: "{{ ah_username }}"
ah_password: "{{ ah_password }}"

- name: Ensure the images are removed
ansible.builtin.command:
cmd: "podman rmi {{ fake_image }} {{ hub_host }}/{{ repository }}:{{ tag }}"
changed_when: true
...
Loading

0 comments on commit 7d41bf1

Please sign in to comment.