Introduction to Installing Ansible

Hello dear reader. Welcome back to this most average blog. This is WyWyFe reporting in live from the time that I wrote this. Tonight, I will take you on a journey through the many steps of how to install Ansible on your Linux machine. We will be using Ubuntu to accomplish this. I hope you enjoy this process as much as I most definitely have.

Update and Upgrade!

You should always do this any time you install any package or feature on Linux, but it bears repeating here. Run the following in CLI:

sudo apt-get update

sudo apt-get upgrade -y

Actually installing Ansible

Alright. You’ve done the prep work. Now it’s time to get down and dirty with Ansible. For the purpose of not altering the local filesystem that we use for everyday tasks, let’s use one we do not use for everyday tasks. We will use a VirtualBox virtual machine to host Ansible.

Use the following command to install the repository we need prior to install Ansible (make sure to hit “Enter” to continue with the installation, it is not an automatic download): sudo apt-add-repository ppa:ansible/ansible It should look something like this: picture 1

With this repository installed, you can now use sudo apt-get install ansible-y to install Ansible. Another important fact: Ansible requires Python in order to run its modules, so if you do not yet have it installed, run sudo apt-get install python -y and you are set. Maybe fiddle with Python for a little in your free time if you like. You have it for free now!

Using the Ansible

To access the Ansible server, you need to generate keys on the machine you just installed the repository, python and Ansible onto. Type sudo ssh-keygen in the CLI and you should see prompts like these pop up: sshkeygen

Kind of cute, right? It looks like an owl in a box, except it’s a visual representation of your SSH key!

Side note: Try not to lose the password you set for your file. Write it down! Also, you do not have to name your file anything special. For the sake of this demonstration, I named it sshkeys1, but you could just as easily hit the enter key when that prompt shows up. You can keep the default location and not cause any issues.

To view this key, type sudo cat sshkeys1.pub (if you named your file sshkeys1 too).

There are many ways you can use these SSH keys. You could use them to SSH into your Ansible server from another device, for example, which is what most people use these for. From here, the world is your oyster. Enjoy learning about Ansible!