Check status of VMware tools & reboot if VMware tools are not running

Hi

I need to check status of VMware tools on vms & if VMware tools are not running, then reboot the vm. I have below playbook which works fine to find vm name & VMware tools status. Please help on how can i extract the vm name & take action as per status.

Note : i have to use the VMware modules as the OS typically will be in hung status ( hence tools not running ) , hence avoid user OS level task ( and use VMware task )

Thanks

Hi

why is it when i run this playbook I get this error

tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to be in ‘/home/tony/ansiblework/vmware_tools.yml’: line 9, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:

  • name: Get information about the virtual machine
    ^ here

That error message often indicates an indentation issue or a missing module parameter.

That module was introduced in ansible 2.5:
https://docs.ansible.com/ansible/latest/modules/vmware_guest_powerstate_module.html

Do you run an older version?

this is the playbook

Please as said by another people here, respect indentations stricly !

vmware_guest_info & name have not the same indentation as written by A. Kasurde

Regards,

JYL

what editor can i use on my ubuntu box? I cant use anything other than vim.

still getting the error.

tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

ERROR! Syntax Error while loading YAML.
mapping values are not allowed in this context

The error appears to be in ‘/home/tony/ansiblework/info.yml’: line 3, column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

name: get info vm
hosts: localhost
^ here

(attachments)

you missing " - "

Why Aren’t you using your Local Machine using Atom or VS Code to build your Yaml files then using WinSCP copy the playbooks over ?

this is what i have. but still not working

(attachments)

What does ‘ansible --version’ say?

Thanks Abhijeet !

Use https://onlineyamltools.com/validate-yaml

This will help you validate the syntax

tony@ubuntu:~/ansiblework$ ansible --version
ansible 2.8.2
config file = /home/tony/ansiblework/ansible.cfg
configured module search path = [u’/home/tony/ansiblework/library’]
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16 (default, Apr 9 2019, 04:50:39) [GCC 8.3.0]

tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to be in ‘/home/tony/ansiblework/vmware_tools.yml’: line 7, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:

  • name: get info about the virtual machine
    ^ here

Screen Shot 2020-04-19 at 12.10.46 PM.png

tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to be in '/home/tony/ansiblework/vmware_tools.yml': line 7, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:
- name: get info about the virtual machine
^ here

The task need to be indented:

    tasks:
      - name: get info about the virtual machine

Regards
         Racke

it is already indented