Browse Source

Fix generate_session_secrets

This commit fixes typo for existing sessions
secret file, l_osm_session_secrets_stat.

This commit also ensures we slurp the existing file
secrets, if any.
Michael Gugino 7 years ago
parent
commit
4e96d40392
1 changed files with 14 additions and 6 deletions
  1. 14 6
      roles/openshift_control_plane/tasks/generate_session_secrets.yml

+ 14 - 6
roles/openshift_control_plane/tasks/generate_session_secrets.yml

@@ -7,11 +7,11 @@
     path: "{{ openshift_master_session_secrets_file }}"
   register: l_osm_session_secrets_stat
 
-- name: setup session secrets if not defined
-  set_fact:
-    l_osm_session_auth_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
-    l_osm_session_encryption_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
-  when: not l_osm_session_secrets_stat.stat.exists
+- name: Determine if sessions secrets already in place
+  slurp:
+    src: "{{ openshift_master_session_secrets_file }}"
+  register: l_osm_session_secrets_slurp
+  when: l_osm_session_secrets_stat.stat.exists
 
 # lib_utils_oo_collect is a custom filter in
 # roles/lib_utils/filter_plugins/oo_filters.py
@@ -20,9 +20,17 @@
     l_osm_session_auth_secrets: "{{ l_existing_osm_session.secrets | lib_utils_oo_collect('authentication') }}"
     l_osm_session_encryption_secrets: "{{ l_existing_osm_session.secrets | lib_utils_oo_collect('encryption') }}"
   vars:
-    l_existing_osm_session: "{{ (osm_session_secrets_stat.content | b64decode | from_yaml) }}"
+    l_existing_osm_session: "{{ (l_osm_session_secrets_slurp.content | b64decode | from_yaml) }}"
   when:
   - l_osm_session_secrets_stat.stat.exists
+  - l_osm_session_secrets_slurp defined
   - l_existing_osm_session.secrets is defined
   - l_existing_osm_session.secrets != ''
   - l_existing_osm_session.secrets != []
+
+# No existing secrets file found, create new secrets
+- name: setup session secrets if not defined
+  set_fact:
+    l_osm_session_auth_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
+    l_osm_session_encryption_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
+  when: not l_osm_session_secrets_stat.stat.exists