Skip to content

Commit f3b994d

Browse files
committed
Allow Prometheus and HAProxy to be installed as the non-privileged user.
Reductionist can be used with https, either with the optional Ansible playbook Step deployment or with third party certificates. Documentation updated for installation of 3rd party certificates.
1 parent 528d532 commit f3b994d

File tree

2 files changed

+44
-25
lines changed

2 files changed

+44
-25
lines changed

deployment/site.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
- name: Set step config path
8585
set_fact:
86-
step_config_path: "{{ ansible_facts.env.HOME }}/step"
86+
step_config_path: "{{ ansible_env.HOME }}/step"
8787

8888
- name: Stat provisioner password file
8989
ansible.builtin.stat:
@@ -161,7 +161,7 @@
161161

162162
- name: Set step config path
163163
set_fact:
164-
step_config_path: "{{ ansible_facts.env.HOME }}/step"
164+
step_config_path: "{{ ansible_env.HOME }}/step"
165165

166166
- name: Regenerate step config if requested
167167
ansible.builtin.file:
@@ -300,41 +300,41 @@
300300
hosts: prometheus
301301
tags:
302302
- prometheus
303-
become: true
304303
tasks:
305304
- name: Assert that there is only one Prometheus server
306305
ansible.builtin.assert:
307306
that:
308307
groups['prometheus'] | length == 1
309308

310-
- name: Ensure /etc/prometheus directory exists
309+
- name: Ensure non-privileged user's prometheus directory exists
311310
ansible.builtin.file:
312-
path: /etc/prometheus
311+
path: "{{ ansible_env.HOME }}/prometheus"
313312
state: directory
314313
mode: "0755"
315314

316315
- name: Ensure CA certificate is copied
317316
ansible.builtin.copy:
318317
src: "{{ prometheus_cacert }}"
319-
dest: /etc/prometheus/cacert.pem
318+
dest: "{{ ansible_env.HOME }}/prometheus/cacert.pem"
320319
mode: "0644"
321320
register: prometheus_cacert
322321

323322
- name: Ensure prometheus.yml is templated
324323
ansible.builtin.template:
325324
src: prometheus.yml.j2
326-
dest: /etc/prometheus/prometheus.yml
325+
dest: "{{ ansible_env.HOME }}/prometheus/prometheus.yml"
327326
mode: "0644"
328327
register: prometheus_yml
329328

330329
- name: Ensure prometheus container is running
331330
containers.podman.podman_container:
332331
name: prometheus
332+
privileged: true # Rocky 9 SELinux prevents visibility of the host volumes
333333
image: docker.io/prom/prometheus
334334
network: host
335335
restart: "{{ prometheus_yml is changed or prometheus_cacert is changed }}"
336336
volumes:
337-
- "/etc/prometheus:/etc/prometheus:ro"
337+
- "{{ ansible_env.HOME }}/prometheus:/etc/prometheus:ro"
338338
- "prometheus:/prometheus"
339339
become: false
340340

@@ -406,7 +406,6 @@
406406
hosts: haproxy
407407
tags:
408408
- haproxy
409-
become: true
410409
tasks:
411410
# Currently we are not deploying any failover mechanism such as keepalived,
412411
# so limit to one HAProxy server.
@@ -424,28 +423,28 @@
424423
register: result
425424
loop: "{{ query('inventory_hostnames', 'reductionist') }}"
426425

427-
- name: Ensure /etc/haproxy directory exists
426+
- name: Ensure non-privileged user's haproxy directory exists
428427
ansible.builtin.file:
429-
path: /etc/haproxy
428+
path: "{{ ansible_env.HOME }}/haproxy"
430429
state: directory
431430
mode: "0755"
432431

433432
- name: Ensure haproxy.cfg is templated
434433
ansible.builtin.template:
435434
src: haproxy.cfg.j2
436-
dest: /etc/haproxy/haproxy.cfg
435+
dest: "{{ ansible_env.HOME }}/haproxy/haproxy.cfg"
437436
mode: "0644"
438437
register: haproxy_cfg
439438

440439
- name: Ensure haproxy container is running
441440
containers.podman.podman_container:
442441
name: haproxy
442+
privileged: true # Rocky 9 SELinux prevents visibility of the host volumes
443443
image: docker.io/haproxy:2.8
444444
network: host
445445
restart: "{{ haproxy_cfg is changed }}"
446446
volumes:
447-
- "/etc/haproxy:/usr/local/etc/haproxy:ro"
448-
become: false
447+
- "{{ ansible_env.HOME }}/haproxy:/usr/local/etc/haproxy:ro"
449448

