Skip to content

Commit cf006d9

Browse files
committed
Add support for authenticated registries
1 parent dab6353 commit cf006d9

File tree

12 files changed

+105
-15
lines changed

12 files changed

+105
-15
lines changed

docs/deployment.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,27 @@ A deployment can have multiple base features enabled.
4444

4545
### Authenticated Registry Handling
4646

47-
In the non-default case where the image sources are supplied from an authenticated location users will need to inject a login step.
48-
For example, users might be consuming a custom build of the Foreman image.
47+
If you need to pull images from private or authenticated container registries, you can configure registry authentication using Podman's auth file.
4948

50-
In this case, the happy path becomes:
49+
#### Setting up Registry Authentication
5150

52-
1. Configure package repository
53-
2. Install `foremanctl` package
54-
3. Run deployment utility and provide registry username and token
51+
1. **Login to your registry** using Podman and save credentials to the default auth file location:
52+
```bash
53+
podman login <registry> --authfile=/etc/foreman/registry-auth.json
54+
```
5555

56-
The advanced path breaks down to:
56+
2. **Ensure proper permissions** on the auth file:
57+
```bash
58+
sudo chmod 600 /etc/foreman/registry-auth.json
59+
sudo chown root:root /etc/foreman/registry-auth.json
60+
```
5761

58-
1. Configure package repository
59-
2. Install `foremanctl` package
60-
3. Login to registry with podman
61-
3. Pull images
62-
4. Generate certificates
63-
5. Execute pre-requisite checks
64-
6. Run deployment utility
65-
7. Post deploy checks
62+
3. **Deploy as usual** - foremanctl will automatically detect and use the authentication file:
63+
```bash
64+
./foremanctl deploy
65+
```
66+
67+
This approach integrates seamlessly with both the happy path and advanced deployment paths described above. The authentication is handled transparently during image pulling operations.
6668

6769
## Deployer Stages
6870

src/roles/candlepin/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ candlepin_ciphers:
1414
- TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
1515
candlepin_container_image: quay.io/foreman/candlepin
1616
candlepin_container_tag: "4.4.14"
17+
candlepin_registry_auth_file: /etc/foreman/registry-auth.json
1718

1819
candlepin_database_host: localhost
1920
candlepin_database_port: 5432

src/roles/candlepin/tasks/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,23 @@
5151
ansible.builtin.include_tasks:
5252
file: artemis.yml
5353

54+
- name: Check if registry auth file exists
55+
ansible.builtin.stat:
56+
path: "{{ candlepin_registry_auth_file }}"
57+
register: candlepin_registry_auth_file_stat
58+
59+
- name: Set registry auth file permissions
60+
ansible.builtin.file:
61+
path: "{{ candlepin_registry_auth_file }}"
62+
mode: '0600'
63+
when: candlepin_registry_auth_file_stat.stat.exists
64+
5465
- name: Pull the Candlepin container image
5566
containers.podman.podman_image:
5667
name: "{{ candlepin_container_image }}:{{ candlepin_container_tag }}"
5768
state: present
69+
environment:
70+
REGISTRY_AUTH_FILE: "{{ candlepin_registry_auth_file if candlepin_registry_auth_file_stat.stat.exists else omit }}"
5871

5972
- name: Deploy Candlepin quadlet
6073
containers.podman.podman_container:

src/roles/foreman/defaults/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
foreman_container_image: "quay.io/foreman/foreman"
33
foreman_container_tag: "nightly"
4+
foreman_registry_auth_file: /etc/foreman/registry-auth.json
45

56
foreman_database_name: foreman
67
foreman_database_user: foreman

src/roles/foreman/tasks/main.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
---
2+
- name: Check if registry auth file exists
3+
ansible.builtin.stat:
4+
path: "{{ foreman_registry_auth_file }}"
5+
register: foreman_registry_auth_file_stat
6+
7+
- name: Set registry auth file permissions
8+
ansible.builtin.file:
9+
path: "{{ foreman_registry_auth_file }}"
10+
mode: '0600'
11+
when: foreman_registry_auth_file_stat.stat.exists
12+
213
- name: Pull the Foreman container image
314
containers.podman.podman_image:
415
name: "{{ foreman_container_image }}:{{ foreman_container_tag }}"
516
state: present
17+
environment:
18+
REGISTRY_AUTH_FILE: "{{ foreman_registry_auth_file if foreman_registry_auth_file_stat.stat.exists else omit }}"
619

720
- name: Create secret for DATABASE_URL
821
containers.podman.podman_secret:
@@ -226,6 +239,8 @@
226239
network: host
227240
env:
228241
FOREMAN_ENABLED_PLUGINS: "{{ foreman_plugins | join(' ') }}"
242+
environment:
243+
REGISTRY_AUTH_FILE: "{{ foreman_registry_auth_file if foreman_registry_auth_file_stat.stat.exists else omit }}"
229244
secrets:
230245
- 'foreman-database-url,type=env,target=DATABASE_URL'
231246
- 'foreman-seed-admin-user,type=env,target=SEED_ADMIN_USER'

