Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (34 sloc) 1.26 KB
# Author: jmutkawoa@cyberstorm.mu
# 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 }}