Installing Ansible (Raspberry Pi)

My professional day-to-day role sees me administrating Windows OS based systems using Microsoft System Centre Configuration Manager (SCCM) and Active Directory/Group Policy. Knowing what tools are available to manage so many Windows systems at once I’m looking for something similar to manage several Raspberry Pi (Linux) systems at once. Previously I have looked at network booting a Pi and BASH scripting installs, however today I am going to start investigating Ansible.

Ansible is a piece of agentless configuration management software that can connect via SSH to unix-like (e.g. Linux) and Windows based computers to deliver instructions. These instructions are normally written in YAML (which stands for YAML Ain’t Markup Language) files called playbooks. Playbooks contain plays, which contain tasks (that run sequentially) and tasks can call on modules (which can be written in my favourite language, Python).

Don’t worry if this sounds confusing, for this initial blog post I’m looking at the install of Ansible, with future blog posts looking at more of Ansible.

For this project I am using my trusty Raspberry Pi 3 and Raspbian Buster.

Installing Ansible

Installing Ansible takes a few lines, one if your apt is up to date 🙂

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt install ansible
Raspberry Pi Installing Ansible
Raspberry Pi Installing Ansible

Ansible only needs installing on the device that is doing the controlling, it does not need to be installed on the devices receiving the instructions.

Check Ansible Version

To check which version of Ansible is installed, type:

  • ansible –version
Checking Ansible version
Checking Ansible version

Ansible Hosts File

Ansible has a hosts file located at /etc/ansible/hosts and this is an inventory of the remote hosts that you want Ansible to look after.

Ansible Hosts File
Ansible Default Hosts File

The entries in the host file can be put in line by line (ungrouped) or grouped with a heading in braces e.g. [GROUP_HEADING]. I’m going to add my Raspberry Pi IP addresses into a group called Pi_Collection.

Ansible Hosts file edited to include Pi_Collection
Ansible Hosts file edited to include Pi_Collection

To see if Ansible can correctly read the edited hosts file a quick ping can be done:

  • ansible GROUP_HEADING -m ping

For me this is ansible Pi_Collection -m ping. The -m tells Ansible that you want to use a module, in this case the ping module. At this point I feel like I should quote Douglas Adams, “Don’t Panic!”. The response will contain SSH failure messages as the SSH connections have not been set up, this ping is just to check that the Group_Heading / hosts file is set up correctly and as long as all the hosts are there (for me 192.168.1.16, 192.168.1.28 and 192.168.1.3) then all is good.

ansible ping Pi_Collection
ansible ping Pi_Collection

My next Ansible blog post will be around the SSH set up.

6 responses to “Installing Ansible (Raspberry Pi)”

  1. Ansible Setting Up SSH (Raspberry Pi) – Geek Tech Stuff Avatar

    […] the previous post I walked through installing Ansible on a Raspberry Pi and finished at the point of the Ansible inventory being set up but needing some […]

    Like

  2. Ansible – Looking at commands & Playbooks (Raspberry Pi) – Geek Tech Stuff Avatar

    […] Ansible installed and connections to other devices set up, it is now time to have some fun and start using […]

    Like

  3. Ansible – Looking At Basic Security (Raspberry Pi) – Geek Tech Stuff Avatar

    […] This post forms part of the my collection of posts on Ansible including installation; SSH set-up and the basics of a […]

    Like

  4. Ansible – Updating Multiple Pis Hosts Files (Raspberry Pi) – Geek Tech Stuff Avatar

    […] going to use Ansible (running on my Raspberry Pi 3) to update the hosts file on each of the other Raspberry Pis. My […]

    Like

  5. Ansible In A Docker Container – Geek Tech Stuff Avatar

    […] Ansible and Docker are both powerful tools and in this blog post I aim to look at putting Ansible in a Docker container. I’m building on the work of https://hub.docker.com/r/philm/ansible_playbook/dockerfile/  […]

    Like

Welcome to GeekTechStuff

my home away from home and where I will be sharing my adventures in the world of technology and all things geek.

The technology subjects have varied over the years from Python code to handle ciphers and Pig Latin, to IoT sensors in Azure and Python handling Bluetooth, to Ansible and Terraform and material around DevOps.

Let’s connect