Skip to content

Commit a8d4e17

Browse files
committed
k3s token now templated into terraform vars
1 parent 2f26fa1 commit a8d4e17

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

ansible/roles/passwords/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ slurm_appliance_secrets:
1212
secrets_openhpc_mungekey_default:
1313
content: "{{ lookup('pipe', 'dd if=/dev/urandom bs=1 count=1024 2>/dev/null | base64') }}"
1414

15+
k3s_secrets:
16+
k3s_token: "{{ lookup('ansible.builtin.password', '/dev/null', length=64) }}"
17+
1518
openhpc_passwords_output_path: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') | default(undefined, true) | mandatory('You must define the APPLIANCES_ENVIRONMENT_ROOT environment variable') }}/inventory/group_vars/all/secrets.yml"

ansible/roles/passwords/tasks/main.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
delegate_to: localhost
88
run_once: true
99

10-
- name: Generate k3s token
11-
ansible.builtin.set_fact:
12-
k3s_token_secret: ""
13-
1410
- name: Generate k3s token and add to terraform
15-
vars:
16-
token: "{{ lookup('ansible.builtin.password', '/dev/null', length=64) }}"
17-
replace:
18-
path: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/terraform/variables.tf"
19-
regexp: "k3s_token_replace_me"
20-
replace: "{{ token }}"
11+
template:
12+
src: k3s-token.auto.tfvars.json
13+
dest: "{{ lookup('env', 'APPLIANCES_ENVIRONMENT_ROOT') }}/terraform/k3s-token.auto.tfvars.json"
14+
delegate_to: localhost
15+
run_once: true
2116

2217

2318
# - name: Ensure munge key directory exists
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ k3s_secrets | to_nice_json }}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,5 @@ variable "security_group_ids" {
6969
}
7070

7171
variable "k3s_token" {
72-
description = "Random cryptographically secure string for K3s token (must be set by ../compute.tf)"
7372
type = string
7473
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,5 @@ variable "root_volume_size" {
133133
}
134134

135135
variable "k3s_token" {
136-
description = "Random cryptographically secure string for K3s token"
137136
type = string
138-
default = "k3s_token_replace_me"
139137
}

0 commit comments

Comments
 (0)