0

I am trying to install VMware Tools on various OS on my guest machines. This is the code I have now.

---
- hosts: all

  tasks:
        -   name: debian | installing open-vm-tools
            apt: name=open-vm-tools state=present
            when: ansible_os_family == "Debian"

        -   name: install vmware tools via Chocolatey
            win_chocolatey: name=vmware-tools state=present
            when: ansible_distribution  == "Windows"

This is what my hosts.ini file looks like:

[my-host]
myhost.com  ansible_ssh_pass=mypw ansible_ssh_user=root

This is the command I am using to run it. Which works.

ansible-playbook -i hosts.ini vmwaretools.yml

However, this is the message I get after I run it.

ok: [myhost.com]
TASK [debian | installing open-vm-tools] *************************************** task path: /Users/Desktop/Ansible/vmwaretools.yml:5 skipping: [myhost.com] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

TASK [install vmware tools via Chocolatey] ************************************* task path: /Users/Desktop/Ansible/vmwaretools.yml:9 skipping: [myhost.com] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

PLAY RECAP ********************************************************************* myhost.com : ok=1 changed=0 unreachable=0
failed=0

Why does it say conditional fail checked? I am sure I have VMs with Debian and Windows running. Any idea why this is happening?

techraf
  • 64,883
  • 27
  • 193
  • 198
user3078335
  • 781
  • 4
  • 13
  • 24
  • Where is the part you connect to your VMs? I see only one host – `myhost.com`. – Konstantin Suvorov Sep 08 '16 at 20:25
  • it's only one host. I should have just done it `hosts: my-host` instead of `all`. Didn't think it would make a difference though. – user3078335 Sep 08 '16 at 21:14
  • Sorry if this seems kinda dumb. I am still a learner. What do you mean connect to the VMs? My assumption is that, once you connect to the host system, it has access to each VM and checks to see if the distribution matches, and if it does, it installs vmware tools on the VM. Am I wrong? If not, please explain to me. I am still very new to this. – user3078335 Sep 08 '16 at 21:28
  • I have a feeling you asked [a question](https://stackoverflow.com/questions/39378928/error-from-installing-vmware-tools-using-ansible/39379201#39379201) yesterday using a different account, I answered your question. You deleted the question (along with my answer) and now posted a new question using the suggestions from my answer. It's not especially social behaviour, you know... – techraf Sep 08 '16 at 23:00
  • @techraf Yeah, I did. It had a lot of downvotes on that question so I was blocked from asking questions for a while (my reason for creating a new account). I decided to use your suggestions to ask a better question. I only deleted it because I did not want duplicate questions out there. – user3078335 Sep 08 '16 at 23:06

1 Answers1

1

From your comment:

My assumption is that, once you connect to the host system, it has access to each VM and checks to see if the distribution matches, and if it does, it installs vmware tools on the VM.

No. Ansible must connect to each single virtual machine and run playbook on that machine. There is no way of delegating the tasks to the host machine.

Even when you run an ESXi host and select "Install VMware Tools" on a particular machine, the only thing it does is mounting an ISO image to the machine. The installation process then takes place locally (either by manual administrator action or through the autorun).

Why does it say conditional fail checked?

You are running the playbook on the VMware host machine which is not Debian. The second condition will never be true:

when: ansible_distribution == "Windows"

ansible_distribution contains more detailed information, like:

"ansible_distribution": "Microsoft Windows NT 10.0.14366.0"

You need to use:

when: ansible_os_family == "Windows"
techraf
  • 64,883
  • 27
  • 193
  • 198
  • Thanks for your response again. It's a bit more clearer now. Would I have to install win_chocalatey on my vm in order for the `win_chocolatey: name=vmware-tools state=present` to work? – user3078335 Sep 08 '16 at 23:11
  • Yes, officially you do it in PowerShell `iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex` – techraf Sep 08 '16 at 23:12