Skip to content

Instantly share code, notes, and snippets.

@sivel
Last active March 15, 2024 08:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivel/a3ab91d4966bfa17ee69cb4bd95f34a4 to your computer and use it in GitHub Desktop.
Save sivel/a3ab91d4966bfa17ee69cb4bd95f34a4 to your computer and use it in GitHub Desktop.
Ansible Include Until
---
- hosts: localhost
gather_facts: false
tasks:
- include_tasks: include_me.yml
vars:
include_max: 10
- 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