mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Moving over all lookup plugins to v2
This commit is contained in:
parent
45f8e6f3b0
commit
1544dde932
54 changed files with 1650 additions and 37 deletions
5
v2/samples/lookup_file.yml
Normal file
5
v2/samples/lookup_file.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
- hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug: msg="the pubkey is {{lookup('file', '~/.ssh/id_rsa.pub')}}"
|
7
v2/samples/lookup_password.yml
Normal file
7
v2/samples/lookup_password.yml
Normal 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') }}"
|
4
v2/samples/lookup_pipe.py
Normal file
4
v2/samples/lookup_pipe.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug: msg="the date is {{ lookup('pipe', 'date') }}"
|
7
v2/samples/lookup_template.yml
Normal file
7
v2/samples/lookup_template.yml
Normal 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
1
v2/samples/template.j2
Normal file
|
@ -0,0 +1 @@
|
|||
the variable is {{my_var}}
|
15
v2/samples/with_dict.yml
Normal file
15
v2/samples/with_dict.yml
Normal 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
5
v2/samples/with_env.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
- hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug: msg="{{ lookup('env','HOME') }} is an environment variable"
|
7
v2/samples/with_fileglob.yml
Normal file
7
v2/samples/with_fileglob.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug: msg="file is {{item}}"
|
||||
with_fileglob:
|
||||
- "*.yml"
|
10
v2/samples/with_first_found.yml
Normal file
10
v2/samples/with_first_found.yml
Normal 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
|
13
v2/samples/with_flattened.yml
Normal file
13
v2/samples/with_flattened.yml
Normal 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
|
11
v2/samples/with_indexed_items.yml
Normal file
11
v2/samples/with_indexed_items.yml
Normal 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
|
6
v2/samples/with_lines.yml
Normal file
6
v2/samples/with_lines.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- hosts: localhost
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug: msg="line is {{item}}"
|
||||
with_lines:
|
||||
- "cat /etc/hosts"
|
10
v2/samples/with_random_choice.yml
Normal file
10
v2/samples/with_random_choice.yml
Normal 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"
|
13
v2/samples/with_sequence.yml
Normal file
13
v2/samples/with_sequence.yml
Normal 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
|
18
v2/samples/with_subelements.yml
Normal file
18
v2/samples/with_subelements.yml
Normal 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
|
11
v2/samples/with_together.yml
Normal file
11
v2/samples/with_together.yml
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue