Skip to content

Commit b3b9e27

Browse files
authored
Merge pull request #26 from stackhpc/content-guard
Add pulp_content_guard role
2 parents 2168c81 + edad66e commit b3b9e27

File tree

8 files changed

+70
-3
lines changed

8 files changed

+70
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Tested with the current Ansible 2.9-2.10 releases.
1111

1212
## Included content
1313

14+
pulp_contentguard role
1415
pulp_repository role
1516

1617
## Using this collection

roles/pulp_content_guard/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
pulp_content_guard
2+
==================
3+
4+
This role manages Pulp content guards.
5+
6+
Role variables
7+
--------------
8+
9+
* `pulp_url`: URL of Pulp server. Default is `https://localhost:8080`
10+
* `pulp_username`: Username used to access Pulp server. Default is `admin`
11+
* `pulp_password`: Password used to access Pulp server. Default is unset
12+
* `pulp_validate_certs`: Whether to validate Pulp server certificate. Default is `true`
13+
* `pulp_content_guard_x509_cert_guards`: List of x509 cert guards. Each item is
14+
a dict with the following keys: `name`, `description`, `ca_certificate`,
15+
`state`.
16+
17+
18+
Example playbook
19+
----------------
20+
21+
```
22+
---
23+
- name: Create Pulp content guards
24+
any_errors_fatal: True
25+
gather_facts: True
26+
hosts: all
27+
roles:
28+
- role: stackhpc.pulp.pulp_contentguard
29+
pulp_username: admin
30+
pulp_password: "{{ secrets_pulp_admin_password }}"
31+
pulp_content_guard_x509_cert_guards:
32+
- name: test_cert_guard
33+
description: For testing
34+
ca_certificate: |-
35+
-----BEGIN CERTIFICATE-----
36+
...
37+
-----END CERTIFICATE-----
38+
state: present
39+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pulp_url: https://localhost:8080
3+
pulp_username: admin
4+
pulp_password:
5+
pulp_validate_certs: true
6+
7+
pulp_content_guard_x509_cert_guards: []
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: Ensure x509 cert guards exist
3+
pulp.squeezer.x509_cert_guard:
4+
pulp_url: "{{ pulp_url }}"
5+
username: "{{ pulp_username }}"
6+
password: "{{ pulp_password }}"
7+
validate_certs: "{{ pulp_validate_certs | bool }}"
8+
name: "{{ item.name }}"
9+
description: "{{ item.description | default(omit) }}"
10+
ca_certificate: "{{ item.ca_certificate | default(omit) }}"
11+
state: "{{ item.state }}"
12+
with_items: "{{ pulp_content_guard_x509_cert_guards }}"
13+
loop_control:
14+
label: "{{ item.name }}"

roles/pulp_distribution/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ Example playbook
4242
base_path: pulp/pulp
4343
repository: pulp/pulp
4444
state: present
45-
# Distribute version 2 of the pulp/pulp repository.
45+
# Distribute version 2 of the pulp/pulp repository with a content guard.
4646
- name: pulp/pulp
4747
base_path: pulp/pulp
4848
repository: pulp/pulp
4949
version: 2
50+
content_guard: secure-content-guard
5051
state: present
5152
pulp_distribution_deb:
5253
# Distribute the latest version of the ubuntu-focal repository.
@@ -60,10 +61,11 @@ Example playbook
6061
repository: ubuntu-focal-security
6162
version: 2
6263
state: present
63-
# Distribute the same publication as the ubuntu-focal distribution.
64+
# Distribute the same publication as the ubuntu-focal distribution with a content guard.
6465
- name: ubuntu-focal-production
6566
base_path: ubuntu-focal-production
6667
distribution: ubuntu-focal
68+
content_guard: secure-content-guard
6769
state: present
6870
pulp_distribution_rpm:
6971
# Distribute the latest version of the centos-baseos repository.
@@ -77,9 +79,10 @@ Example playbook
7779
repository: centos-appstream
7880
version: 2
7981
state: present
80-
# Distribute the same publication as the centos-baseos distribution.
82+
# Distribute the same publication as the centos-baseos distribution with a content guard.
8183
- name: centos-baseos-production
8284
base_path: centos-baseos-production
8385
distribution: centos-baseos
86+
content_guard: secure-content-guard
8487
state: present
8588
```

roles/pulp_distribution/tasks/container.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
base_path: "{{ item.base_path }}"
1010
repository: "{{ item.repository }}"
1111
version: "{{ item.version | default(omit) }}"
12+
content_guard: "{{ item.content_guard | default(omit) }}"
1213
state: "{{ item.state }}"
1314
with_items: "{{ pulp_distribution_container }}"

roles/pulp_distribution/tasks/deb.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
name: "{{ item.name }}"
4747
base_path: "{{ item.base_path }}"
4848
publication: "{{ pubs[0].pulp_href if item.state == 'present' else omit }}"
49+
content_guard: "{{ item.content_guard | default(omit) }}"
4950
state: "{{ item.state }}"
5051
with_items: "{{ pulp_distribution_deb }}"
5152
when: >-

roles/pulp_distribution/tasks/rpm.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
name: "{{ item.name }}"
4747
base_path: "{{ item.base_path }}"
4848
publication: "{{ pubs[0].pulp_href if item.state == 'present' else omit }}"
49+
content_guard: "{{ item.content_guard | default(omit) }}"
4950
state: "{{ item.state }}"
5051
with_items: "{{ pulp_distribution_rpm }}"
5152
when: >-

0 commit comments

Comments
 (0)