Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: Imported static task 1 | ||
debug: | ||
var: foobar | ||
|
||
- name: Imported static task 2 | ||
debug: | ||
var: foobar | ||
|
||
- name: Imported static task 3 | ||
debug: | ||
var: foobar | ||
|
||
- name: Imported static task 4 | ||
debug: | ||
var: foobar | ||
tags: xyzzy | ||
|
||
- name: Imported static task 5 | ||
debug: | ||
var: foobar | ||
tags: frobozz | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env ansible-playbook | ||
--- | ||
|
||
# https://docs.ansible.com/ansible/2.4/playbooks_reuse.html#dynamic-vs-static | ||
|
||
- name: Demonstrate the difference between Includes and Imports | ||
hosts: localhost | ||
vars: | ||
foobar: false | ||
|
||
tasks: | ||
- name: Include extra tasks dynamically | ||
import_tasks: included-dynamic-tasks.yaml | ||
when: foobar | ||
|
||
- name: Import extra tasks statically | ||
include_tasks: imported-static-tasks.yaml | ||
when: foobar | ||
|
||
# ERROR! You cannot use loops on 'import_tasks' statements. You should use 'include_tasks' instead. | ||
- name: Include extra tasks dynamically | ||
import_tasks: included-dynamic-tasks.yaml | ||
|
||
- name: Import extra tasks statically | ||
include_tasks: imported-static-tasks.yaml | ||
with_items: | ||
- foo | ||
- bar | ||
|
||
- name: Include extra tasks dynamically with tag xyzzy | ||
import_tasks: included-dynamic-tasks.yaml | ||
tags: xyzzy | ||
|
||
- name: Import extra tasks statically with tag xyzzy | ||
include_tasks: imported-static-tasks.yaml | ||
tags: xyzzy |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
- name: Included dynamic task 1 | ||
debug: | ||
var: foobar | ||
|
||
- name: Included dynamic task 2 | ||
debug: | ||
var: foobar | ||
|
||
- name: Included dynamic task 3 | ||
debug: | ||
var: foobar | ||
|
||
- name: Included dynamic task 4 | ||
debug: | ||
var: foobar | ||
tags: xyzzy | ||
|
||
- name: Included dynamic task 5 | ||
debug: | ||
var: foobar | ||
tags: frobozz | ||
|