|
| 1 | +--- |
| 2 | +- name: Query repositories |
| 3 | + pulp.squeezer.deb_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.deb_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 | + |
| 18 | +- name: Query distributions |
| 19 | + pulp.squeezer.deb_distribution: |
| 20 | + pulp_url: "{{ pulp_url }}" |
| 21 | + username: "{{ pulp_username }}" |
| 22 | + password: "{{ pulp_password }}" |
| 23 | + validate_certs: "{{ pulp_validate_certs | bool }}" |
| 24 | + register: pulp_dists_list |
| 25 | + |
| 26 | +- name: Ensure Deb distributions are defined |
| 27 | + vars: |
| 28 | + repo: "{{ pulp_repos_list.repositories | selectattr('name', 'equalto', item.repository) | first }}" |
| 29 | + # If the distribution references a specific version: |
| 30 | + specific_pub: "{{ pulp_pubs_list.publications | selectattr('repository_version', 'equalto', repo.pulp_href ~ 'versions/' ~ item.version | default ~ '/') }}" |
| 31 | + # If the distribution uses the latest version: |
| 32 | + latest_pub: "{{ pulp_pubs_list.publications | selectattr('repository', 'equalto', repo.pulp_href) | sort(attribute='repository_version', reverse=True) }}" |
| 33 | + # If another distribution is being promoted to this one: |
| 34 | + promoted_dist: "{{ pulp_dists_list.distributions | selectattr('name', 'equalto', item.distribution | default) }}" |
| 35 | + promoted_pub: "{{ pulp_pubs_list.publications | selectattr('pulp_href', 'equalto', (promoted_dist | first).publication | default) }}" |
| 36 | + # Pick the right publication based on the type of distribution. |
| 37 | + pubs: "{{ specific_pub if item.version is defined else promoted_pub if item.distribution is defined else latest_pub }}" |
| 38 | + # Whether any distributions exist for this publication. |
| 39 | + pub_has_dists: >- |
| 40 | + {{ pulp_dists_list.distributions | selectattr('publication', 'equalto', pubs[0].pulp_href if item.state == 'present' else None) | list | length > 0 }} |
| 41 | + pulp.squeezer.deb_distribution: |
| 42 | + pulp_url: "{{ pulp_url }}" |
| 43 | + username: "{{ pulp_username }}" |
| 44 | + password: "{{ pulp_password }}" |
| 45 | + validate_certs: "{{ pulp_validate_certs | bool }}" |
| 46 | + name: "{{ item.name }}" |
| 47 | + base_path: "{{ item.base_path }}" |
| 48 | + publication: "{{ pubs[0].pulp_href if item.state == 'present' else omit }}" |
| 49 | + state: "{{ item.state }}" |
| 50 | + with_items: "{{ pulp_distribution_deb }}" |
| 51 | + when: >- |
| 52 | + item.state == 'absent' or |
| 53 | + not (item.skip_existing | default(pulp_distribution_deb_skip_existing) | bool and pub_has_dists) |
0 commit comments