Skip to content

Commit dc58a25

Browse files
wtripp180901sjpb
andauthored
Change defaults so a cookiecutter environment is fully functional (#473)
* cookiecutter environment now has working defaults * updated docs * refactored ood demo user into cookiecutter * updated docs * changed secret name * Doc changes Co-authored-by: Steve Brasier <[email protected]> * rename * replaced testuser with demo_user * selinux now defaults to disabled * bump images * updated readme * moved files and removed redundant ood config * environments now have grafana anonymous auth by default * docs update Co-authored-by: Steve Brasier <[email protected]> --------- Co-authored-by: Steve Brasier <[email protected]>
1 parent 781c2d4 commit dc58a25

File tree

20 files changed

+49
-32
lines changed

20 files changed

+49
-32
lines changed

.github/workflows/stackhpc.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ jobs:
9999
. venv/bin/activate
100100
. environments/.stackhpc/activate
101101
ansible-playbook ansible/adhoc/generate-passwords.yml
102-
echo vault_testuser_password: "$TESTUSER_PASSWORD" > $APPLIANCES_ENVIRONMENT_ROOT/inventory/group_vars/all/test_user.yml
102+
echo vault_demo_user_password: "$DEMO_USER_PASSWORD" > $APPLIANCES_ENVIRONMENT_ROOT/inventory/group_vars/all/test_user.yml
103103
env:
104-
TESTUSER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
104+
DEMO_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
105105

106106
- name: Provision nodes using fat image
107107
id: provision_servers
@@ -163,12 +163,12 @@ jobs:
163163
--spider \
164164
--server-response \
165165
--no-check-certificate \
166-
--http-user=testuser \
167-
--http-password=${TESTUSER_PASSWORD} https://${openondemand_servername} \
166+
--http-user=demo_user \
167+
--http-password=${DEMO_USER_PASSWORD} https://${openondemand_servername} \
168168
2>&1)
169169
(echo $statuscode | grep "200 OK") || (echo $statuscode && exit 1)
170170
env:
171-
TESTUSER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
171+
DEMO_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
172172

