Installing the VNC server on Ubuntu using Ansible

In this post,we’ll learn that how we can install the VNC server on Ubuntu 14.04 LTS using Ansible. If you don’t know about Ansible, please check this link.

If you want manual step by step procedure to install the VNC server on Ubuntu, please refer this post.

First, download this Repository from the GitHub:

git clone

Note: If git is not installed then you can simply download the zip file.

To use this role, edit the site.yml file:

vi site.yml

Mentioned the VNC role:

 - hosts: server
   sudo: True
   gather_facts: True
     - vnc

After that, edit the hosts file and enter the ip of your remote server, on which you want to perform all these tasks:

vi hosts

In my case, it is


After that edit the vnc/vars/main.yml file:

Change the username(s),port(s) and resolution for VNC Client as per your environment, but these user(s) must exist on the target system. Here 1 will make vnc port 5901 for the user, 2 will enable the user to get access to the VNC Server with the port 5902. Don’t forget to change the password because it will be used by the user to login to the VNC Server.

 default_passwd: mypassword
 vnc_client_res: "1024x600"
   - { name: 'arbab', vnc_num: 1 }
   - { name: 'ali', vnc_num: 2 }
   - { name: 'hussain', vnc_num: 3 }

Then run this command:

ansible-playbook -i hosts -u arbab site.yml

1Note: Please don’t forget to change arbab with your username

After successful completion of these tasks, it will show you the summary, something like this:


Verification: After that, download VNC client onto your desktop computer from which you want to access the shared desktop(vnc server). Connect using ServerIP/Name:Number (1 is for arbab, 2 is for ali and 3 is for hussain user in my case).



Enjoy :-)

Hope this will help you!

Please Remember me in your prayers!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: