- Launch 2 minimal local webservers
#.gitconfig file exists on 8081
python3 -m http.server --bind 127.0.0.1 8081
#.gitconfig file does not exist on 8080
python3 -m http.server --bind 127.0.0.1 8080
--- | |
- name: Fault Tolerance | |
hosts: all | |
connection: local | |
gather_facts: true | |
vars: | |
filename: ".gitconfig" | |
tasks: | |
- name: Download .gitconfig from unreliable source | |
ansible.builtin.get_url: | |
url: http://localhost:8080/{{filename}} | |
dest: /tmp/{{filename}} | |
mode: '0644' | |
retries: 3 | |
delay: 3 | |
register: result | |
until: result.status_code == 200 | |
ignore_errors: true | |
- name: Print results | |
ansible.builtin.debug: | |
msg: "{{ result }}" | |
- name: Download .gitconfig from reliable source | |
ansible.builtin.get_url: | |
url: http://localhost:8081/{{filename}} | |
dest: /Users/User1/repos/ansible/fault-tol/{{filename}} | |
mode: '0644' | |
force: true | |
when: result.status_code != 200 | |
retries: 3 | |
delay: 3 | |
register: retry_url | |
until: retry_url.status_code == 200 |