Installing Ansible (Raspberry Pi)

Raspberry Pi Installing Ansible

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, and 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 thoughts on “Installing Ansible (Raspberry Pi)

Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

Google photo

You are commenting using your Google 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

This site uses Akismet to reduce spam. Learn how your comment data is processed.