procure_shared_key.yaml 1.2 KB

12345678910111213141516171819202122232425
  1. ---
  2. - name: Checking for {{ shared_key_info.procure_component }}_shared_key
  3. stat: path="{{generated_certs_dir}}/{{ shared_key_info.procure_component }}_shared_key"
  4. register: component_shared_key_file
  5. check_mode: no
  6. - name: Trying to discover shared key variable name for {{ shared_key_info.procure_component }}
  7. set_fact: procure_component_shared_key={{ lookup('env', '{{shared_key_info.procure_component}}' + '_shared_key') }}
  8. when:
  9. - shared_key_info[ shared_key_info.procure_component + '_shared_key' ] is defined
  10. check_mode: no
  11. - name: Creating shared_key for {{ shared_key_info.procure_component }}
  12. copy: content="{{'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'|random_word(64)}}"
  13. dest="{{generated_certs_dir}}/{{shared_key_info.procure_component}}_shared_key"
  14. check_mode: no
  15. when:
  16. - not component_shared_key_file.stat.exists
  17. - name: Copying shared key for {{ shared_key_info.procure_component }} to generated certs directory
  18. copy: content="{{procure_component_shared_key}}" dest="{{generated_certs_dir}}/{{shared_key_info.procure_component}}_shared_key"
  19. check_mode: no
  20. when:
  21. - shared_key_info[ shared_key_info.procure_component + '_shared_key' ] is defined
  22. - not component_shared_key_file.stat.exists