Moving over all lookup plugins to v2

This commit is contained in:
James Cammarata 2015-01-09 09:37:31 -06:00
commit 1544dde932
54 changed files with 1650 additions and 37 deletions

View file

@ -0,0 +1,5 @@
- hosts: localhost
connection: local
gather_facts: no
tasks:
- debug: msg="the pubkey is {{lookup('file', '~/.ssh/id_rsa.pub')}}"

View file

@ -0,0 +1,7 @@
- hosts: localhost
gather_facts: no
#vars:
# my_password: "{{ lookup('password', '/tmp/test_lookup_password length=15') }}"
tasks:
#- debug: msg="the password is {{my_password}}"
- debug: msg="the password is {{ lookup('password', '/tmp/test_lookup_password length=15') }}"

View file

@ -0,0 +1,4 @@
- hosts: localhost
gather_facts: no
tasks:
- debug: msg="the date is {{ lookup('pipe', 'date') }}"

View file

@ -0,0 +1,7 @@
- hosts: localhost
gather_facts: no
vars:
my_var: "Bazinga!"
tasks:
- debug: msg="the rendered template is {{ lookup('template', 'template.j2') }}"

1
v2/samples/template.j2 Normal file
View file

@ -0,0 +1 @@
the variable is {{my_var}}

15
v2/samples/with_dict.yml Normal file
View file

@ -0,0 +1,15 @@
- hosts: localhost
connection: local
gather_facts: no
vars:
users:
alice:
name: Alice Appleworth
telephone: 123-456-7890
bob:
name: Bob Bananarama
telephone: 987-654-3210
tasks:
- name: Print phone records
debug: msg="User {{ item.key }} is {{ item.value.name }} ({{ item.value.telephone }})"
with_dict: users

5
v2/samples/with_env.yml Normal file
View file

@ -0,0 +1,5 @@
- hosts: localhost
connection: local
gather_facts: no
tasks:
- debug: msg="{{ lookup('env','HOME') }} is an environment variable"

View file

@ -0,0 +1,7 @@
- hosts: localhost
connection: local
gather_facts: no
tasks:
- debug: msg="file is {{item}}"
with_fileglob:
- "*.yml"

View file

@ -0,0 +1,10 @@
- hosts: localhost
connection: local
gather_facts: no
tasks:
- debug: msg="file is {{item}}"
with_first_found:
- /etc/foo
- /etc/bar
- /etc/passwd
- /etc/shadow

View file

@ -0,0 +1,13 @@
- hosts: localhost
connection: local
gather_facts:
vars:
list_a:
- ['foo', 'bar']
list_b:
- [['bam', 'baz']]
tasks:
- debug: msg="item is {{item}}"
with_flattened:
- list_a
- list_b

View file

@ -0,0 +1,11 @@
- hosts: localhost
connection: local
gather_facts: no
vars:
some_list:
- a
- b
- c
tasks:
- debug: msg="at array position {{ item.0 }} there is a value {{ item.1 }}"
with_indexed_items: some_list

View file

@ -0,0 +1,6 @@
- hosts: localhost
gather_facts: no
tasks:
- debug: msg="line is {{item}}"
with_lines:
- "cat /etc/hosts"

View file

@ -0,0 +1,10 @@
- hosts: localhost
connection: local
gather_facts: no
tasks:
- debug: msg={{ item }}
with_random_choice:
- "go through the door"
- "drink from the goblet"
- "press the red button"
- "do nothing"

View file

@ -0,0 +1,13 @@
- hosts: localhost
connection: local
gather_facts: no
tasks:
- debug: msg="name={{ item }} state=present groups=evens"
with_sequence: start=0 end=32 format=testuser%02x
- debug: msg="dest=/var/stuff/{{ item }} state=directory"
with_sequence: start=4 end=16 stride=2
- debug: msg="name=group{{ item }} state=present"
with_sequence: count=4

View file

@ -0,0 +1,18 @@
- hosts: localhost
connection: local
gather_facts: no
vars:
users:
- name: alice
authorized:
- /tmp/alice/onekey.pub
- /tmp/alice/twokey.pub
- name: bob
authorized:
- /tmp/bob/id_rsa.pub
tasks:
- debug: msg="user={{ item.0.name }} key='{{ item.1 }}'"
with_subelements:
- users
- authorized

View file

@ -0,0 +1,11 @@
- hosts: localhost
connection: local
gather_facts: no
vars:
alpha: [ 'a', 'b', 'c', 'd' ]
numbers: [ 1, 2, 3, 4 ]
tasks:
- debug: msg="{{ item.0 }} and {{ item.1 }}"
with_together:
- alpha
- numbers