Skip to content

Commit dad614e

Browse files
committed
Support Let's Encrypt for Open OnDemand
1 parent bd6573a commit dad614e

File tree

8 files changed

+57
-5
lines changed

8 files changed

+57
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Before starting ensure that:
3333
- You have an SSH keypair defined in OpenStack, with the private key available on the deploy host.
3434
- Created instances have access to internet (note proxies can be setup through the appliance if necessary).
3535
- Created instances have accurate/synchronised time (for VM instances this is usually provided by the hypervisor; if not or for bare metal instances it may be necessary to configure a time service via the appliance).
36-
- Three security groups are present: ``default`` allowing intra-cluster communication, ``SSH`` allowing external access via SSH and ``HTTPS`` allowing access for Open OnDemand.
36+
- Four security groups are present: ``default`` allowing intra-cluster communication, ``SSH`` allowing external access via SSH, and ``HTTP`` and ``HTTPS`` allowing access for Open OnDemand.
3737

3838
### Setup deploy host
3939

ansible/fatimage.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@
130130
vars_from: "Rocky/{{ ansible_distribution_major_version }}.yml"
131131
when: "'openondemand' in group_names"
132132

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

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.

environments/skeleton/{{cookiecutter.environment}}/tofu/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ variable "login_security_groups" {
259259
default = [
260260
"default", # allow all in-cluster services
261261
"SSH", # access via ssh
262+
"HTTP", # HTTP-01 challenge and redirect to HTTPS
262263
"HTTPS", # access OpenOndemand
263264
]
264265
}

0 commit comments

Comments
 (0)