I'm trying to write a simple 'how to' for the build of an Ansible 'sandpit' environment that my networking colleague can follow. I want this to have minimal demands in terms of prior knowledge about linux, git and OS package management.
What's the problem?
- Ansible control machine is not supported on Windows. That's an issue for a lot of my intended audience. Not having a simple Wins install process means we are out in the linux wilds. Fun for the experienced, confusion for many.
- Ansible install documentation. It is rambling and covers multiple installation processes without what I consider a simple process of 'DO THIS!'.
- Lots of options, each slightly different - Sometimes choice isn't what we need. I want to get ansible installed. Quick. Thanks. But I have multiple linux OS options, package management, PIP or git clone from source. It is easy once you know how but there are a number of details in the different install routes that could confuse the inexperienced, myself included. Hence this blog.
Option 1: DO THIS!
This is my straight to the point, easy install. I'll leave the nuances until later:
- Install Ubuntu 16.04 Desktop on your host OS (my is Wins7) using Virtualbox or a VMware virtualization client (E.G. Workstation).
- Run this:
sudo apt update sudo apt -y upgrade sudo apt-get install software-properties-common sudo apt-add-repository ppa:ansible/ansible sudo apt-get update sudo apt-get install ansible
- Now check the ansible version, it should be the latest, stable (currently 2.4), and you should have a config file located at in
$ ansible --version ansible 126.96.36.199 config file = /etc/ansible/ansible.cfg configured module search path = [u'/home/joe/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]
That's it you're done.
Here's a video of the install:
For those that just want the install your quest ends here. For those seeking more answers, read on.
Option 1.1: More details
Why did I feel the need to write a post then? The above is just a rewrite of the 'Latest Releases Via Apt (Ubuntu)' section of the install docs.
The answer is that prior to that section, the install docs contain this,
'If you are wishing to run the latest released version of Ansible and you are running Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian, or Ubuntu, we recommend using the OS package manager.'
That says to me, just do an
'apt install ansible'.
Moreover, if you check whether ansible is installed on Ubuntu, and it is not, you get this helpful message:
$ ansible --version The program 'ansible' is currently not installed. You can install it by typing: sudo apt install ansible
However, the Ubuntu package repo holds an out-of-date version:
$ ansible --version ansible 188.8.131.52 config file = /etc/ansible/ansible.cfg configured module search path = Default w/o overrides
That maybe fine but this is just a long-winded way of saying, if you want the latest stable release, add the ansible ppa, do not just
apt install ansible.
N.B. This advice seems to hold true for other software projects; the packages issued by Ubuntu via apt are not readily updated.
Option 2: Install via PIP
The ansible install docs suggest an alternative to the OS package management system in the form of the Python Package Index, pip.
Here's the commands, again on Ubuntu:
sudo apt install python-pip pip install ansible ... $ ansible --version ansible 184.108.40.206 config file = None configured module search path = [u'/home/joe/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /home/joe/.local/lib/python2.7/site-packages/ansible executable location = /home/joe/.local/bin/ansible python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]
This installs pip and, at the time of writing, a recent stable version of ansible, 2.4.3.
However, pip just installs ansible as a Python project. It does not create the
/etc/ansible directory, and thus, no ansible.cfg nor hosts file.
This option is not hard once the steps are explained but I feel this could be a lot easier. Searching about for the .cfg file, picking over the inventory/hosts files makes me wonder if I can bullet point the links, why on earth doesn't the official install doc?
Option 3: Fedora
Fedora package management, DNF or Dandified Yum, does not loll behind like apt. You get ansible 2.4.3 in a single install command, no need for additional repo nonsense.
sudo dnf install ansible ... $ ansible --version ansible 220.127.116.11 config file = /etc/ansible/ansible.cfg configured module search path = [u'/home/joe/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.14 (default, Feb 17 2018, 10:42:17) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]
I use Fedora as my primary linux OS but I know that a lot of my networking collegues only have experience with Ubuntu, and this is all about ansible, not forcing a new OS on others.
There is also the option to run the latest dev version from source with a
If you go for that then you are in the same situation as the pip install. If you want to use a .cfg & hosts file, you're on your own. But I'm assuming that those that are happy with running from source are the 'do-it-yourself' types that will not be reading this installation blog.
The inventory file seems to be needlessly confusing in a move away from called the file that you list the IP addresses you want to control. That thing. Ansible hosts has been deprecated, so now everything is about the Inventory file, and what's that called by default? /etc/ansible/hosts! ↩︎
Also, I'm currently having lots of issues with Fedora27 workstation on virtualbox, to the extent I've switched over to VM Workstation. I'm guessing it is virtualbox & the 4.15 kernel. I know there are workarounds but ease of use and defaults trump all here. ↩︎