src/roles/postgresql/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
postgresql_container_image: quay.io/sclorg/postgresql-13-c9s
33
postgresql_container_tag: "latest"
4+
postgresql_registry_auth_file: /etc/foreman/registry-auth.json
45
postgresql_container_name: postgresql
56
postgresql_network: host
67
postgresql_restart_policy: always

src/roles/postgresql/tasks/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
---
2+
- name: Check if registry auth file exists
3+
ansible.builtin.stat:
4+
path: "{{ postgresql_registry_auth_file }}"
5+
register: postgresql_registry_auth_file_stat
6+
7+
- name: Set registry auth file permissions
8+
ansible.builtin.file:
9+
path: "{{ postgresql_registry_auth_file }}"
10+
mode: '0600'
11+
when: postgresql_registry_auth_file_stat.stat.exists
12+
213
- name: Pull PostgreSQL container image
314
containers.podman.podman_image:
415
name: "{{ postgresql_container_image }}:{{ postgresql_container_tag }}"
516
state: present
17+
environment:
18+
REGISTRY_AUTH_FILE: "{{ postgresql_registry_auth_file if postgresql_registry_auth_file_stat.stat.exists else omit }}"
619

720
- name: Create PostgreSQL storage directory
821
ansible.builtin.file:

src/roles/pre_install/tasks/main.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@
1616
- python3-libsemanage
1717
- python3-psycopg2
1818
- python3-requests
19+
20+
- name: Create foreman configuration directory
21+
ansible.builtin.file:
22+
path: /etc/foreman
23+
state: directory
24+
owner: root
25+
group: root
26+
mode: '0755'

src/roles/pulp/defaults/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
pulp_container_image: quay.io/foreman/pulp
33
pulp_container_tag: "3.73"
4+
pulp_registry_auth_file: /etc/foreman/registry-auth.json
45
pulp_api_image: "{{ pulp_container_image }}:{{ pulp_container_tag }}"
56
pulp_content_image: "{{ pulp_container_image }}:{{ pulp_container_tag }}"
67
pulp_worker_image: "{{ pulp_container_image }}:{{ pulp_container_tag }}"

src/roles/pulp/tasks/main.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1+
- name: Check if registry auth file exists
2+
ansible.builtin.stat:
3+
path: "{{ pulp_registry_auth_file }}"
4+
register: pulp_registry_auth_file_stat
5+
6+
- name: Set registry auth file permissions
7+
ansible.builtin.file:
8+
path: "{{ pulp_registry_auth_file }}"
9+
mode: '0600'
10+
when: pulp_registry_auth_file_stat.stat.exists
11+
112
- name: Pull the Pulp API container image
213
containers.podman.podman_image:
314
name: "{{ pulp_api_image }}"
415
state: present
16+
environment:
17+
REGISTRY_AUTH_FILE: "{{ pulp_registry_auth_file if pulp_registry_auth_file_stat.stat.exists else omit }}"
518

619
- name: Pull the Pulp Content container image
720
containers.podman.podman_image:
821
name: "{{ pulp_content_image }}"
922
state: present
23+
environment:
24+
REGISTRY_AUTH_FILE: "{{ pulp_registry_auth_file if pulp_registry_auth_file_stat.stat.exists else omit }}"
1025

1126
- name: Pull the Pulp Worker container image
1227
containers.podman.podman_image:
1328
name: "{{ pulp_worker_image }}"
1429
state: present
30+
environment:
31+
REGISTRY_AUTH_FILE: "{{ pulp_registry_auth_file if pulp_registry_auth_file_stat.stat.exists else omit }}"
1532

1633
- name: Create Pulp storage
1734
ansible.builtin.file:
@@ -199,6 +216,8 @@
199216
detach: false
200217
network: host
201218
volumes: "{{ pulp_volumes }}"
219+
environment:
220+
REGISTRY_AUTH_FILE: "{{ pulp_registry_auth_file if pulp_registry_auth_file_stat.stat.exists else omit }}"
202221
secrets:
203222
- 'pulp-symmetric-key,type=mount,target=/etc/pulp/certs/database_fields.symmetric.key'
204223
- 'pulp-db-password,type=env,target=PULP_DATABASES__default__PASSWORD'
@@ -212,6 +231,8 @@
212231
detach: false
213232
network: host
214233
volumes: "{{ pulp_volumes }}"
234+
environment:
235+
REGISTRY_AUTH_FILE: "{{ pulp_registry_auth_file if pulp_registry_auth_file_stat.stat.exists else omit }}"
215236
secrets:
216237
- 'pulp-symmetric-key,type=mount,target=/etc/pulp/certs/database_fields.symmetric.key'
217238
- 'pulp-db-password,type=env,target=PULP_DATABASES__default__PASSWORD'

0 commit comments

Comments
 (0)