Last active
March 15, 2024 08:17
-
-
Save sivel/a3ab91d4966bfa17ee69cb4bd95f34a4 to your computer and use it in GitHub Desktop.
Ansible Include Until
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
gather_facts: false | |
tasks: | |
- include_tasks: include_me.yml | |
vars: | |
include_max: 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- set_fact: | |
include_counter: "{{ include_counter|default(0)|int + 1 }}" | |
- block: | |
- command: "{{ 'false' if include_counter|int < 5 else 'true' }}" | |
rescue: | |
- include_tasks: include_me.yml | |
when: include_counter|int < include_max|default(10)|int | |
- fail: | |
msg: Failed to meet conditional | |
when: include_counter|int >= include_max|default(10)|int |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment