Skip to content

Commit 619176d

Browse files
committed
feat(tests/sync-ansible-collections.yaml): Prettify code
rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
1 parent 53303c7 commit 619176d

File tree

1 file changed

+110
-109
lines changed

1 file changed

+110
-109
lines changed
Lines changed: 110 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,146 @@
11
- hosts: satellite6
2-
vars_files:
3-
- Downloads/satperf.yaml
2+
gather_facts: false
43
vars:
5-
test_sync_repositories_count: 8
6-
test_sync_repositories_product: "test_sync_repositories_product"
7-
test_sync_repositories_upstream_url_template: "https://galaxy.ansible.com/"
8-
test_sync_repositories_repo_template: "test_sync_repositories_repo*"
9-
test_sync_repositories_max_sync_secs: 3600
10-
test_sync_repositories_cv_template: "test_sync_repositories_cv*"
11-
test_sync_repositories_le: "test_sync_repositories_le"
12-
sat_user: admin
13-
sat_pass: changeme
14-
organization: Default Organization
4+
test_sync_ansible_collections_count: 8
5+
test_sync_ansible_collections_upstream_url_template: "https://galaxy.ansible.com/"
6+
test_sync_ansible_collections_max_sync_secs: 3600
7+
test_sync_ansible_collections_product: "test_sync_ansible_collections_product"
8+
test_sync_ansible_collections_le: "test_sync_ansible_collections_le"
9+
test_sync_ansible_collections_repo_template: "test_sync_ansible_collections_repo*"
10+
test_sync_ansible_collections_cv_template: "test_sync_ansible_collections_cv*"
11+
roles:
12+
- wait-for-task-script
1513
tasks:
16-
- name: "Create product"
17-
ansible.builtin.command:
14+
- name: "Create product"
15+
ansible.builtin.command:
1816
cmd: |
19-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" product create --organization "{{ organization }}" --name "{{ test_sync_repositories_product }}"
20-
register: create_product
21-
failed_when:
17+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" product create --organization "{{ organization }}" --name "{{ test_sync_ansible_collections_product }}"
18+
register: create_product
19+
failed_when:
2220
- create_product.rc != 0
2321
- "'Name has already been taken for a product in this organization' not in create_product.stderr"
24-
changed_when:
22+
changed_when:
2523
- create_product.rc == 0
2624
- "'Product created' in create_product.stdout"
2725

28-
- name: "Create requirements file"
29-
ansible.builtin.copy:
30-
dest: "/tmp/blabllbl"
31-
content: |
32-
---
33-
collections:
34-
- name: ansible.posix
35-
version: 1.5.4
36-
- name: ansible.utils
37-
version: 5.0.0
38-
- name: community.general
39-
version: 9.1.0
40-
...
26+
- name: "Create requirements file"
27+
ansible.builtin.tempfile:
28+
state: file
29+
suffix: .yaml
30+
register: requirement_yaml
4131

42-
- name: "Create repos"
43-
ansible.builtin.command:
32+
- name: "Add collections to requirements file"
33+
ansible.builtin.copy:
34+
dest: requirement_yaml
35+
content: |
36+
---
37+
collections:
38+
- name: ansible.posix
39+
version: 1.5.4
40+
- name: ansible.utils
41+
version: 5.0.0
42+
- name: community.general
43+
version: 9.1.0
44+
...
45+
46+
- name: "Create repos"
47+
ansible.builtin.command:
4448
cmd: |
45-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" repository create --organization "{{ organization }}" --product "{{ test_sync_repositories_product }}" --content-type ansible_collection --url "{{ test_sync_repositories_upstream_url_template }}" --requirements "/tmp/blabllbl" --name "{{ test_sync_repositories_repo_template | replace('*', item) }}"
46-
register: create_repo
47-
loop: "{{ range(1, test_sync_repositories_count | int + 1) | list }}"
49+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" repository create --organization "{{ organization }}" --product "{{ test_sync_ansible_collections_product }}" --content-type ansible_collection --url "{{ test_sync_ansible_collections_upstream_url_template }}" --ansible-collection-requirements-file "/tmp/blabllbl" --name "{{ test_sync_ansible_collections_repo_template | replace('*', item) }}"
50+
register: create_repo
51+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
4852

