-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
48 lines (39 loc) · 1.21 KB
/
playbook.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
- name: Gather client infos
hosts: clients
vars:
output_dir: '/etc/ansible/IT-Planet/'
output_file: '{{ [output_dir, inventory_hostname] | path_join }}'
output_host: srv01
tasks:
- name: Gather local ip address
ansible.builtin.shell: hostname -i
register: ip_local
- name: Gather hostname
ansible.builtin.shell: hostname
register: hostname
- name: Gather os info
ansible.builtin.shell: cat /proc/version
register: os_info
- name: Gather disk usage
ansible.builtin.shell: df -H /
register: disk_usage
- name: Gather memory usage
ansible.builtin.shell: free -m
register: memory_usage
- name: Ensure directory exists
ansible.builtin.file:
path: '{{ output_dir }}'
state: directory
delegate_to: '{{ output_host }}'
- name: Save client infos
ansible.builtin.copy:
content: |
Hostname: {{ hostname.stdout }}
IP Address: {{ ip_local.stdout }}
OS: {{ os_info.stdout }}
Memory Usage:
{{ memory_usage.stdout }}
Disk Usage:
{{ disk_usage.stdout }}
dest: '{{ output_file }}'
delegate_to: '{{ output_host }}'