RousselTMLEARNING

TP · Ansible: from discovery to expertise

Lab: Install Ansible and prepare the machines

What you will learn in this TP
  • Install Ansible with pip
  • Install Ansible with the package manager
  • Create an automation account
  • Validate the SSH connection
Mode :

All steps and instructions are shown. Recommended for this lab: guided

Introduction #

Context. Before automating anything, you need a control node and machines that accept it. You prepare the course "env_0" environment.

Prerequisites: the cloned test environment (lab "Test environment setup"), VirtualBox and Vagrant  ·  Estimated time: 40 min

Ansible installed on two machines and a "pong" from every host, as the ansible user with sudo.

Setup #

Guided steps, with their solution.

  1. 1. Start the environment

    Why? The three virtual machines are described in the Vagrantfile: one command creates them identically.

    Start env_0 and note the name and IP address of each machine.
  2. 2. Install with pip

    Why? pip gives the latest Ansible version; the virtual environment isolates it from system Python packages.

    On rousseltm-ansible-v02, install Ansible with pip in a virtual environment and check the version.
  3. 3. Identify the system

    Why? The package manager depends on the system family: apt for Debian and Ubuntu, dnf for Red Hat, Rocky and Alma.

    Identify the system family and version of rousseltm-ansible-v01.
  4. 4. Install with the package manager

    Why? The system package is updated with the rest of the machine: it is the simplest choice to maintain.

    Install Ansible on rousseltm-ansible-v01 with the command suited to its family.
  5. 5. Create the ansible user

    Why? A dedicated automation account is easy to trace and revoke, without touching personal accounts.

    On each of the three machines, create the ansible user and give it passwordless sudo.
  6. 6. Distribute an SSH key

    Why? Ansible connects over SSH: a key avoids passwords and allows unattended automation.

    On the control node, generate a key for ansible, then add the public key to the ansible account authorized_keys on the other machines.
  7. 7. First ping

    Why? The ping module checks the whole chain: SSH, user, Python on the target. -b also checks sudo.

    As ansible on the control node, write an inventory with the noted addresses, then run a ping and a command with privilege escalation.

Validate your work

Check that each goal above is reached and that you get the result described in the introduction.

Difficulty level : ●●○○○ (2/5)

My progress

  • ⏱ Estimated time : ≈ 40 min

🧪 Launch the lab environment ↗

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

4.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Course Glossary

Ansible

An open source IT automation tool (IaC) enabling configuration management, application deployment, and orchestration, operating agentlessly via SSH.

Recommended Articles

Ansible: the inventory (static, dynamic, groups and variables)

Understand and master the Ansible inventory: INI and YAML files, groups, host and group variables...

Ansible: ad-hoc commands

Run immediate actions on a fleet of servers with ansible: the ping, command, shell, copy, apt, se...

Ansible: structuring your code with roles

Create, organize and reuse Ansible roles: directory layout, defaults, tasks, handlers, templates,...

Ansible: managing security (Vault, SSH, privileges and secrets)

Securing Ansible: Ansible Vault, SSH key authentication, become and sudo, no_log, hardening the c...

Ansible: driving your automations with a graphical interface (AWX, Semaphore, AAP)

Compare and install Ansible's graphical interfaces: AWX, Ansible Automation Platform, Semaphore a...

Ansible: generating dynamic files with Jinja2 and facts

Create dynamic configuration files: Jinja2 templates, variables, facts, filters, loops, condition...

Ansible: going further (testing, quality, CI/CD and performance)

Industrialize Ansible: ansible-lint, yamllint, Molecule, continuous integration, collections, exe...

Ansible best practices: structure, idempotence, security and quality

Ansible best practices: project organization, naming, FQCN, idempotence, modules rather than shel...

Ansible: managing your infrastructure with playbooks (Infrastructure as Code)

Write production playbooks: project structure, plays, handlers, tags, serial strategy, error hand...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!