procure_shared_key.yaml 1.3 KB

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