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:
James Cammarata 2015-02-26 09:51:12 -06:00
commit 4af2d0a907
28 changed files with 430 additions and 418 deletions

4
v2/samples/include.yml Normal file
View 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
View 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

View file

View file

@ -0,0 +1 @@
- debug: msg="this is a task from the common role"

View file

@ -0,0 +1,2 @@
dependencies:
- common

View file

@ -0,0 +1 @@
- debug: msg="this is a task from role A"

View file

@ -0,0 +1,2 @@
dependencies:
- common

View file

@ -0,0 +1 @@
- debug: msg="this is a task from role B"

View file

@ -0,0 +1,2 @@
dependencies:
- test_role_dep

View file

@ -1 +1,3 @@
- debug: msg="here we are in the role, foo={{foo}}"
- fail:
when: foo != "bar"

View file

@ -0,0 +1 @@
- debug: msg="here we are in the role dependency"

View file

@ -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"

View file

@ -0,0 +1,8 @@
- hosts: localhost
gather_facts: no
tasks:
- block:
- block:
- block:
- block:
- debug: msg="are we there yet?"

View 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"

View file

@ -1,4 +1,5 @@
- hosts: ubuntu1404
- hosts: localhost
connection: local
gather_facts: no
vars:
foo: "BAD!!"

View 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" }