-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook-lookup-url.yml
33 lines (26 loc) · 1.07 KB
/
playbook-lookup-url.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
- name: Ansible and RESTful interfaces
hosts: localhost
connection: local
gather_facts: false
vars:
astros: "{{ lookup('url', 'http://api.open-notify.org/astros.json') }}"
spacecowboys: []
tasks:
- name: Quick ISS API checkup
debug:
msg: "Today on the ISS are: {{ astros.people }}"
- name: Loop through our data and display each dict (name and craft)
debug:
msg: "Loop across ISS data: {{ item }}"
loop: "{{ astros.people }}"
- name: Loop through our data and display ONLY first and last names
debug:
msg: "Astro names are: {{ item.name }}"
loop: "{{ astros.people }}"
- name: Create a new list with ansible of astro names
set_fact:
spacecowboys: "{{ astros.people|map(attribute='name')|list }}"
- name: Only display the first names of the astros
debug:
msg: "{{ item.split()[0] }}"
loop: "{{ spacecowboys }}"