4953
# Sync
50-
- name: "Start sync asynchronously"
51-
ansible.builtin.command:
52-
cmd: |
53-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" repository synchronize --organization "{{ organization }}" --product "{{ test_sync_repositories_product }}" --name "{{ test_sync_repositories_repo_template | replace('*', item) }}" --async
54-
loop: "{{ range(1, test_sync_repositories_count | int + 1) | list }}"
55-
register: start_sync
56-
ignore_errors: true
54+
- name: "Start sync asynchronously"
55+
ansible.builtin.command:
56+
cmd: |
57+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" repository synchronize --organization "{{ organization }}" --product "{{ test_sync_ansible_collections_product }}" --name "{{ test_sync_ansible_collections_repo_template | replace('*', item) }}" --async
58+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
59+
register: start_sync
60+
ignore_errors: true
5761

58-
- name: "Check that start message is sane"
59-
ansible.builtin.assert:
62+
- name: "Check that start message is sane"
63+
ansible.builtin.assert:
6064
that: "'Repository is being synchronized in task' in item.stdout"
6165
msg: 'Pass'
6266
quiet: true
63-
loop: "{{ start_sync.results }}"
64-
loop_control:
65-
label: "{{ test_sync_repositories_repo_template | replace('*', item.item) }}"
67+
loop: "{{ start_sync.results }}"
68+
loop_control:
69+
label: "{{ test_sync_ansible_collections_repo_template | replace('*', item.item) }}"
6670

67-
- name: "Wait for synces to finish"
68-
ansible.builtin.command:
69-
cmd: |
70-
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[6].split('.')[0] }}" "{{ test_sync_repositories_max_sync_secs }}"
71-
loop: "{{ start_sync.results }}"
72-
loop_control:
73-
label: "{{ test_sync_repositories_repo_template | replace('*', item.item) }}"
74-
register: wait_sync
75-
ignore_errors: true
71+
- name: "Wait for synces to finish"
72+
ansible.builtin.command:
73+
cmd: |
74+
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[6].split('.')[0] }}" "{{ test_sync_ansible_collections_max_sync_secs }}"
75+
loop: "{{ start_sync.results }}"
76+
loop_control:
77+
label: "{{ test_sync_ansible_collections_repo_template | replace('*', item.item) }}"
78+
register: wait_sync
79+
ignore_errors: true
7680

77-
- name: "Print sync results"
78-
ansible.builtin.debug:
81+
- name: "Print synchronizations results"
82+
ansible.builtin.debug:
7983
msg: "SyncRepositories {{ item.stdout_lines[-2] }} to {{ item.stdout_lines[-1] }}"
80-
loop: "{{ wait_sync.results }}"
81-
when: "item.rc is defined and item.rc == 0"
84+
loop: "{{ wait_sync.results }}"
85+
when: "item.rc is defined and item.rc == 0"
8286

83-
- name: "Create lifecycle environment"
84-
ansible.builtin.command:
87+
- name: "Create lifecycle environment"
88+
ansible.builtin.command:
8589
cmd: |
86-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" lifecycle-environment create --organization "{{ organization }}" --prior Library --name "{{ test_sync_repositories_le }}"
87-
register: create_le
90+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" lifecycle-environment create --organization "{{ organization }}" --prior Library --name "{{ test_sync_ansible_collections_le }}"
91+
register: create_le
8892

89-
- name: "Create content views"
90-
ansible.builtin.command:
91-
cmd: |
92-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view create --organization "{{ organization }}" --name "{{ test_sync_repositories_cv_template | replace('*', item) }}"
93-
register: create_cv
94-
loop: "{{ range(1, test_sync_repositories_count | int + 1) | list }}"
93+
- name: "Create content views"
94+
ansible.builtin.command:
95+
cmd: |
96+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view create --organization "{{ organization }}" --name "{{ test_sync_ansible_collections_cv_template | replace('*', item) }}"
97+
register: create_cv
98+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
9599

