Using Ansible to install vmware tools (open-vm-tools)

By | 1st August 2015

Installation of vmware tools for linux versions can be done using the open-vm-tools.

Noticed the below message while trying to install vmware tools on my Ubuntu 14.04

$ sudo ./
[sudo] password for rsa:
open-vm-tools are available from the OS vendor and VMware recommends using
open-vm-tools. See for more information.
Do you still want to proceed with this legacy installer? [no] no

Since Ansible was something I was trying out, thought of using the same to install vmware open tools.

Please see my earlier posts on getting started with ansible.

1. Create a folder(just for ease)

Added both the playbook and hosts file.
A simple playbook was created to help with the installation of the packages.

$ ls -ltr

total 8
-rw-rw-r– 1 rsa rsa 194 Aug 1 16:15 vmwtools.yml
-rw-r–r– 1 rsa rsa 434 Aug 1 16:15 hosts

$ cat vmwtools.yml

– hosts: ubuntu_vms
remote_user: stack
sudo: yes

– name: Install vmware tools

2. Try to see if the vm is pingable before starting with the installation.

$ ansible all -m ping -i hosts -k
SSH password: | success >> {
“changed”: false,
“ping”: “pong”


3. Even before starting with the installation, one option is to run the check command to see if there are any issues. Hit the below issue and google showed that it is because of config file.


$ ansible-playbook vmwtools.yml -i hosts –check -k
SSH password:

PLAY [ubuntu_vms] *************************************************************

GATHERING FACTS *************************************************************
fatal: [] => Missing become password

TASK: [Install vmware tools] **************************************************
FATAL: no hosts matched or all hosts have already failed — aborting

Change the file and made it “true”

$ cat /etc/ansible/ansible.cfg | grep -i ask_sudo_pass
ask_sudo_pass = True

At the end it worked like ease.

(note: some of the output has been removed as it was too long, this is because I used verbose option)

$ ansible-playbook vmwtools.yml -i hosts -k -vvv
SSH password:
SUDO password[defaults to SSH password]:

PLAY [ubuntu_vms] *************************************************************

GATHERING FACTS *************************************************************
<> EXEC sshpass -d4 ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=”/home/rsa/.ansible/cp/ansible-ssh-%h-%p-%r” -o GSSAPIAuthentication=no -o PubkeyAuthentication=no -o C

TASK: [Install vmware tools] **************************************************
<> REMOTE_MODULE apt name=open-vm-tools-desktop state=latest update_cache=yes
<> EXEC sshpass -d7 ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o 0ubuntu6) …n”}

PLAY RECAP ************************************************************ : ok=2 changed=1 unreachable=0 failed=0

Ansible is idempotent so it does change or do anything if run it again. Changed = 0 after rerunning the command.

me/rsa/.ansible/tmp/ansible-tmp-1438435178.73-12162422762569/ >/dev/null 2>&1′”‘””
ok: [] => {“changed”: false}

PLAY RECAP *********************************************************** : ok=2 changed=0 unreachable=0 failed=0



For reference the code is uploaded to my git repo:

Download the scripts, change the host details and get going.



Leave a Reply

Your email address will not be published. Required fields are marked *