ansible-role-docker-compose/tasks/present.yml

59 lines
1.4 KiB
YAML
Raw Normal View History

2023-05-05 22:19:15 +02:00
---
- block:
- name: Create Temporary directory
tempfile:
state: directory
changed_when: false
register: temp_file
- name: Create directory structure
file:
state: directory
dest: '{{ temp_file.path }}/{{ item.path }}'
mode: "{{ item.mode }}"
changed_when: false
2023-05-05 22:30:21 +02:00
with_filetree: "{{ service_base }}/{{ service | mandatory }}"
2023-05-05 22:19:15 +02:00
when: item.state == 'directory'
loop_control:
label: '{{ item.path }}'
- name: Template Service Files
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ temp_file.path }}/{{ item.path }}"
mode: "{{ item.mode }}"
force: true
trim_blocks: false
changed_when: false
2023-05-05 22:30:21 +02:00
with_filetree: "{{ service_base }}/{{ service | mandatory }}"
2023-05-05 22:19:15 +02:00
loop_control:
label: '{{ item.path }}'
when: item.state == 'file'
delegate_to: localhost
check_mode: no
- name: Create Service Directory
file:
state: directory
path: "{{ compose_dir | mandatory }}"
- name: Copy Compose files
become: false
ansible.posix.synchronize:
src: "{{ temp_file.path | mandatory }}/"
dest: "{{ service_dir | mandatory }}"
archive: false
checksum: true
delete: true
recursive: true
mode: push
owner: false
group: false
perms: false
register: compose_files
- name: Delete temporary directory
ansible.builtin.file:
path: "{{ temp_file.path }}"
state: absent
changed_when: false