-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoke-ansible.yml
94 lines (78 loc) · 2.49 KB
/
poke-ansible.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
- name: Interact with PokeAPI
hosts: TM1
become: yes
vars:
pokemon_file: "/home/PokeDes/magmar.txt"
tasks:
- name: Create Directory
shell: mkdir /home/PokeDes
ignore_errors: yes
- name: Create file
shell: touch {{ pokemon_file }}
ignore_errors: yes
- name: Get Pokemon Details
uri:
url: "https://pokeapi.co/api/v2/pokemon/magmar"
method: GET
return_content: yes
register: response
- name: Extract abilities list
set_fact:
abilities: "{{ response.json.abilities }}"
- name: Print the first three ability names and Append them to a file
lineinfile:
path: "{{ pokemon_file }}"
line: "Ability name: {{ item.ability.name }}"
loop: "{{ abilities[:3] }}"
- name: Interact with PokeAPI Electabuzz
hosts: TM2
become: yes
vars:
pokemon_file2: "/home/PokeDes/electabuzz.txt"
tasks:
- name: Create Directory
shell: mkdir /home/PokeDes
ignore_errors: yes
- name: Create file
shell: touch {{ pokemon_file2 }}
ignore_errors: yes
- name: Get Pokemon Details
uri:
url: "https://pokeapi.co/api/v2/pokemon/electabuzz"
method: GET
return_content: yes
register: response
- name: Extract abilities list
set_fact:
abilities: "{{ response.json.abilities }}"
- name: Print the first three ability names for Electabuzz and Append them to a file
lineinfile:
path: "{{ pokemon_file2 }}"
line: "Ability name: {{ item.ability.name }}"
loop: "{{ abilities[:3] }}"
- name: Interact with PokeAPI Infernape
hosts: target_machines
become: yes
vars:
pokemon_file3: "/home/PokeDes/infernape.txt"
tasks:
- name: Create Directory
shell: mkdir /home/PokeDes
ignore_errors: yes
- name: Create file
shell: touch {{ pokemon_file3 }}
ignore_errors: yes
- name: Get Pokemon Details
uri:
url: "https://pokeapi.co/api/v2/pokemon/infernape"
method: GET
return_content: yes
register: response
- name: Extract abilities list
set_fact:
abilities: "{{ response.json.abilities }}"
- name: Print the first three ability names for Infernape and Append them to a file
lineinfile:
path: "{{ pokemon_file3 }}"
line: "Ability name: {{ item.ability.name }}"
loop: "{{ abilities[:3] }}"