Skip to content

Commit c346577

Browse files
committed
Support Let's Encrypt for Open OnDemand
1 parent eabf59b commit c346577

File tree

6 files changed

+59
-8
lines changed

6 files changed

+59
-8
lines changed

ansible/fatimage.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,35 @@
115115
when: "'openhpc' in group_names"
116116

117117
# - import_playbook: portal.yml
118-
- name: Open Ondemand server (packages)
118+
- name: Open OnDemand server (packages)
119119
include_role:
120120
name: osc.ood
121121
tasks_from: install-package.yml
122122
vars_from: "Rocky/{{ ansible_distribution_major_version }}.yml"
123123
when: "'openondemand' in group_names"
124124
# # FUTURE: install-apps.yml - this is git clones
125125

126-
- name: Open Ondemand server (apps)
126+
- name: Open OnDemand server (apps)
127127
include_role:
128128
name: osc.ood
129129
tasks_from: install-apps.yml
130130
vars_from: "Rocky/{{ ansible_distribution_major_version }}.yml"
131131
when: "'openondemand' in group_names"
132132

133-
- name: Open Ondemand remote desktop
133+
- name: Open OnDemand certbot
134+
import_role:
135+
name: openondemand
136+
tasks_from: certbot.yml
137+
when: "'openondemand' in group_names"
138+
139+
- name: Open OnDemand remote desktop
134140
import_role:
135141
name: openondemand
136142
tasks_from: vnc_compute.yml
137143

138144
when: "'openondemand_desktop' in group_names"
139145

140-
- name: Open Ondemand jupyter node
146+
- name: Open OnDemand jupyter node
141147
import_role:
142148
name: openondemand
143149
tasks_from: jupyter_compute.yml

ansible/roles/openondemand/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,14 @@ No other authentication options are required for this method.
4646

4747
### SSL Certificates
4848
This role enables SSL on the Open Ondemand server, using the following self-signed certificate & key which are autogenerated by the `mod_ssl` package installed as part of the `ondemand-apache` package. Replace with your own keys if required.
49-
- `openondemand_ssl_cert`: Optional. Default `/etc/pki/tls/certs/localhost.crt`.
50-
- `openondemand_ssl_cert_key`: Optional. Default `/etc/pki/tls/private/localhost.key`
49+
- `openondemand_ssl_cert`: Optional. Default `/etc/pki/tls/certs/localhost.crt` (unless `openondemand_certbot` is true).
50+
- `openondemand_ssl_cert_key`: Optional. Default `/etc/pki/tls/private/localhost.key` (unless `openondemand_certbot` is true).
51+
52+
Alternatively, you can generate a certificate from Let's Encrypt automatically by configuring the following variables:
53+
- `openondemand_certbot`: Optional. Default is false. Set to true to request a certificate from Let's Encrypt.
54+
- `openondemand_certbot_email`: Optional. Default is empty. Set to the admin email address if using Let's Encrypt.
55+
56+
If using Let's Encrypt, leave `openondemand_ssl_cert` and `openondemand_ssl_cert_key` set to their default values.
5157

5258
### Dashboard and application configuration
5359
- `openondemand_dashboard_docs_url`: Optional. URL of docs to show under Help in dashboard. Default `(undefined)`.

ansible/roles/openondemand/defaults/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ openondemand_oidc_remote_user_claim: preferred_username
1313
openondemand_oidc_scope: openid profile preferred_username
1414

1515
# SSL Certificates
16-
openondemand_ssl_cert: /etc/pki/tls/certs/localhost.crt
17-
openondemand_ssl_cert_key: /etc/pki/tls/private/localhost.key
16+
openondemand_certbot: false
17+
openondemand_certbot_email:
18+
openondemand_ssl_cert: "{{ '/etc/letsencrypt/live/' + openondemand_servername + '/fullchain.pem' if openondemand_certbot | bool else '/etc/pki/tls/certs/localhost.crt' }}"
19+
openondemand_ssl_cert_key: "{{ '/etc/letsencrypt/live/' + openondemand_servername + '/privkey.pem' if openondemand_certbot | bool else '/etc/pki/tls/private/localhost.key' }}"
1820

1921
# Dashboard and application config:
2022
openondemand_dashboard_docs_url: (undefined)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
- name: Install EPEL
3+
tags: install
4+
dnf:
5+
name: epel-release
6+
7+
- name: Install certbot
8+
tags: install
9+
dnf:
10+
name:
11+
- certbot
12+
- python3-certbot-apache
13+
14+
- block:
15+
- name: Validate that server name is set
16+
assert:
17+
that:
18+
- openondemand_servername | length > 0
19+
fail_msg: openondemand_servername must be set
20+
21+
- name: Validate that email address is set
22+
assert:
23+
that:
24+
- openondemand_certbot_email | length > 0
25+
fail_msg: openondemand_certbot_email must be set
26+
27+
- name: Generate Let's Encrypt certificate
28+
command: sudo certbot certonly --standalone -d {{ openondemand_servername }} -n -m {{ openondemand_certbot_email }} --agree-tos
29+
when: appliances_mode == 'configure'

ansible/roles/openondemand/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
when: appliances_mode != 'configure'
2222
# can't set vars: from a dict hence the workaround above
2323

24+
- include_tasks:
25+
file: certbot.yml
26+
when: openondemand_certbot | bool
27+
2428
- include_tasks:
2529
file: pam_auth.yml
2630
when: openondemand_auth | lower == 'basic_pam'

docs/openondemand.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ The appliance automatically configures Open OnDemand to proxy Grafana and adds a
4747

4848
# Access
4949
By default the appliance authenticates against OOD with basic auth through PAM. When creating a new environment, a new user with username `demo_user` will be created. Its password is found under `vault_openondemand_default_user` in the appliance secrets store in `environments/{ENV}/inventory/group_vars/all/secrets.yml`. Other users can be defined by overriding the `basic_users_users` variable in your environment (templated into `environments/{ENV}/inventory/group_vars/all/basic_users.yml` by default).
50+
51+
# Certificates
52+
53+
The default configuration uses using a self-signed certificate. Instead, you can bring your own certificate and key, or use Let's Encrypt. See [../ansible/roles/openondemand/README.md](../ansible/roles/openondemand/README.md) for more details.

0 commit comments

Comments
 (0)