You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

  1. ---
  2. - name: "sync_file | Cat the file"
  3. command: "cat {{ sync_file_path }}"
  4. register: sync_file_cat
  5. when: inventory_hostname == sync_file_srcs|first
  6. - name: "sync_file | Cat the key file"
  7. command: "cat {{ sync_file_key_path }}"
  8. register: sync_file_key_cat
  9. when: sync_file_is_cert|d() and inventory_hostname == sync_file_srcs|first
  10. - name: "sync_file | Set facts for file contents"
  11. set_fact:
  12. sync_file_contents: "{{ hostvars[sync_file_srcs|first]['sync_file_cat']['stdout'] }}"
  13. - name: "sync_file | Set fact for key contents"
  14. set_fact:
  15. sync_file_key_contents: "{{ hostvars[sync_file_srcs|first]['sync_file_key_cat']['stdout'] }}"
  16. when: sync_file_is_cert|d()
  17. - name: "sync_file | Ensure the directory exists"
  18. file:
  19. group: "{{ sync_file_group|d('root') }}"
  20. mode: "{{ sync_file_dir_mode|default('0750') }}"
  21. owner: "{{ sync_file_owner|d('root') }}"
  22. path: "{{ sync_file_dir }}"
  23. state: directory
  24. when: inventory_hostname not in sync_file_srcs
  25. - name: "sync_file | Copy the file to hosts that don't have it"
  26. copy:
  27. content: "{{ sync_file_contents }}"
  28. dest: "{{ sync_file_path }}"
  29. group: "{{ sync_file_group|d('root') }}"
  30. mode: "{{ sync_file_mode|default('0640') }}"
  31. owner: "{{ sync_file_owner|d('root') }}"
  32. when: inventory_hostname not in sync_file_srcs
  33. - name: "sync_file | Copy the key file to hosts that don't have it"
  34. copy:
  35. content: "{{ sync_file_key_contents }}"
  36. dest: "{{ sync_file_key_path }}"
  37. group: "{{ sync_file_group|d('root') }}"
  38. mode: "{{ sync_file_mode|default('0640') }}"
  39. owner: "{{ sync_file_owner|d('root') }}"
  40. when: sync_file_is_cert|d() and inventory_hostname not in sync_file_srcs