-
Notifications
You must be signed in to change notification settings - Fork 15
/
InventoryUsingAnsibleCMDB.yml
44 lines (34 loc) · 1.26 KB
/
InventoryUsingAnsibleCMDB.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
# Author: [email protected]
# This playbook will:
# - Output the server inventory as well as the vmware tool version in two separate files.
# - Also make sure if the file /home/Ansible-Workdesk/<hostname of server> does exist.
# - Change the default stdout_lines value to vmwareversion in the JSON file.
---
- hosts: test
gather_facts: no
become: yes
become_method: sudo
tasks:
- setup:
register: setup_res
- command: vmware-toolbox-cmd -v
register: vmwareversion
- set_fact:
vmwareversion: '{ "vmwareversion": {{ vmwareversion.stdout_lines }} }'
# Commented for testing purposes
- debug: var=vmwareversion
- file:
path: /home/Ansible-Workdesk/out/{{ inventory_hostname }}
state: touch
delegate_to: localhost
- copy:
content: "{{ setup_res | to_nice_json }}"
dest: /home/Ansible-Workdesk/out/{{ inventory_hostname }}
delegate_to: localhost
- file:
path: /home/Ansible-Workdesk/out/other_info/vmwaretool/{{ inventory_hostname }}
state: touch
delegate_to: localhost
- copy:
content: "{{ vmwareversion | to_nice_json }}"
dest: /home/Ansible-Workdesk/out/other_info/vmwaretool/{{ inventory_hostname }}