Skip to content

Commit d3597c5

Browse files
committed
galaxy
Depends-On: ansible/galaxy#2138 Signed-off-by: Paul Belanger <[email protected]>
1 parent f8a749e commit d3597c5

File tree

3 files changed

+172
-8
lines changed

3 files changed

+172
-8
lines changed

.zuul.yaml

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
- job:
2+
name: galaxy-quick-start
3+
run: playbooks/run.yaml
4+
required-projects:
5+
- name: github.com/ansible/galaxy
6+
- name: github.com/ansible-network/releases
7+
nodeset: centos-8-1vcpu
8+
9+
- job:
10+
name: galaxy-quick-start-child
11+
dependencies:
12+
- name: galaxy-quick-start
13+
run: playbooks/child.yaml
14+
nodeset: centos-8-1vcpu
15+
116
- project:
2-
post:
17+
check:
318
jobs:
4-
- release-ansible-collection-galaxy-dev
5-
pre-rlease:
6-
jobs:
7-
- release-ansible-collection-galaxy-dev
8-
release:
9-
jobs:
10-
- release-ansible-collection-galaxy-dev
19+
- galaxy-quick-start
20+
- galaxy-quick-start-child

playbooks/child.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
- hosts: all
2+
tasks:
3+
- name: Create ansible.cfg configuration file
4+
copy:
5+
content: |
6+
[galaxy]
7+
server_list = buildset_galaxy, release_galaxy
8+
9+
[galaxy_server.buildset_galaxy]
10+
url = http://{{ registry_ip_address }}:8000
11+
12+
[galaxy_server.release_galaxy]
13+
url = https://galaxy.ansible.com
14+
dest: /tmp/galaxy.cfg
15+
mode: 0600
16+
17+
- name: Setup tox role
18+
include_role:
19+
name: tox
20+
vars:
21+
tox_extra_args: -vv --notest
22+
tox_install_siblings: false
23+
zuul_work_dir: "{{ zuul.project.src_dir }}"
24+
25+
- name: Install collection from buildset Galaxy
26+
environment:
27+
ANSIBLE_CONFIG: /tmp/galaxy.cfg
28+
shell: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/.tox/venv/bin/ansible-galaxy -vvvv collection install network.sandbox:0.0.26-dev1 ibm.qradar"

playbooks/run.yaml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
- hosts: all
2+
tasks:
3+
- name: Executor install-docker role
4+
include_role:
5+
name: install-docker
6+
vars:
7+
use_upstream_docker: true
8+
9+
- name: Ensure dependencies are installed
10+
become: true
11+
package:
12+
name:
13+
- docker-compose
14+
- python-pexpect
15+
state: installed
16+
17+
- name: Build docker containers
18+
shell: make dev/build
19+
args:
20+
chdir: "{{ zuul.projects['github.com/ansible/galaxy'].src_dir }}"
21+
executable: /bin/bash
22+
23+
- name: Run docker-compose up
24+
shell: make dev/up_detached
25+
args:
26+
chdir: "{{ zuul.projects['github.com/ansible/galaxy'].src_dir }}"
27+
executable: /bin/bash
28+
29+
- name: Print list of images
30+
command: docker image ls --all --digests --no-trunc
31+
32+
- name: Wait for galaxy to start
33+
uri:
34+
url: http://localhost:8000
35+
register: result
36+
until: result.status == 200 and result.redirected == false
37+
retries: 120
38+
39+
- name: Create admin user
40+
expect:
41+
chdir: "{{ zuul.projects['github.com/ansible/galaxy'].src_dir }}"
42+
command: make dev/createsuperuser
43+
echo: true
44+
responses:
45+
'Username:': admin
46+
'Email address:': [email protected]
47+
'Password:': secret
48+
'Password \(again\):': secret
49+
timeout: 60
50+
51+
- name: Create admin token
52+
args:
53+
chdir: "{{ zuul.projects['github.com/ansible/galaxy'].src_dir }}"
54+
executable: /bin/bash
55+
shell: make USERNAME=admin dev/createusertoken | tail -n1 | cut -d ' ' -f3
56+
register: _token
57+
58+
- name: Create ansible.cfg configuration file
59+
copy:
60+
content: |
61+
[galaxy]
62+
server_list = buildset_galaxy
63+
64+
[galaxy_server.buildset_galaxy]
65+
url = http://localhost:8000
66+
token = {{ _token.stdout }}
67+
dest: /tmp/galaxy.cfg
68+
mode: 0600
69+
70+
- name: Create network namespace
71+
args:
72+
chdir: "{{ zuul.projects['github.com/ansible/galaxy'].src_dir }}"
73+
executable: /bin/bash
74+
shell: make USERNAME=admin NAMESPACE=network dev/createnamespace
75+
76+
- name: Confirm namespace exists
77+
uri:
78+
url: http://localhost:8000/api/v1/namespaces/?name=network
79+
register: result
80+
until: result.status == 200
81+
retries: 120
82+
83+
- name: Assert namespace exists
84+
assert:
85+
that:
86+
- result.json.count != 0
87+
88+
- name: Setup tox role
89+
include_role:
90+
name: tox
91+
vars:
92+
tox_extra_args: -vv --notest
93+
tox_install_siblings: false
94+
zuul_work_dir: "{{ zuul.projects['github.com/ansible-network/releases'].src_dir }}"
95+
96+
- name: Generate version number for ansible collection.
97+
args:
98+
chdir: "{{ zuul.project.src_dir }}"
99+
command: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible-network/releases'].src_dir }}/.tox/venv/bin/generate-ansible-collection"
100+
101+
- name: Run build-ansible-collection role
102+
include_role:
103+
name: build-ansible-collection
104+
vars:
105+
ansible_galaxy_output_path: ~/artifacts
106+
ansible_galaxy_executable: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible-network/releases'].src_dir }}/.tox/venv/bin/ansible-galaxy"
107+
108+
- name: Find tarballs to upload
109+
find:
110+
paths: ~/artifacts
111+
patterns: "*.tar.gz"
112+
register: found_tarballs
113+
114+
- name: Publish collection to Ansible Galaxy
115+
environment:
116+
ANSIBLE_CONFIG: /tmp/galaxy.cfg
117+
shell: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/ansible-network/releases'].src_dir }}/.tox/venv/bin/ansible-galaxy -vvv collection publish {{ item.path }}"
118+
register: result
119+
until: result.rc == 0
120+
with_items: "{{ found_tarballs.files }}"
121+
122+
- zuul_return:
123+
data:
124+
zuul:
125+
pause: true
126+
registry_ip_address: "{{ hostvars[groups.all[0]].ansible_host }}"

0 commit comments

Comments
 (0)