Ansible is a popular agent-less automation tool used to configure local or remote systems and deploy applications.
The easiest way to install the latest version of Ansible on Ubuntu is to get it from the official APT repository.
This short note shows how to install Ansible on Ubuntu, check its version, locate the configuration file and test the connection to a remote host from the command line.
Cool Tip: Enable DEBUG mode and increase VERBOSITY in Ansible! Read more →
Install Ansible on Ubuntu
Add the official APT repository of Ansible:
$ sudo apt-add-repository ppa:ansible/ansible
Add the public key:
$ curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x93C4A3FD7BB9C367" | sudo apt-key add
Update the list of packages and install Ansible on Ubuntu:
$ sudo apt update $ sudo apt install ansible
Check the installed version of Ansible and the default location of ansible.cfg
:
$ ansible --version
Now you can do a fast connection test from the command line to check if the Ansible can communicate with the remote hosts.
Cool Tip: Run Ansible Playbooks Locally! Read more →
Test connection to a remote host using username and password-based authentication:
$ ansible -i <host>, all -u <username> -k -m ping
If you already have SSH-keys configured, you can test the connection as follows:
$ ansible -i <host>, all -u <username> -m ping
Note, that the comma after <host>,
is mandatory, otherwise <host>
is treated like a file name, that will cause the following errors:
[WARNING]: Unable to parse …/<host> as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’