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
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. Start the environment
Why? The three virtual machines are described in the Vagrantfile: one command creates them identically.
Startenv_0and note the name and IP address of each machine.2. Install with pip
Why? pip gives the latest Ansible version; the virtual environment isolates it from system Python packages.
Onrousseltm-ansible-v02, install Ansible with pip in a virtual environment and check the version.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 ofrousseltm-ansible-v01.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 onrousseltm-ansible-v01with the command suited to its family.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 theansibleuser and give it passwordless sudo.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 foransible, then add the public key to the ansible accountauthorized_keyson the other machines.7. First ping
Why? The ping module checks the whole chain: SSH, user, Python on the target.
-balso checks sudo.Asansibleon 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
🧪 Launch the lab environment ↗
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Course Glossary
Ansible
An open source IT automation tool (IaC) enabling configuration management, application deployment, and orchestration, operating agentlessly via SSH.
Recommended Articles
Identities and access on OVHcloud: account, IAM, OpenStack users and keys
Secure access to OVHcloud: two-factor authentication on the account, OVHcloud IAM (identities, po...
Infrastructure as Code and GitOps: Terraform, Ansible and Argo CD
Manage infrastructure as code: declarative or imperative, Terraform (providers, state, plan, modu...
Automation and infrastructure as code for Elasticsearch: API, Terraform, Ansible and CI/CD
Automate Elasticsearch administration: REST API and clients, the elasticstack Terraform provider ...
Visualizing and automating Zabbix: dashboards, Grafana and API
Build dashboards and maps in Zabbix, use Grafana's Zabbix plugin, and automate configuration with...
Kibana: role, installation and first steps
What Kibana is in the Elastic suite, how to install it with Elasticsearch (start-local, Docker), ...
Compute on Azure: virtual machines, App Service, Functions and containers
Choose and use Azure compute: virtual machines and scale sets (VMSS), App Service, Azure Function...
Vagrant multi-machine: deploying a ready-to-use Docker Swarm cluster
Use a single Vagrantfile to build a three-node Docker Swarm cluster (one manager, two workers) wi...
Containers, Kubernetes and cloud native in a DevOps approach
The role of containers and Kubernetes in DevOps: reproducible images, multi-stage Dockerfiles, re...
Sharing a Vagrant environment: ngrok and the vagrant-share plugin
Make an application running in a Vagrant machine accessible to a colleague or a client: port forw...