Implemented update-repository-with-files.yml

This commit is contained in:
2024-05-26 21:09:36 +02:00
parent 4735081128
commit 06537dfe9a
8 changed files with 49 additions and 40 deletions

View File

@@ -1,34 +1,5 @@
- name: "backup docker-compose.yml if it exists"
command: >
mv "{{ docker_compose_file_path }}" "{{ docker_compose_backup_path }}"
args:
removes: "{{ docker_compose_file_path }}"
become: true
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
ignore_errors: true
- name: pull docker repository
git:
repo: "{{ repository_address }}"
dest: "{{ repository_directory }}"
update: yes
notify: docker compose project setup
become: true
- name: "restore docker-compose.yml from backup"
command: >
mv "{{ docker_compose_backup_path }}" "{{ docker_compose_file_path }}"
args:
removes: "{{ docker_compose_backup_path }}"
become: true
- name: "copy docker-compose.yml"
template:
src: docker-compose.yml.j2
dest: "{{ docker_compose_file_path }}"
notify: docker compose project setup
- name: "include tasks update-repository-with-files.yml"
include_tasks: update-repository-with-files.yml
vars:
detached_files:
- "{{docker_compose_file_path}}"

View File

@@ -0,0 +1,37 @@
- name: "backup docker-compose.yml if it exists"
command: >
mv "{{docker_compose_instance_directory}}{{ item }}" "/tmp/{{docker_compose_project_name}}-{{ item }}.backup"
args:
removes: "{{docker_compose_instance_directory}}{{ item }}"
become: true
loop: "{{ detached_files }}"
- name: checkout repository
ansible.builtin.shell: git checkout .
become: true
args:
chdir: "{{docker_compose_instance_directory}}"
ignore_errors: true
- name: pull docker repository
git:
repo: "{{ repository_address }}"
dest: "{{ repository_directory }}"
update: yes
notify: docker compose project setup
become: true
- name: "restore docker-compose.yml from backup"
command: >
mv "/tmp/{{docker_compose_project_name}}-{{ item }}.backup" "{{docker_compose_instance_directory}}{{ item }}"
args:
removes: "/tmp/{{docker_compose_project_name}}-{{ item }}.backup"
become: true
loop: "{{ detached_files }}"
- name: "copy {{ item }}"
template:
src: "{{ item }}.j2"
dest: "{{docker_compose_instance_directory}}{{ item }}"
loop: "{{ detached_files }}"
notify: docker compose project setup