Ansible Quick Start Guide

Ansible Quick Start Guide

What is ansible?

Ansible is an automation tool which can be used to configure, deploy and monitor multiple servers simultaneously. When setting up ansible, there are some terms that a new user should be familiar with:

  • control node - this is the server/machine that runs ansible and from which the administrator will issue commands.

  • managed nodes/target nodes - these are the servers/machines which are being administered.

  • modules - units of code that can control system resources or execute system commands (doc.ansible.com).

  • playbooks - yaml files that contains ansible code used to configure servers.

Quick Start guide

Using the ansible documentation I have configured a quick start guide that gets you up and running with ansible in minutes:

  • Prerequisites

    • Control Node - ensure that Python 3.9 or later is installed

    • Managed Nodes

      • Does not need to have ansible installed

      • Should have Python 3.9 or later installed

      • Should have a user account with ssh enabled

  • Install and setup ansible on the control node

    • Verify that pip is installed python3.10 -m pip -V

    • If pip is not installed it can be installed using the following commands:

        sudo apt install curl && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py --user
      
    • Install ansible using pip python3.10 -m pip install --user ansible

    • Verify that ansible is installed ansible --version this should produce the following output:

        ansible [core 2.14.2]
          config file = None
          configured module search path = ['/home/fikradev/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
          ansible python module location = /home/fikradev/.local/lib/python3.10/site-packages/ansible
          ansible collection location = /home/fikradev/.ansible/collections:/usr/share/ansible/collections
          executable location = /home/fikradev/.local/bin/ansible
          python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (/usr/bin/python3.10)
          jinja version = 3.1.2
          libyaml = True
      
    • If instead of the above output, you receive an error, simply run the following command to add /local/bin to PATH: export PATH=~/.local/bin:$PATH. You can now rerun ansible --version to verify the version.

That is it, you now have ansible installed and running on your control node. The next step is to create your inventory file, add some hosts, verify that they can communicate with the control node and start playing around.