forked from therjmartins/project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lookups.yml
40 lines (34 loc) · 1.17 KB
/
lookups.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
- name: Play to make use of lookups
hosts: localhost
vars:
choices:
- Take the blue pill
- Take the red pill
- Do nothing
tasks:
- name: Print out contents of file read in
debug:
msg: "{{ lookup('file', 'files/somefile.txt') }}"
- name: Print put the contents of two files read in using a loop
debug:
msg: "{{ item }}"
with_file:
- somefile.txt
- someotherfile.txt
- name: Print out the contents of whichever file is found first
debug:
msg: "{{ lookup('file', lookup('first_found', 'files/somefile.txt', 'files/someotherfile.txt', '/etc/hosts')) }}"
- name: Execute a command and use the output in a task using the lines lookup
debug:
msg: "{{ lookup('lines', 'cat /etc/hosts', 'cat /etc/motd') }}"
- name: Read in a processed Jinja2 template
debug:
msg: "{{ lookup('template', 'j2/sample.j2') }}"
- name: Choose a random item from a list
debug:
msg: "{{ item }}"
with_random_choice: "{{ choices }}"
- name: Grab content from a URL
debug:
msg: "{{ lookup('url', 'https://w3.org/TR/PNG/iso_8859-1.txt') }}"