2017-01-13 20:31:10 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- 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
|
2017-02-08 21:41:36 +00:00
|
|
|
when: sync_file_is_cert|d() and inventory_hostname == sync_file_srcs|first
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: "sync_file | Set facts for file contents"
|
|
|
|
set_fact:
|
2017-04-19 15:52:51 +00:00
|
|
|
sync_file_contents: "{{ hostvars[sync_file_srcs|first].get('sync_file_cat', {}).get('stdout') }}"
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: "sync_file | Set fact for key contents"
|
|
|
|
set_fact:
|
2017-04-19 15:52:51 +00:00
|
|
|
sync_file_key_contents: "{{ hostvars[sync_file_srcs|first].get('sync_file_key_cat', {}).get('stdout') }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
when: sync_file_is_cert|d()
|
2017-01-13 20:31:10 +00:00
|
|
|
|
|
|
|
- name: "sync_file | Ensure the directory exists"
|
|
|
|
file:
|
2017-02-08 21:41:36 +00:00
|
|
|
group: "{{ sync_file_group|d('root') }}"
|
|
|
|
mode: "{{ sync_file_dir_mode|default('0750') }}"
|
|
|
|
owner: "{{ sync_file_owner|d('root') }}"
|
2017-01-13 20:31:10 +00:00
|
|
|
path: "{{ sync_file_dir }}"
|
|
|
|
state: directory
|
|
|
|
when: inventory_hostname not in sync_file_srcs
|
|
|
|
|
2017-06-29 17:46:27 +00:00
|
|
|
- name: "sync_file | Copy {{ sync_file_path }} to hosts that don't have it"
|
2017-01-13 20:31:10 +00:00
|
|
|
copy:
|
|
|
|
content: "{{ sync_file_contents }}"
|
|
|
|
dest: "{{ sync_file_path }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
group: "{{ sync_file_group|d('root') }}"
|
|
|
|
mode: "{{ sync_file_mode|default('0640') }}"
|
|
|
|
owner: "{{ sync_file_owner|d('root') }}"
|
2017-01-13 20:31:10 +00:00
|
|
|
when: inventory_hostname not in sync_file_srcs
|
|
|
|
|
2017-06-29 17:46:27 +00:00
|
|
|
- name: "sync_file | Copy {{ sync_file_key_path }} to hosts that don't have it"
|
2017-01-13 20:31:10 +00:00
|
|
|
copy:
|
|
|
|
content: "{{ sync_file_key_contents }}"
|
|
|
|
dest: "{{ sync_file_key_path }}"
|
2017-02-08 21:41:36 +00:00
|
|
|
group: "{{ sync_file_group|d('root') }}"
|
|
|
|
mode: "{{ sync_file_mode|default('0640') }}"
|
|
|
|
owner: "{{ sync_file_owner|d('root') }}"
|
|
|
|
when: sync_file_is_cert|d() and inventory_hostname not in sync_file_srcs
|