-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscovery.yml
29 lines (29 loc) · 1.06 KB
/
discovery.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
---
- name: Discovery play
hosts: all
gather_facts: true
become: yes
tasks:
- name: Finding uptime
shell: "uptime"
register: up_time
- name: Displaying Discovery info
debug:
msg: "{{inventory_hostname}},{{ansible_os_family}},{{ansible_system}},{{ansible_distribution}},{{up_time.stdout.split(',')[0].split('up')[-1]}}"
- name: Removing old Discovery.csv file
file:
dest: ./Discovery.csv
state: absent
delegate_to: localhost
run_once: ture
- name: Creating Discovery.csv file with header
copy:
dest: ./Discovery.csv
content: "Server_Name, OS Family, OS Name, OS Distribution, uptime\n"
delegate_to: localhost
run_once: true
- name: UPdating info of each server in csv file
lineinfile:
path: ./Discovery.csv
line: "{{inventory_hostname}},{{ansible_os_family}},{{ansible_system}},{{ansible_distribution}},{{up_time.stdout.split(',')[0].split('up')[-1]}}"
delegate_to: localhost