1
0
Fork 0
myserver-configuration/roles/cloud/tasks/base.yml

39 lines
965 B
YAML
Raw Normal View History

---
- name: Check cloud directory exist
ansible.builtin.file:
path: cloud
state: directory
- name: Copy cloud conf
ansible.builtin.copy:
backup: true
src: .
dest: cloud/
register: cloud_copy_files_results
- name: Copy template conf
ansible.builtin.template:
backup: true
src: "{{ item.src }}"
dest: "cloud/{{ item.dest }}"
loop:
- { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' }
register: cloud_copy_templates_results
- name: Force update and restart container
community.docker.docker_compose:
project_src: cloud
state: present
pull: true
restarted: true
when: cloud_copy_files_results.changed or cloud_copy_templates_results.changed
become: true
- name: Update or start container
community.docker.docker_compose:
project_src: cloud
state: present
pull: true
when: not cloud_copy_files_results.changed and not cloud_copy_templates_results.changed
become: true