39 lines
1.2 KiB
YAML
39 lines
1.2 KiB
YAML
|
---
|
||
|
|
||
|
- name: "sync_file | Cat the file"
|
||
|
command: "cat {{ sync_file_path }}"
|
||
|
register: sync_file_cat
|
||
|
when: inventory_hostname == sync_file_srcs|first
|
||
|
|
||
|
- name: "sync_file | Cat the key file"
|
||
|
command: "cat {{ sync_file_key_path }}"
|
||
|
register: sync_file_key_cat
|
||
|
when: sync_file_is_cert|bool and inventory_hostname == sync_file_srcs|first
|
||
|
|
||
|
- name: "sync_file | Set facts for file contents"
|
||
|
set_fact:
|
||
|
sync_file_contents: "{{ hostvars[sync_file_srcs|first]['sync_file_cat']['stdout'] }}"
|
||
|
|
||
|
- name: "sync_file | Set fact for key contents"
|
||
|
set_fact:
|
||
|
sync_file_key_contents: "{{ hostvars[sync_file_srcs|first]['sync_file_key_cat']['stdout'] }}"
|
||
|
when: sync_file_is_cert|bool
|
||
|
|
||
|
- name: "sync_file | Ensure the directory exists"
|
||
|
file:
|
||
|
path: "{{ sync_file_dir }}"
|
||
|
state: directory
|
||
|
when: inventory_hostname not in sync_file_srcs
|
||
|
|
||
|
- name: "sync_file | Copy the file to hosts that don't have it"
|
||
|
copy:
|
||
|
content: "{{ sync_file_contents }}"
|
||
|
dest: "{{ sync_file_path }}"
|
||
|
when: inventory_hostname not in sync_file_srcs
|
||
|
|
||
|
- name: "sync_file | Copy the key file to hosts that don't have it"
|
||
|
copy:
|
||
|
content: "{{ sync_file_key_contents }}"
|
||
|
dest: "{{ sync_file_key_path }}"
|
||
|
when: sync_file_is_cert|bool and inventory_hostname not in sync_file_srcs
|