generate_session_secrets.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---
  2. # This should be run on the first master so we can set_fact some items
  3. # to ensure values are consistent across cluster
  4. - name: Determine if sessions secrets already in place
  5. stat:
  6. path: "{{ openshift_master_session_secrets_file }}"
  7. get_checksum: false
  8. get_attributes: false
  9. get_mime: false
  10. register: l_osm_session_secrets_stat
  11. - name: slurp session secrets if defined
  12. slurp:
  13. src: "{{ openshift_master_session_secrets_file }}"
  14. register: l_osm_session_secrets_slurp
  15. no_log: true
  16. when: l_osm_session_secrets_stat.stat.exists
  17. # lib_utils_oo_collect is a custom filter in
  18. # roles/lib_utils/filter_plugins/oo_filters.py
  19. - name: Gather existing session secrets from first master
  20. set_fact:
  21. l_osm_session_auth_secrets: "{{ l_existing_osm_session.secrets | lib_utils_oo_collect('authentication') }}"
  22. l_osm_session_encryption_secrets: "{{ l_existing_osm_session.secrets | lib_utils_oo_collect('encryption') }}"
  23. vars:
  24. l_existing_osm_session: "{{ (l_osm_session_secrets_slurp.content | b64decode | from_yaml) }}"
  25. when:
  26. - l_osm_session_secrets_stat.stat.exists
  27. - l_osm_session_secrets_slurp is defined
  28. - l_existing_osm_session.secrets is defined
  29. - l_existing_osm_session.secrets != ''
  30. - l_existing_osm_session.secrets != []
  31. # No existing secrets file found, create new secrets
  32. - name: setup session secrets if not defined
  33. set_fact:
  34. l_osm_session_auth_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
  35. l_osm_session_encryption_secrets: "{{ [ 24 | lib_utils_oo_generate_secret ] }}"
  36. when: not l_osm_session_secrets_stat.stat.exists