Skip to content

Commit bc0c66c

Browse files
authored
Merge pull request #774 from stackhpc/fix/caas-secrets
Make CaaS specific role: `persist_openhpc_secrets` idempotent
2 parents b2ed670 + 7911ee0 commit bc0c66c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

ansible/roles/persist_openhpc_secrets/tasks/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414
loop:
1515
- "{{ appliances_state_dir }}/ansible.facts.d"
1616
- "/etc/ansible/facts.d"
17-
17+
18+
- name: Load existing OpenHPC secrets if present
19+
ansible.builtin.setup:
20+
filter: ansible_local
21+
when: openhpc_secrets_stat.stat.exists
22+
1823
- name: Write OpenHPC secrets
1924
template:
2025
src: openhpc_secrets.fact
2126
dest: "{{ appliances_state_dir }}/ansible.facts.d/openhpc_secrets.fact"
2227
owner: root
2328
mode: 0600
24-
when: "not openhpc_secrets_stat.stat.exists"
2529

2630
- name: Symlink persistent facts to facts_path
2731
file:
@@ -30,6 +34,6 @@
3034
dest: /etc/ansible/facts.d/openhpc_secrets.fact
3135
owner: root
3236

33-
- name: Read facts
37+
- name: Refresh facts to pick up any new secrets
3438
ansible.builtin.setup:
3539
filter: ansible_local
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
2-
"vault_azimuth_user_password": "{{ lookup('password', '/dev/null') }}",
3-
"vault_grafana_admin_password": "{{ lookup('password', '/dev/null') }}",
4-
"vault_elasticsearch_admin_password": "{{ lookup('password', '/dev/null') }}",
5-
"vault_elasticsearch_kibana_password": "{{ lookup('password', '/dev/null') }}",
6-
"vault_mysql_root_password": "{{ lookup('password', '/dev/null') }}",
7-
"vault_mysql_slurm_password": "{{ lookup('password', '/dev/null') }}",
8-
"vault_openhpc_mungekey": "{{ lookup('pipe', 'dd if=/dev/urandom bs=1 count=1024 2>/dev/null | base64') | regex_replace('\s+', '') }}"
2+
"vault_azimuth_user_password": "{{ ansible_local.openhpc_secrets.vault_azimuth_user_password | default(lookup('password', '/dev/null')) }}",
3+
"vault_grafana_admin_password": "{{ ansible_local.openhpc_secrets.vault_grafana_admin_password | default(lookup('password', '/dev/null')) }}",
4+
"vault_elasticsearch_admin_password": "{{ ansible_local.openhpc_secrets.vault_elasticsearch_admin_password | default(lookup('password', '/dev/null')) }}",
5+
"vault_elasticsearch_kibana_password": "{{ ansible_local.openhpc_secrets.vault_elasticsearch_kibana_password | default(lookup('password', '/dev/null')) }}",
6+
"vault_mysql_root_password": "{{ ansible_local.openhpc_secrets.vault_mysql_root_password | default(lookup('password', '/dev/null')) }}",
7+
"vault_mysql_slurm_password": "{{ ansible_local.openhpc_secrets.vault_mysql_slurm_password | default(lookup('password', '/dev/null')) }}",
8+
"vault_openhpc_mungekey": "{{ ansible_local.openhpc_secrets.vault_openhpc_mungekey | default(lookup('pipe', 'dd if=/dev/urandom bs=1 count=1024 2>/dev/null | base64') | regex_replace('\\s+', '')) }}",
9+
"vault_alertmanager_admin_password": "{{ ansible_local.openhpc_secrets.vault_alertmanager_admin_password | default(lookup('password', '/dev/null')) }}"
910
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ vault_elasticsearch_kibana_password: "{{ hostvars[groups['control'][0]].ansible_
1111
vault_mysql_root_password: "{{ hostvars[groups['control'][0]].ansible_local.openhpc_secrets.vault_mysql_root_password }}"
1212
vault_mysql_slurm_password: "{{ hostvars[groups['control'][0]].ansible_local.openhpc_secrets.vault_mysql_slurm_password }}"
1313
vault_openhpc_mungekey: "{{ hostvars[groups['control'][0]].ansible_local.openhpc_secrets.vault_openhpc_mungekey }}"
14+
vault_alertmanager_admin_password: "{{ hostvars[groups['control'][0]].ansible_local.openhpc_secrets.vault_alertmanager_admin_password }}"
1415

1516
# Override this to cope with the case where the podman group just doesn't exist
1617
appliances_local_users_podman_enable: "{{ groups.get('podman', []) | length > 0 }}"

0 commit comments

Comments
 (0)