Skip to content

Commit 812ded7

Browse files
committed
Add support for authenticated registries
Signed-off-by: Eric D. Helms <[email protected]>
1 parent dab6353 commit 812ded7

File tree

13 files changed

+51
-25
lines changed

13 files changed

+51
-25
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/playbooks/pull-images/pull-images.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
- "../../vars/images.yml"
99
- "../../vars/base.yaml"
1010
become: true
11-
tasks:
12-
- name: Install podman
13-
ansible.builtin.package:
14-
name:
15-
- podman
16-
11+
roles:
12+
- role: pre_install
13+
post_tasks:
1714
- name: Pull an image
1815
containers.podman.podman_image:
1916
name: "{{ item }}"

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
containers.podman.podman_image:
5656
name: "{{ candlepin_container_image }}:{{ candlepin_container_tag }}"
5757
state: present
58+
environment:
59+
REGISTRY_AUTH_FILE: "/etc/foreman/registry-auth.json"
5860

5961
- name: Deploy Candlepin quadlet
6062
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
containers.podman.podman_image:
44
name: "{{ foreman_container_image }}:{{ foreman_container_tag }}"
55
state: present
6+
environment:
7+
REGISTRY_AUTH_FILE: "/etc/foreman/registry-auth.json"
68

79
- name: Create secret for DATABASE_URL
810
containers.podman.podman_secret:
@@ -224,8 +226,7 @@
224226
- bin/rails db:migrate && bin/rails db:seed
225227
detach: false
226228
network: host
227-
env:
228-
FOREMAN_ENABLED_PLUGINS: "{{ foreman_plugins | join(' ') }}"
229+
env: "{{ {'FOREMAN_ENABLED_PLUGINS': foreman_plugins | join(' ')} | combine({'REGISTRY_AUTH_FILE': '/etc/foreman/registry-auth.json'}) }}"
229230
secrets:
230231
- 'foreman-database-url,type=env,target=DATABASE_URL'
231232
- '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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
containers.podman.podman_image:
44
name: "{{ postgresql_container_image }}:{{ postgresql_container_tag }}"
55
state: present
6+
environment:
7+
REGISTRY_AUTH_FILE: "/etc/foreman/registry-auth.json"
68

79
- name: Create PostgreSQL storage directory
810
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 }}"

0 commit comments

Comments
 (0)