31.1 C
New Delhi
Saturday, October 5, 2024

Ansible on the Raspberry Pi-4

Must Read

Add proper shutdown button to Raspberry Pi-4 The Easiest Way!

­ Hardware Setup: Shutdown Button Setup: In this tutorial, I will share my workaround to configure the proper shutdown button...

Digitization vs. Digitalization

The two words may sound similar, but there is a notable difference between Digitization and Digitalization, and this ambiguity...

Big Data – Cluster Environment: Powered by Raspberry Pi-4, Hadoop, and Spark

Introduction: This write-up contains detailed instructions to create a low-cost, high-performance Big Data cluster using Raspberry Pi – 4. The buzzword...

We have prepared a lab environment for our new trainees to get their hands dirty on configuration management on Cloud using Ansible as primary tool. We got clusters of Raspberry pi-4 to orchestrate as an in-house cloud environment, this helps us to make our next-gen innovators to envisualize the divergent thinking.

Why Ansible?

Ansible is an open-source IT configuration management automation tool, which can dramatically improve the scalability, consistency, and reliability of your Cloud Environment.

Ansible can automate three types of tasks:

  • Configuration management: Change the configuration of an application, OS, or device; start and stop services; install or update applications; implement a security policy; or perform a wide variety of other configuration tasks.
  • Provisioning: Set up the various servers you need in your infrastructure (Infrastructure as code).
  • Applistructure deployment: Make DevOps easier by automating the deployment of internally developed applications to your production systems.

Ansible is capable to automate IT environments whether they are hosted on traditional servers, virtualization platforms, or in the cloud. It can also automate the configuration of a wide range of systems and devices such as storage, databases devices, networks, firewalls, and many others.

To ensure that your web servers are running on the latest version of Apache, you could use a playbook similar to the following and Ansible would handle the rest.

---
- hosts: Unio_webservers
  vars:
    http_port: 80
    max_clients: 200
  remote_user: Unio_root
  tasks:
  - name: make sure latest apache installed
    yum: name=httpd state=latest
  - name: write the apache config file
    template: src=/srv/httpd.j2 dest=/etc/httpd.conf
    notify:
    - restart apache

  - name: ensure running it at boot
    service: name=httpd state=started enabled=yes
  handlers:
    - name: restart apache
      service: name=httpd state=restarted

The mentioned playbook, actually installs or updates Apache is “yum: name=httpd state=latest”. You just specify the name of the software package (httpd) and the desired state (latest) and Ansible does the rest. The other tasks in this playbook update the Apache config file, restart Apache, and enable the Apache to run at boot time.

Michael DeHaan, the creator of Ansible, accomplished this by using YAML, it’s a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. Puppet and Chef, on the other hand, use Ruby. The Ansible deployment is further simplified by making it agentless. That is, instead of installing an agent on every system you want to manage (as you have to do with Puppet and Chef), Ansible just requires that systems have Python (on Linux servers) or PowerShell (on Windows servers) and SSH.

Installing Ansible on the Raspberry Pi-4, the real fun!

Ansible, itself, is a configuration management system that is agentless, so we only need to install Ansible on the controller which is often a machine in infrastructure known as controller.

$ sudo apt update


$ sudo apt install -y ansible sshpass

Note: Installing from the Raspbian repositories, will give you the earlier version of Ansible, 2.2.1. In order to get the latest version of Ansible on the Raspberry Pi-4 we need to check in the Ansible website, where they have excellent documentation,

https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-debian

Here we can see that a Ubuntu PPA, Personal Package Archive for Debian. We can edit the file /etc/apt/sources.list and add a new line:

$ echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | sudo tee --append /etc/apt/sources.list

With the new repository listed we will need to grab the GPG signing key from Ubuntu, to do this we need to add the Directory Manager to manage the download.

$ sudo apt install dirmngr -y

We can now install the signing key:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367  

With the key installed we can now run the update again to initialize the package list and before installing the latest version of Ansible:

$ sudo apt update


$ sudo apt install -y ansible

We will now have a later version direct from Ansible. You can check that by using :

$ ansible --version

That’s it, enjoy cloud configuration management automation.

- Advertisement -
- Advertisement -
Latest News

Add proper shutdown button to Raspberry Pi-4 The Easiest Way!

­ Hardware Setup: Shutdown Button Setup: In this tutorial, I will share my workaround to configure the proper shutdown button...

Digitization vs. Digitalization

The two words may sound similar, but there is a notable difference between Digitization and Digitalization, and this ambiguity has created uncertainty even among...

Big Data – Cluster Environment: Powered by Raspberry Pi-4, Hadoop, and Spark

Introduction: This write-up contains detailed instructions to create a low-cost, high-performance Big Data cluster using Raspberry Pi – 4. The buzzword in the industry nowadays is...

Design for Failure : Pre-Mortem

A good leader, gives the team a logical reason to think and emotional support to act - relentlessly to achieve organisational goal. Project failures often...

Ansible on the Raspberry Pi-4

We have prepared a lab environment for our new trainees to get their hands dirty on configuration management on Cloud using Ansible as primary...
- Advertisement -

More Articles Like This

- Advertisement -