173173
# - name: Build environment-specific compute image
174174
# id: packer_build

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ To deploy this infrastructure, ensure the venv and the environment are [activate
104104

105105
export OS_CLOUD=openstack
106106
cd environments/$ENV/terraform/
107+
tofu init
107108
tofu apply
108109

109110
and follow the prompts. Note the OS_CLOUD environment variable assumes that OpenStack credentials are defined using a [clouds.yaml](https://docs.openstack.org/python-openstackclient/latest/configuration/index.html#clouds-yaml) file in a default location with the default cloud name of `openstack`.

ansible/roles/passwords/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ slurm_appliance_secrets:
1010
vault_freeipa_admin_password: "{{ vault_freeipa_admin_password | default(lookup('password', '/dev/null')) }}"
1111
vault_k3s_token: "{{ vault_k3s_token | default(lookup('ansible.builtin.password', '/dev/null', length=64)) }}"
1212
vault_pulp_admin_password: "{{ vault_pulp_admin_password | default(lookup('password', '/dev/null', chars=['ascii_letters', 'digits'])) }}"
13+
vault_demo_user_password: "{{ vault_demo_user_password | default(lookup('password', '/dev/null')) }}"
1314

1415
secrets_openhpc_mungekey_default:
1516
content: "{{ lookup('pipe', 'dd if=/dev/urandom bs=1 count=1024 2>/dev/null | base64') }}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
- name: Assert secrets created
22
assert:
3-
that: (hostvars[inventory_hostname].keys() | select('contains', 'vault_') | length) > 1 # 1 as may have vault_testuser_password defined in dev
3+
that: (hostvars[inventory_hostname].keys() | select('contains', 'vault_') | length) > 1 # 1 as may have vault_demo_user_password defined in dev
44
fail_msg: "No inventory variables 'vault_*' found: Has ansible/adhoc/generate-passwords.yml been run?"

docs/openondemand.README.md renamed to docs/openondemand.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ The above functionality is configured by running the `ansible/portal.yml` playbo
3030

3131
See the [ansible/roles/openondemand/README.md](../ansible/roles/openondemand/README.md) for more details on the variables described below.
3232

33-
At minimum the following must be defined:
34-
- `openondemand_servername` - this must be defined for both `openondemand` and `grafana` hosts (when Grafana is enabled). It is suggested to place it groupvars for `all`.
35-
- `openondemand_auth` and any corresponding options.
36-
- `openondemand_desktop_partition` and `openondemand_jupyter_partition` if the corresponding inventory groups are defined.
37-
- `openondemand_host_regex` if `openondemand_desktop` or `openondemand_jupyter` inventory groups are defined and/or proxying Grafana via Open Ondemand is required.
33+
The following variables have been given default values to allow Open Ondemand to work in a newly created environment without additional configuration, but generally should be overridden in `environment/site/inventory/group_vars/all/` with site-specific values:
34+
- `openondemand_servername` - this must be defined for both `openondemand` and `grafana` hosts (when Grafana is enabled). Default is `ansible_host` (i.e. the IP address) of the first host in the `openondemand` group.
35+
- `openondemand_auth` and any corresponding options. Defaults to `basic_pam`.
36+
- `openondemand_desktop_partition` and `openondemand_jupyter_partition` if the corresponding inventory groups are defined. Defaults to the first compute group defined in the `compute` Terraform variable in `environments/$ENV/terraform`.
3837

3938
It is also recommended to set:
4039
- `openondemand_dashboard_support_url`
@@ -45,3 +44,6 @@ If shared filesystems other than `$HOME` are available, add paths to `openondema
4544
The appliance automatically configures Open Ondemand to proxy Grafana and adds a link to it on the Open Ondemand dashboard. This means no external IP (or SSH proxying etc) is required to access Grafana (which by default is deployed on the control node). To allow users to authenticate to Grafana, the simplest option is to enable anonymous (View-only) login by setting `grafana_auth_anonymous` (see [environments/common/inventory/group_vars/all/grafana.yml](../environments/common/inventory/group_vars/all/grafana.yml)[^1]).
4645

4746
[^1]: Note that if `openondemand_auth` is `basic_pam` and anonymous Grafana login is enabled, the appliance will (by default) configure Open Ondemand's Apache server to remove the Authorisation header from proxying of all `node/` addresses. This is done as otherwise Grafana tries to use this header to authenticate, which fails with the default configuration where only the admin Grafana user `grafana` is created. Note that the removal of this header in this configuration means it cannot be used to authenticate proxied interactive applications - however the appliance-deployed remote desktop and Jupyter Notebook server applications use other authentication methods. An alternative if using `basic_pam` is not to enable anonymous Grafana login and to create Grafana users matching the local users (e.g. in `environments/<env>/hooks/post.yml`).
47+
48+
# Access
49+
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).

docs/production.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ and referenced from the `site` and `production` environments, e.g.:
9898

9999
- Configure Open OpenOndemand - see [specific documentation](openondemand.README.md).
100100

101+
- Remove the `demo_user` user from `environments/$ENV/inventory/group_vars/all/basic_users.yml`
102+
103+
- Consider whether having (read-only) access to Grafana without login is OK. If not, remove `grafana_auth_anonymous` in `environments/$ENV/inventory/group_vars/all/grafana.yml`
104+
101105
- Modify `environments/site/terraform/nodes.tf` to provide fixed IPs for at least
102106
the control node, and (if not using FIPs) the login node(s):
103107

environments/.caas/inventory/group_vars/all/selinux.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
test_user_password: "{{ lookup('env', 'TESTUSER_PASSWORD') | default(vault_testuser_password, true) }}" # CI uses env, debug can set vault_testuser_password
1+
test_demo_user_password: "{{ lookup('env', 'DEMO_USER_PASSWORD') | default(vault_demo_user_password, true) }}" # CI uses env, debug can set vault_demo_user_password
22

33
basic_users_users:
4-
- name: testuser # can't use rocky as $HOME isn't shared!
5-
password: "{{ test_user_password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}" # idempotent
4+
- name: demo_user # can't use rocky as $HOME isn't shared!
5+
password: "{{ test_demo_user_password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}" # idempotent
66
uid: 1005

environments/.stackhpc/inventory/group_vars/all/freeipa.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# NB: Users defined this way have expired passwords
44
freeipa_users:
5-
- name: testuser # can't use rocky as $HOME isn't shared!
6-
password: "{{ test_user_password }}"
5+
- name: demo_user # can't use rocky as $HOME isn't shared!
6+
password: "{{ test_demo_user_password }}"
77
givenname: test
88
sn: test
99

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
openondemand_servername: "{{ hostvars[ groups['openondemand'] | first].ansible_host }}" # Use a SOCKS proxy to acccess
1+
openondemand_auth: basic_pam
2+
openondemand_jupyter_partition: standard
3+
openondemand_desktop_partition: standard
4+
#openondemand_dashboard_support_url:
5+
#openondemand_dashboard_docs_url:
6+
#openondemand_filesapp_paths:
7+
ondemand_package: ondemand-"{{ ondemand_package_version }}"
8+
ondemand_package_version: '3.1.10'

environments/.stackhpc/inventory/group_vars/openondemand/overrides.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

environments/.stackhpc/inventory/group_vars/selinux/overrides.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

environments/common/inventory/group_vars/all/openondemand.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
# NB: Variables prefixed ood_ are all from https://github.com/OSC/ood-ansible
77

8-
# openondemand_servername: '' # Must be defined when using openondemand
8+
openondemand_servername: "{{ hostvars[groups['openondemand'].0].ansible_host if groups['openondemand'] else '' }}"
9+
10+
openondemand_auth: basic_pam
11+
12+
openondemand_jupyter_partition: "{{ openhpc_slurm_partitions[0]['name'] }}"
13+
openondemand_desktop_partition: "{{ openhpc_slurm_partitions[0]['name'] }}"
914

1015
# Regex defining hosts which openondemand can proxy; the default regex is compute nodes (for apps) and grafana host,
1116
# e.g. if the group `compute` has hosts `compute-{0,1,2,..}` this will be '(compute-\d+)|(control)'.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22

3-
selinux_state: permissive
3+
selinux_state: disabled
44
selinux_policy: targeted

environments/common/layouts/everything

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ login
3636
[block_devices:children]
3737
# Environment-specific so not defined here
3838

39-
[basic_users]
39+
[basic_users:children]
4040
# Add `openhpc` group to add Slurm users via creation of users on each node.
41+
openhpc
4142

4243
[openondemand:children]
4344
# Host to run Open Ondemand server on - subset of login
@@ -51,8 +52,9 @@ compute
5152
# Subset of compute to run a Jupyter Notebook servers on via Open Ondemand
5253
compute
5354

54-
[etc_hosts]
55+
[etc_hosts:children]
5556
# Hosts to manage /etc/hosts e.g. if no internal DNS. See ansible/roles/etc_hosts/README.md
57+
cluster
5658

5759
[cuda]
5860
# Hosts to install NVIDIA CUDA on - see ansible/roles/cuda/README.md
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
basic_users_users:
2+
- name: demo_user
3+
password: "{% raw %}{{ vault_demo_user_password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}{% endraw %}" # idempotent
4+
uid: 1005
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
grafana_auth_anonymous: true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variable "cluster_name" {
66
variable "cluster_domain_suffix" {
77
type = string
88
description = "Domain suffix for cluster"
9-
default = "invalid"
9+
default = "internal"
1010
}
1111

1212
variable "cluster_net" {

0 commit comments

Comments
 (0)