Skip to content

Commit f617a14

Browse files
committed
Parallelise pulp_container_content
1 parent 83ddd5d commit f617a14

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
---
2+
- name: Initialize active tasks list
3+
set_fact:
4+
pulp_container_active_tasks: []
5+
26
- name: Add or remove content units
37
include_tasks: process_content.yml
48
loop: "{{ pulp_container_content }}"
59
loop_control:
610
loop_var: content_item
11+
12+
- name: Wait for tasks to complete
13+
pulp.squeezer.task:
14+
pulp_url: "{{ pulp_url }}"
15+
username: "{{ pulp_username }}"
16+
password: "{{ pulp_password }}"
17+
validate_certs: "{{ pulp_validate_certs | bool }}"
18+
pulp_href: "{{ item }}"
19+
state: completed
20+
loop: "{{ pulp_container_active_tasks }}"
21+
when: pulp_container_content_wait | bool

roles/pulp_container_content/tasks/process_content.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
parameters:
3232
name: "{{ content_item.src_repo }}"
3333
register: src_repo_result
34-
when:
34+
when:
3535
- content_item.state | default('present') == 'present'
3636
- content_item.src_repo is defined
3737

3838
- name: Fail if source repository not found
3939
fail:
4040
msg: "Source repository '{{ content_item.src_repo }}' not found."
41-
when:
41+
when:
4242
- content_item.state | default('present') == 'present'
4343
- content_item.src_repo is defined
4444
- src_repo_result.response.count == 0
@@ -75,7 +75,7 @@
7575
missing_tags: "{{ content_item.tags | difference(found_tags) }}"
7676
fail:
7777
msg: "Some tags not found in source repository: {{ missing_tags | join(', ') }}"
78-
when:
78+
when:
7979
- content_item.state | default('present') in ['present', 'read']
8080
- not content_item.allow_missing | default(false)
8181
- missing_tags | length > 0
@@ -96,7 +96,7 @@
9696
body:
9797
content_units: "{{ content_units }}"
9898
register: add_result
99-
when:
99+
when:
100100
- content_item.state | default('present') == 'present'
101101
- content_units | length > 0
102102
changed_when: true
@@ -113,20 +113,16 @@
113113
body:
114114
content_units: "{{ content_units }}"
115115
register: remove_result
116-
when:
116+
when:
117117
- content_item.state | default('present') == 'absent'
118118
- content_units | length > 0
119119
changed_when: true
120120

121-
- name: Wait for task completion
122-
pulp.squeezer.task:
123-
pulp_url: "{{ pulp_url }}"
124-
username: "{{ pulp_username }}"
125-
password: "{{ pulp_password }}"
126-
validate_certs: "{{ pulp_validate_certs | bool }}"
127-
pulp_href: "{{ item.response.pulp_href }}"
128-
state: completed
121+
- name: Register active tasks
122+
set_fact:
123+
pulp_container_active_tasks: "{{ pulp_container_active_tasks + [item.response.pulp_href] }}"
129124
loop: "{{ [add_result, remove_result] }}"
130-
when:
125+
when:
126+
- item is defined
131127
- item.changed | default(false)
132-
- pulp_container_content_wait | bool
128+
- item.response.pulp_href is defined

0 commit comments

Comments
 (0)