Adds tripleo-repos/-operator-ansible collection push jobs

In [1] a release job was added for tripleo-operator. Now we need
to add the same for the tripleo-repos collection. This proposes
we move the playbook, secret and job definition to here so that
both jobs can share them. Then the jobs can be wired up into their
respective repo zuul layout files.

Once we are happy with testing (this needs to merge so we can test)
we can merge [2] and remove the duplication in t-o-a.

[1] https://review.opendev.org/c/openstack/tripleo-operator-ansible/+/803588
[2] https://review.opendev.org/c/openstack/tripleo-operator-ansible/+/810259
Change-Id: I09b24c4782db2e7cad117fb98a70a1c3d36a4301
This commit is contained in:
Marios Andreou 2021-09-21 17:22:36 +03:00
parent f3cd56a7e8
commit 74be796580
3 changed files with 114 additions and 0 deletions

View File

@ -24,6 +24,7 @@ repos:
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
exclude: zuul.d/ansible-galaxy.yaml
- repo: https://gitlab.com/pycqa/flake8
rev: '3.8.4'
hooks:

View File

@ -0,0 +1,75 @@
---
- hosts: all
vars:
build_collection_path: /tmp/collection_built/
ansible_galaxy_path: "~/.local/bin/ansible-galaxy"
tasks:
- name: Include role for pip
include_role:
name: ensure-pip
- name: Install ansible
pip:
name: ansible-core<2.12
- name: Discover tag version
set_fact:
version_tag: "{{ zuul.tag|default('no_version', true) }}"
- name: Fail if no tag version found
fail:
msg: "No tag was found in Zuul vars!"
when: version_tag == 'no_version'
- name: Create a directory for collection
file:
state: "{{ item }}"
path: "{{ build_collection_path }}"
mode: 0644
loop:
- absent
- directory
- name: Set galaxy.yml for right version from tag
lineinfile:
path: '{{ collection_path }}/galaxy.yml'
regexp: '^version:.*'
line: 'version: {{ version_tag }}'
- name: Build collection
command: "{{ ansible_galaxy_path }} collection build --output-path {{ build_collection_path }} --force"
args:
chdir: "{{ collection_path }}"
- name: Publish content to Ansible Galaxy
block:
- name: Create ansible.cfg configuration file tempfile
tempfile:
state: file
suffix: .cfg
register: _ansiblecfg_tmp
- name: Create ansible.cfg configuration file
copy:
dest: "{{ _ansiblecfg_tmp.path }}"
mode: 0600
content: |
[galaxy]
server_list = release_galaxy
[galaxy_server.release_galaxy]
url = {{ ansible_galaxy_secret.url }}
token = {{ ansible_galaxy_secret.token }}
- name: Publish collection to Ansible Galaxy / Automation Hub
environment:
ANSIBLE_CONFIG: "{{ _ansiblecfg_tmp.path }}"
shell: >-
{{ ansible_galaxy_path }} collection publish -vvv
{{ build_collection_path }}/{{ collection_name_prefix }}-{{ version_tag }}.tar.gz
always:
- name: Shred ansible-galaxy credentials
command: "shred {{ _ansiblecfg_tmp.path }}"

View File

@ -0,0 +1,38 @@
---
- job:
name: tripleo-operator-ansible-release-new # TODO(marios) remove -new
parent: base
run: playbooks/publish-galaxy-collection/publish_collection.yml
secrets:
- name: ansible_galaxy_secret
secret: ansible_galaxy_info_tripleo_ci
vars:
collection_path: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/tripleo-operator-ansible'].src_dir }}"
collection_name_prefix: "tripleo-operator"
- job:
name: tripleo-repos-release
parent: base
run: playbooks/publish-galaxy-collection/publish_collection.yml
secrets:
- name: ansible_galaxy_secret
secret: ansible_galaxy_info_tripleo_ci
vars:
collection_path: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/tripleo-repos'].src_dir }}"
collection_name_prefix: "tripleo-repos"
- secret:
name: ansible_galaxy_info_tripleo_ci
data:
url: https://galaxy.ansible.com
token: !encrypted/pkcs1-oaep
- Wj3D5B5XYJkZkOfiITUW4kplITZcTjlXPLhLU4fvjhS/MunE0hnDkUEVBCEmWTszBRUKu
90RScKHIx9C4jLOsQ/pXgAMq/E8WkdgiKaWE1BgryxhYfAE4ceL97xNqjidacUBbHoeRU
4RiCOP7POlYzVMTRi1gaILsRu0DfxaGHq1FOTqDOgwwnq95glNHIpj1ShN+xGWnv2hxhH
msLipXCiRT91VJUgyajJk6lXnP+lpep0xjgEP+uEryEJyfxng7oDSE9Y8Hifp4GwKhBMd
UTLaaeaVFqxIw8jdgglE4mSZ3LnLs3gcfIXf5t+ZRI7RVUax2khOoaRni9R3pEe8aw/8R
u7d53g5PlNtM4EYLmgznFbCFdvo/a0eqQ45lNckknB9pbWZGHBefZsgWgNgLpNEV5cJxH
EDwYtZTu4TS/K1nr/rc9dKGQqhaF+6aLnsVataYiDjxc6QPgZt0lzsAJw091rwDMfLGzQ
a85GlvkVCrkII6URwRWErAjSPWj4+F6B7V0wLM/TambkKExBd0boJ5bKcuDgWfenSuWgp
LZ087/qpkxUBOw3MnVeWhBsjWaqJoIvOfofNta9fcN2uI4U1OWjhYre95KHd5GIcir4ZO
ap++iJqRF//D5bSLDgA9Kv9FIfZO0XvVM2vG34CE/z/uZ9wUe7dK4HkBt+RLmI=