Блоки различные блоки в ansible роли
---
- name: Задача 1
ansible.builtin.get_url:
url: "{{ docker_compose_binary_source }}"
dest: /usr/local/bin/docker-compose
- name: Задача 2
become: true
apt:
name: zip
state: present
- name: Блок задач
block:
- name: Задача 1
lineinfile:
path: /путь/к/файлу
line: 'строка_для_добавления'
- name: Check if backup file already exists
stat:
path: "/opt/{{ docker_compose_backup }}"
register: backup_file_exists
- name: Задача 2
command: "cp {{ docker_compose }} {{ docker_compose_backup }}"
args:
chdir: "{{ project_path }}"
when: not backup_file_exists.stat.exists
rescue:
- name: Задача восстановления при сбое выполнения задач в блоке выше
debug:
msg: "Failed to process Docker Compose file."
- name: Задача 3
command:
cmd: "docker-compose up -d"
args:
chdir: "{{ project_path }}"
- name: Задача 4
file:
path: "/opt/{{ sentry_version }}.zip"
state: absent
ignore_errors: true