Ansible:运行异步任务,如果失败:运行清理任务并重试第一个任务x次
我想创建一个类似以下内容的程序流:Ansible:运行异步任务,如果失败:运行清理任务并重试第一个任务x次,ansible,Ansible,我想创建一个类似以下内容的程序流: - name: Clone git repository block: - git: repo: "{{ project_gitlab_repository }}" dest: "{{ project_build_path }}" async: 120 poll: 5 rescue: - file: path: "{{ project_buil
- name: Clone git repository
block:
- git:
repo: "{{ project_gitlab_repository }}"
dest: "{{ project_build_path }}"
async: 120
poll: 5
rescue:
- file:
path: "{{ project_build_path }}"
state: absent
- ansible.builtin.command: /bin/false
retries: 3
- block:
- name: Clone git repository
git:
repo: "{{ project_gitlab_repository }}"
dest: "{{ project_build_path }}"
async: 120
poll: 5
rescue:
- set_fact:
retry_count: "{{ 0 if retry_count is undefined else retry_count | int + 1 }}"
- fail:
msg: maximum retries reached
when: retry_count | int == 5
- command: "rm -rf {{ project_build_path }}"
- include_tasks: clone_git_repository.yml