-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsite.yml
More file actions
39 lines (32 loc) · 902 Bytes
/
Copy pathsite.yml
File metadata and controls
39 lines (32 loc) · 902 Bytes
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
---
- name: generate temporary files
hosts: all
gather_facts: no
tasks:
- name: setup the variable to dump
set_fact:
output_var:
hostname: "{{ inventory_hostname }}"
ok_count: "{{ 10 | random }}"
ng_count: "{{ 10 | random }}"
- name: dump the variable to a local file
copy:
content: "{{ output_var | to_nice_json }}"
dest: "/var/tmp/test_{{ inventory_hostname }}.json"
force: yes
delegate_to: localhost
- name: aggregate temporary files
hosts: localhost
gather_facts: no
vars:
total_ok: 0
total_ng: 0
tasks:
- name: read and count the variables in all .json files
include_tasks:
file: loopblock.yml
with_fileglob:
- "/var/tmp/test_*.json"
- name: print total counts
debug:
msg: "Total OKs = {{ total_ok }}, Total NGs = {{ total_ng }}"