Skip to content

Commit 5d9a7b8

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 5d9a7b8

File tree

2 files changed

+110
-109
lines changed

2 files changed

+110
-109
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
collections:
3+
- name: ansible.posix
4+
version: 1.5.4
5+
- name: ansible.utils
6+
version: 5.0.0
7+
- name: community.general
8+
version: 9.1.0
9+
...
Lines changed: 101 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,137 @@
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: requirements_yaml
4131

42-
- name: "Create repos"
43-
ansible.builtin.command:
32+
- name: "Add collections to requirements file"
33+
ansible.builtin.copy:
34+
src: files/requirements.yaml
35+
dest: "{{ requirements_yaml.path }}"
36+
37+
- name: "Create repos"
38+
ansible.builtin.command:
4439
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 }}"
40+
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 "{{ requirements_yaml.path }}" --name "{{ test_sync_ansible_collections_repo_template | replace('*', item) }}"
41+
register: create_repo
42+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
4843

4944
# 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
45+
- name: "Start sync asynchronously"
46+
ansible.builtin.command:
47+
cmd: |
48+
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
49+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
50+
register: start_sync
51+
ignore_errors: true
5752

58-
- name: "Check that start message is sane"
59-
ansible.builtin.assert:
53+
- name: "Check that start message is sane"
54+
ansible.builtin.assert:
6055
that: "'Repository is being synchronized in task' in item.stdout"
6156
msg: 'Pass'
6257
quiet: true
63-
loop: "{{ start_sync.results }}"
64-
loop_control:
65-
label: "{{ test_sync_repositories_repo_template | replace('*', item.item) }}"
58+
loop: "{{ start_sync.results }}"
59+
loop_control:
60+
label: "{{ test_sync_ansible_collections_repo_template | replace('*', item.item) }}"
6661

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
62+
- name: "Wait for synces to finish"
63+
ansible.builtin.command:
64+
cmd: |
65+
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[6].split('.')[0] }}" "{{ test_sync_ansible_collections_max_sync_secs }}"
66+
loop: "{{ start_sync.results }}"
67+
loop_control:
68+
label: "{{ test_sync_ansible_collections_repo_template | replace('*', item.item) }}"
69+
register: wait_sync
70+
ignore_errors: true
7671

77-
- name: "Print sync results"
78-
ansible.builtin.debug:
72+
- name: "Print synchronizations results"
73+
ansible.builtin.debug:
7974
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"
75+
loop: "{{ wait_sync.results }}"
76+
when: "item.rc is defined and item.rc == 0"
8277

83-
- name: "Create lifecycle environment"
84-
ansible.builtin.command:
78+
- name: "Create lifecycle environment"
79+
ansible.builtin.command:
8580
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
81+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" lifecycle-environment create --organization "{{ organization }}" --prior Library --name "{{ test_sync_ansible_collections_le }}"
82+
register: create_le
8883

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 }}"
84+
- name: "Create content views"
85+
ansible.builtin.command:
86+
cmd: |
87+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view create --organization "{{ organization }}" --name "{{ test_sync_ansible_collections_cv_template | replace('*', item) }}"
88+
register: create_cv
89+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
9590

9691
# Publish
97-
- name: "Publish content views"
98-
ansible.builtin.command:
92+
- name: "Publish content views"
93+
ansible.builtin.command:
9994
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 }}"
95+
hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" content-view publish --async --organization "{{ organization }}" --name "{{ test_sync_ansible_collections_cv_template | replace('*', item) }}"
96+
register: start_publish
97+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
10398

104-
- name: "Wait for publish to finish"
105-
ansible.builtin.command:
99+
- name: "Wait for publish to finish"
100+
ansible.builtin.command:
106101
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
102+
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[7].split('.')[0] }}" "{{ test_sync_ansible_collections_max_sync_secs }}"
103+
loop: "{{ start_publish.results }}"
104+
loop_control:
105+
label: "{{ test_sync_ansible_collections_cv_template | replace('*', item.item) }}"
106+
register: wait_publish
107+
ignore_errors: true
113108

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"
109+
- name: "Print publication results"
110+
ansible.builtin.debug:
111+
msg: "PublishContentViews {{ item.stdout_lines[-2] }} to {{ item.stdout_lines[-1] }}"
112+
loop: "{{ wait_publish.results }}"
113+
when: "item.rc is defined and item.rc == 0"
119114

120115
# 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 }}"
116+
- name: "Promote content views"
117+
ansible.builtin.command:
118+
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 }}"
119+
register: start_promote
120+
loop: "{{ range(1, test_sync_ansible_collections_count | int + 1) | list }}"
126121

127-
- name: "Wait for promote to finish"
128-
ansible.builtin.command:
122+
- name: "Wait for promote to finish"
123+
ansible.builtin.command:
129124
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
125+
/root/wait-for-task.sh "{{ sat_user }}" "{{ sat_pass }}" "{{ item.stdout.split()[7].split('.')[0] }}" "{{ test_sync_ansible_collections_max_sync_secs }}"
126+
loop: "{{ start_promote.results }}"
127+
loop_control:
128+
label: "{{ test_sync_ansible_collections_cv_template | replace('*', item.item) }}"
129+
register: wait_promote
130+
ignore_errors: true
139131

140-
- name: "Print promote results"
141-
ansible.builtin.debug:
132+
- name: "Print promotion results"
133+
ansible.builtin.debug:
142134
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"
135+
loop: "{{ wait_promote.results }}"
136+
when: "item.rc is defined and item.rc == 0"
145137
...

0 commit comments

Comments
 (0)