mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Reworking v2 play iterator and fixing some other bugs
Still not working quite right: * dynamic includes are not adding the included tasks yet * running roles with tags not quite working right
This commit is contained in:
parent
fbc525cfb6
commit
4af2d0a907
28 changed files with 430 additions and 418 deletions
4
v2/samples/include.yml
Normal file
4
v2/samples/include.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- debug: msg="this is the include, a=={{a}}"
|
||||
- debug: msg="this is the second debug in the include"
|
||||
- debug: msg="this is the third debug in the include, and a is still {{a}}"
|
||||
|
3
v2/samples/localhosts
Normal file
3
v2/samples/localhosts
Normal file
|
@ -0,0 +1,3 @@
|
|||
l1 ansible_ssh_host=127.0.0.1
|
||||
l2 ansible_ssh_host=127.0.0.2
|
||||
l3 ansible_ssh_host=127.0.0.3
|
0
v2/samples/roles/common/meta/main.yml
Normal file
0
v2/samples/roles/common/meta/main.yml
Normal file
1
v2/samples/roles/common/tasks/main.yml
Normal file
1
v2/samples/roles/common/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- debug: msg="this is a task from the common role"
|
2
v2/samples/roles/role_a/meta/main.yml
Normal file
2
v2/samples/roles/role_a/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- common
|
1
v2/samples/roles/role_a/tasks/main.yml
Normal file
1
v2/samples/roles/role_a/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- debug: msg="this is a task from role A"
|
2
v2/samples/roles/role_b/meta/main.yml
Normal file
2
v2/samples/roles/role_b/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- common
|
1
v2/samples/roles/role_b/tasks/main.yml
Normal file
1
v2/samples/roles/role_b/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- debug: msg="this is a task from role B"
|
2
v2/samples/roles/test_role/meta/main.yml
Normal file
2
v2/samples/roles/test_role/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- test_role_dep
|
|
@ -1 +1,3 @@
|
|||
- debug: msg="here we are in the role, foo={{foo}}"
|
||||
- fail:
|
||||
when: foo != "bar"
|
||||
|
|
1
v2/samples/roles/test_role_dep/tasks/main.yml
Normal file
1
v2/samples/roles/test_role_dep/tasks/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
- debug: msg="here we are in the role dependency"
|
|
@ -1,17 +1,20 @@
|
|||
- hosts: localhost
|
||||
- hosts: all
|
||||
connection: local
|
||||
gather_facts: no
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- block:
|
||||
- command: /bin/false
|
||||
- debug: msg="you shouldn't see me"
|
||||
- debug: msg="this is the first task"
|
||||
- fail:
|
||||
when: inventory_hostname == "l2"
|
||||
- debug: msg="only l1 and l3 should see me"
|
||||
rescue:
|
||||
- debug: msg="this is the rescue"
|
||||
- command: /bin/false
|
||||
- debug: msg="you shouldn't see this either"
|
||||
- debug: msg="no host should see this run"
|
||||
always:
|
||||
- debug: msg="this is the always block, it will always be seen"
|
||||
when: foo|default('') != "some value"
|
||||
tags:
|
||||
- foo
|
||||
- bar
|
||||
- debug: msg="you should only see l1 and l3 run this"
|
||||
|
|
8
v2/samples/test_blocks_of_blocks.yml
Normal file
8
v2/samples/test_blocks_of_blocks.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- block:
|
||||
- block:
|
||||
- block:
|
||||
- block:
|
||||
- debug: msg="are we there yet?"
|
26
v2/samples/test_include.yml
Normal file
26
v2/samples/test_include.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- block:
|
||||
- include: include.yml
|
||||
when: 1 == 2
|
||||
- include: include.yml a=1
|
||||
when: 1 == 1
|
||||
notify: foo
|
||||
- include: include.yml a={{item}}
|
||||
with_items:
|
||||
- foo
|
||||
- bar
|
||||
- bam
|
||||
- fail:
|
||||
|
||||
#rescue:
|
||||
#- include: include.yml a=rescue
|
||||
|
||||
always:
|
||||
- include: include.yml a=always
|
||||
|
||||
handlers:
|
||||
- name: foo
|
||||
include: include.yml a="this is a handler"
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
- hosts: ubuntu1404
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
vars:
|
||||
foo: "BAD!!"
|
||||
|
|
6
v2/samples/test_roles_complex.yml
Normal file
6
v2/samples/test_roles_complex.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- hosts: localhost
|
||||
gather_facts: no
|
||||
roles:
|
||||
- { role: role_a, tags: A, when: skip != "A" }
|
||||
- { role: role_b, tags: B, when: skip != "B" }
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue