-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook-varspractice04.yml
39 lines (32 loc) · 1.09 KB
/
playbook-varspractice04.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
---
- name: A playbook that manipulates data from uri
hosts: localhost
vars:
uritouse: "https://statsapi.web.nhl.com/api/v1/teams"
tasks:
- name: Use URI module to send HTTP GET
ansible.builtin.uri:
method: GET
url: "{{ uritouse }}"
register: results
tags:
- keys
- upper
- stringslice
- name: Use python to show all dictionary keys with python
ansible.builtin.debug:
var: results.keys() # .keys() is a python dict method
tags:
- keys
- name: Loop across the teams and display the team locations made uppercase with python
ansible.builtin.debug:
var: item.venue.name.upper() # .upper() is a python string method
loop: "{{ results.json.teams }}"
tags:
- upper
# transform http://pittsburghpenguins.com/ into pittsburghpenguins.com
- name: Loop across the teams and write out a lite of URLs without the http:// or trailing /
shell: "echo {{ item.officialSiteUrl.lstrip('http:').rstrip('/').lstrip('//') }} >> /tmp/teamsites.txt"
loop: "{{ results.json.teams }}"
tags:
- stringslice