Skip to content

Commit 1428343

Browse files
committed
Avoid specifying publication hrefs for distributions
Pulp hrefs are not very easy to work with, and aren't known up front. Use the repository name and version to lookup a matching publication when distributing.
1 parent 6d900ee commit 1428343

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

roles/pulp_distribution/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ Example playbook
2929
pulp_distribution_rpm:
3030
- name: centos-baseos
3131
base_path: centos-baseos
32-
publication:
32+
repository: centos-baseos
3333
state: present
3434
- name: centos-appstream
3535
base_path: centos-appstream
36-
publication:
36+
repository: centos-appstream
37+
version: 2
3738
state: present
3839
```
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
11
---
2+
- name: Query repositories
3+
pulp.squeezer.rpm_repository:
4+
pulp_url: "{{ pulp_url }}"
5+
username: "{{ pulp_username }}"
6+
password: "{{ pulp_password }}"
7+
validate_certs: "{{ pulp_validate_certs | bool }}"
8+
register: pulp_repos_list
9+
10+
- name: Query publications
11+
pulp.squeezer.rpm_publication:
12+
pulp_url: "{{ pulp_url }}"
13+
username: "{{ pulp_username }}"
14+
password: "{{ pulp_password }}"
15+
validate_certs: "{{ pulp_validate_certs | bool }}"
16+
register: pulp_pubs_list
17+
218
- name: Ensure RPM distributions are defined
19+
vars:
20+
repo: "{{ pulp_repos_list.repositories | selectattr('name', 'equalto', item.repository) | first }}"
21+
# If the distribution references a specific version:
22+
specific_pub: "{{ pulp_pubs_list.publications | selectattr('repository_version', 'equalto', repo.pulp_href ~ 'versions/' ~ item.version | default ~ '/') }}"
23+
# If the distribution uses the latest version:
24+
latest_pub: "{{ pulp_pubs_list.publications | selectattr('repository', 'equalto', repo.pulp_href) | sort(attribute='repository_version', reverse=True) }}"
25+
pub: "{{ latest_pub | first if item.version is not defined else specific_pub | first }}"
326
pulp.squeezer.rpm_distribution:
427
pulp_url: "{{ pulp_url }}"
528
username: "{{ pulp_username }}"
629
password: "{{ pulp_password }}"
730
validate_certs: "{{ pulp_validate_certs | bool }}"
831
name: "{{ item.name }}"
932
base_path: "{{ item.base_path }}"
10-
publication: "{{ item.publication }}"
33+
publication: "{{ pub.pulp_href }}"
1134
state: "{{ item.state }}"
1235
with_items: "{{ pulp_distribution_rpm }}"

0 commit comments

Comments
 (0)