96100
# Publish
97-
- name: "Publish content views"
98-
ansible.builtin.command:
101+
- name: "Publish content views"
102+
ansible.builtin.command:
99103
cmd: |
100-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view publish --async --organization "{{ organization }}" --name "{{ test_sync_repositories_cv_template | replace('*', item) }}"
101-
register: start_publish
102-
loop: "{{ range(1, test_sync_repositories_count | int + 1) | list }}"
104+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view publish --async --organization "{{ organization }}" --name "{{ test_sync_ansible_collections_cv_template | replace('*', item) }}"
105+
register: start_publish
106+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
103107

104-
- name: "Wait for publish to finish"
105-
ansible.builtin.command:
108+
- name: "Wait for publish to finish"
109+
ansible.builtin.command:
106110
cmd: |
107-
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[7].split('.')[0] }}" "{{ test_sync_repositories_max_sync_secs }}"
108-
loop: "{{ start_publish.results }}"
109-
loop_control:
110-
label: "{{ test_sync_repositories_cv_template | replace('*', item.item) }}"
111-
register: wait_publish
112-
ignore_errors: true
111+
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[7].split('.')[0] }}" "{{ test_sync_ansible_collections_max_sync_secs }}"
112+
loop: "{{ start_publish.results }}"
113+
loop_control:
114+
label: "{{ test_sync_ansible_collections_cv_template | replace('*', item.item) }}"
115+
register: wait_publish
116+
ignore_errors: true
113117

114-
- name: "Print publish results"
115-
ansible.builtin.debug:
116-
msg: "PublishContentViews {{ item.stdout_lines[-2] }} to {{ item.stdout_lines[-1] }}"
117-
loop: "{{ wait_publish.results }}"
118-
when: "item.rc is defined and item.rc == 0"
118+
- name: "Print publication results"
119+
ansible.builtin.debug:
120+
msg: "PublishContentViews {{ item.stdout_lines[-2] }} to {{ item.stdout_lines[-1] }}"
121+
loop: "{{ wait_publish.results }}"
122+
when: "item.rc is defined and item.rc == 0"
119123

120124
# Promote
121-
- name: "Promote content views"
122-
ansible.builtin.command:
123-
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view version promote --async --organization "{{ organization }}" --content-view "{{ test_sync_repositories_cv_template | replace('*', item) }}" --version "1.0" --to-lifecycle-environment "{{ test_sync_repositories_le }}"
124-
register: start_promote
125-
loop: "{{ range(1, test_sync_repositories_count | int + 1) | list }}"
125+
- name: "Promote content views"
126+
ansible.builtin.command:
127+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view version promote --async --organization "{{ organization }}" --content-view "{{ test_sync_ansible_collections_cv_template | replace('*', item) }}" --version "1.0" --to-lifecycle-environment "{{ test_sync_ansible_collections_le }}"
128+
register: start_promote
129+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
126130

127-
- name: "Wait for promote to finish"
128-
ansible.builtin.command:
131+
- name: "Wait for promote to finish"
132+
ansible.builtin.command:
129133
cmd: |
130-
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[7].split('.')[0] }}" "{{ test_sync_repositories_max_sync_secs }}"
131-
loop: "{{ start_promote.results }}"
132-
loop_control:
133-
label: "{{ test_sync_repositories_cv_template | replace('*', item.item) }}"
134-
register: wait_promote
135-
ignore_errors: true
136-
137-
- ansible.builtin.debug:
138-
var: wait_promote
134+
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[7].split('.')[0] }}" "{{ test_sync_ansible_collections_max_sync_secs }}"
135+
loop: "{{ start_promote.results }}"
136+
loop_control:
137+
label: "{{ test_sync_ansible_collections_cv_template | replace('*', item.item) }}"
138+
register: wait_promote
139+
ignore_errors: true
139140

140-
- name: "Print promote results"
141-
ansible.builtin.debug:
141+
- name: "Print promotion results"
142+
ansible.builtin.debug:
142143
msg: "PromoteContentViews {{ item.stdout_lines[-2] }} to {{ item.stdout_lines[-1] }}"
143-
loop: "{{ wait_promote.results }}"
144-
when: "item.rc is defined and item.rc == 0"
144+
loop: "{{ wait_promote.results }}"
145+
when: "item.rc is defined and item.rc == 0"
145146
...

0 commit comments

Comments
 (0)