Vmware_guest

373 views
Skip to first unread message

olivier pouilly

unread,
Aug 29, 2017, 5:30:12 AM8/29/17
to Ansible Project
Hi all,

I recently discovered the module VMware_guest for ansible. I would like to know how it's work. Indeed I installed ansible version 2.3.2.0. and the module python 2.7.6 and  PyVmomi.
And when I run a ansible-playbook like this :

- name: Gather all registered virtual machines
  local_action:
    module: vmware_vm_facts
    hostname: esxi_or_vcenter_ip_or_hostname
    username: username
    password: password

And when I run the playbook I see the following message :

ERROR! 'local_action' is not a valid attribute for a Play
The error appears to have been in '/etc/ansible/Vmware.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:

- name: Gather all registered virtual machines
  ^ here

do I forgot  Something ?

Best Regards,

Philippe Eveque

unread,
Aug 29, 2017, 10:56:45 AM8/29/17
to ansible...@googlegroups.com
What you have is a task that belongs to a tasks section

Phil

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bb05dc34-b66b-4a55-9c85-fa132877e2e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

olivier pouilly

unread,
Aug 30, 2017, 4:34:44 AM8/30/17
to ansible...@googlegroups.com
Hi,

Thanks for you reply. I discovered this soft recently so I don't realy have the knowledge to complete my YML.
I treid to search how I can delete a VM on VMware and I create this Playbook with your advice :

- hosts: all
  gather_facts: false
  connection: local
    vars_prompt :
    - name: "vsphere_password"
      prompt: "vSphere Password"
    - name: "notes"
      prompt: "VM notes"
      private: no
      default: "Deployed with ansible"
  tasks:
  - vmware_guest:
      hostname: '{{ vsphere_host }}'
      username: '{{ vsphere_user }}'
      password: '{{ vsphere_password }}'
      uuid: 421e4592-c069-924d-ce20-7e7533fab926
      state: absent

But it seems that  it missing Something. Because it doesn't work. 
Do you have an example of completed Playbook to do that ?


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Lr8SuQEIaUk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.

To post to this group, send email to ansible-project@googlegroups.com.

J Hawkesworth

unread,
Aug 30, 2017, 4:42:36 AM8/30/17
to Ansible Project
What error do you get when it doesn't work?

It looks like you are attempting to delete a vm via its uuid.  Has the vm already been deleted?  


I suggest removing the vars_prompt stuff and hard coding values until you have the vmware_guest module doing something.

Also worth using the debug module to display the contents of any vars you are creating so that you can be sure that they contain values that you expect, like this.

- name: show notes
  debug:
     var: notes

Hope this helps,

Jon
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/Lr8SuQEIaUk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

olivier pouilly

unread,
Aug 30, 2017, 8:27:56 AM8/30/17
to ansible...@googlegroups.com
Hi Jonh,

I tried with this :

- hosts: all
  gather_facts: false
  connection: local
  tasks:

  - name: show notes
    debug:
     var: notes
  - vmware_guest:
    hostname: 10.112.100.60
    username: root
    password: password
    uuid: 564d0c49-a688-b277-68b8-09848a0c4ca4
    state: absent

but when I run this playbook I have this error messagee :

ERROR! conflicting action statements: hostname, vmware_guest
The error appears to have been in '/etc/ansible/new.yml': line 8, column 5, but may

be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
     var: notes
  - vmware_guest:
    ^ here

The error appears to have been in '/etc/ansible/new.yml': line 8, column 5, but may

be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
     var: notes
  - vmware_guest:
    ^ here



Regards,

To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/66b0d9ac-2b87-4ac0-a126-72856105f57e%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages