Add ansible import vs include

This commit is contained in:
Wilfried OLLIVIER 2019-06-26 12:11:43 +02:00
parent 15a570ea45
commit fc2f18838b
1 changed files with 17 additions and 1 deletions

View File

@ -34,3 +34,19 @@ To tell Jinja2 to not mess with carriage return in templates add
```
at the top of the template file
## Import vs include (kudos @href)
If you want to exec a sets of tasks when a condition is true, use
import_tasks.
```
- name: Include init tasks
import_tasks: init.yml
tags:
- init
when: proof.stat.exists == False
```
`ìnclude_tasks` will add all tasks to play run, even if the when condition is
false.