blob: e47c39cbaea0cbc95715bf2ed0ac89683e152122 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---
- name: Create temporary directory on localhost
delegate_to: localhost
become: false
ansible.builtin.tempfile:
state: directory
register: tempdir
- name: Ensure parent directories exist for rendered templates
delegate_to: localhost
become: false
ansible.builtin.file:
path: "{{ tempdir.path }}/{{ item.path | dirname }}"
state: directory
mode: "{{ mode | default('0755') }}"
with_filetree: "{{ render_dir }}"
when: item.state == "file"
- name: Recursively render templates
delegate_to: localhost
become: false
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ tempdir.path }}/{{ item.path }}"
mode: "{{ mode | default('0755') }}"
with_filetree: "{{ render_dir }}"
when: item.state == "file"
- name: Sync rendered templates to remote host
delegate_to: localhost
become: false
ansible.builtin.synchronize:
src: "{{ tempdir.path }}/"
dest: "{{ tempdir.path }}/"
- name: Remove local temporary directory
delegate_to: localhost
become: false
ansible.builtin.file:
path: "{{ tempdir.path }}"
state: absent
- name: Update remote files
ansible.builtin.command:
cmd: bash -c 'cp -r {{ tempdir.path }}/* {{ destination_dir }}/'
- name: Remove local temporary directory
delegate_to: localhost
become: false
ansible.builtin.file:
path: "{{ tempdir.path }}"
state: absent
- name: Remove remote temporary directory
ansible.builtin.file:
path: "{{ tempdir.path }}"
state: absent
|