450449
- name: Wait for reductionist server to be accessible via HAProxy
451450
ansible.builtin.uri:

docs/deployment.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,50 +136,70 @@ ansible-galaxy collection install -r deployment/requirements.yml
136136
Podman will be used to run containers under the same user account used for ansible deployment.
137137
To install requisite system packages some tasks will require sudo `privileged` access.
138138

139-
To run the entire playbook as an unprivileged user prompting for a sudo password:
139+
To run the entire playbook as a non-privileged user prompting for a sudo password:
140140
```sh
141141
ansible-playbook -i deployment/inventory deployment/site.yml -K
142142
```
143143

144144
To run specific plays the following tags are supported and may be specified via `--tags <tag1,tag2>`:
145145

146-
* `podman` - runs privileged tasks
146+
* `podman` - runs privileged tasks to install packages
147147
* `step-ca`
148-
* `step` - runs privileged tasks
148+
* `step` - runs privileged tasks to install and the CA certificate
149149
* `minio`
150-
* `prometheus` - runs privileged tasks
150+
* `prometheus`
151151
* `jaeger`
152152
* `reductionist`
153-
* `haproxy` - runs privileged tasks
153+
* `haproxy`
154154

155155
### Minimal deployment of Podman and the Reductionist
156156

157157
Podman is a prerequisite for running the Reductionist.
158-
Podman can run containers as an **unprivileged** user, however this user must have **linger** enabled on their account to allow Podman to continue to run after logging out of the user session.
158+
Podman can run containers as an **non-privileged** user, however this user must have **linger** enabled on their account to allow Podman to continue to run after logging out of the user session.
159159

160-
To enable **linger** support for the unprivileged user:
160+
To enable **linger** support for the non-privileged user:
161161
```sh
162-
sudo loginctl enable-linger <unprivileged user>
162+
sudo loginctl enable-linger <non-privileged user>
163163
```
164164

165-
Alternatively, run the optional `podman` play to install Podman as an **unprivileged** user. The following will prompt for the sudo password to escalate privileges only for package installation and for enabling **linger** for the unprivileged user:
165+
Alternatively, run the optional `podman` play to install Podman as an **non-privileged** user. The following will prompt for the sudo password to escalate privileges only for package installation and for enabling **linger** for the non-privileged user:
166166
```sh
167167
ansible-playbook -i deployment/inventory deployment/site.yml --tags podman -K
168168
```
169169

170-
Then to run the `reductionist` play, again as the **unprivileged** user:
170+
Then to run the `reductionist` play, again as the **non-privileged** user:
171171
```sh
172172
ansible-playbook -i deployment/inventory deployment/site.yml --tags reductionist
173173
```
174174

175175
Podman containers require a manual restart after a system reboot.
176-
This requires logging into the host(s) running the Reductionist as the **unprivileged** user to run:
176+
This requires logging into the host(s) running the Reductionist as the **non-privileged** user to run:
177177
```sh
178178
podman restart reductionist
179179
```
180180

181181
Automatic restart on boot can be enabled via **systemd**, not covered by this documentation.
182182

183+
### Using SSL/TLS certificates with the Reductionist
184+
185+
To enable **https** connections edit `deployment/group_vars/all` before deployment as set:
186+
187+
```
188+
REDUCTIONIST_HTTPS: "true"
189+
```
190+
191+
Note, this is the default.
192+
193+
Create a `certs` directory under the home directory of the non-privileged deployment user.
194+
Ensure the following files are added to the this directory:
195+
196+
| Filename | Description |
197+
| -------- | ------- |
198+
| certs/key.pem | Private key file |
199+
| certs/cert.pem | Certificate file including any intermediates |
200+
201+
Certificates can be added post Reductionist deployment but the Reductionist's container will need to be restarted afterwards.
202+
183203
## Usage
184204

185205
Once deployed, the Reductionist API is accessible on port 8080 by HAProxy. The Prometheus UI is accessible on port 9090 on the host running Prometheus. The Jaeger UI is accessible on port 16686 on the host running Jaeger.

0 commit comments

Comments
 (0)