Setup Ansible by Yourself

AnsibleAnsibleBeginner
Practice Now

Introduction

Welcome to the Ansible Setup Challenge! You've just learned how to install and configure Ansible on an Ubuntu system. Now, it's time to put your skills to the test. Imagine you're a newly hired system administrator, and your first task is to set up Ansible on a fresh Ubuntu server. This challenge will simulate that real-world scenario, pushing you to apply what you've learned and demonstrate your ability to work independently with Ansible.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/PackagesandSoftwaresGroup(["`Packages and Softwares`"]) linux(("`Linux`")) -.-> linux/RemoteAccessandNetworkingGroup(["`Remote Access and Networking`"]) ansible(("`Ansible`")) -.-> ansible/AnsibleSetupandConfigurationGroup(["`Ansible Setup and Configuration`"]) ansible(("`Ansible`")) -.-> ansible/InventoryManagementGroup(["`Inventory Management`"]) ansible(("`Ansible`")) -.-> ansible/ModuleOperationsGroup(["`Module Operations`"]) linux/PackagesandSoftwaresGroup -.-> linux/apt("`Package Handling`") linux/RemoteAccessandNetworkingGroup -.-> linux/ssh("`Secure Connecting`") ansible/AnsibleSetupandConfigurationGroup -.-> ansible/install("`Ansible Setup`") ansible/InventoryManagementGroup -.-> ansible/groups_inventory("`Define Inventory Groups`") ansible/ModuleOperationsGroup -.-> ansible/ping("`Network Test`") subgraph Lab Skills linux/apt -.-> lab-390383{{"`Setup Ansible by Yourself`"}} linux/ssh -.-> lab-390383{{"`Setup Ansible by Yourself`"}} ansible/install -.-> lab-390383{{"`Setup Ansible by Yourself`"}} ansible/groups_inventory -.-> lab-390383{{"`Setup Ansible by Yourself`"}} ansible/ping -.-> lab-390383{{"`Setup Ansible by Yourself`"}} end

Ansible Installation and Configuration

Tasks

  1. Update and upgrade the system packages.
  2. Install Ansible on the LabEx VM (Ubuntu 22.04).
  3. Configure SSH for passwordless authentication to localhost.
  4. Create an Ansible inventory file with two groups: "local" and "webservers".
  5. Test Ansible connectivity to ensure it's working correctly.

Requirements

  • All operations must be performed in the /home/labex/project directory.
  • The Ansible version installed must be the latest available.
  • The SSH key pair must be generated with RSA 4096 bits and the comment "labex@ansible-challenge".
  • The Ansible inventory file must be created at /etc/ansible/hosts.
  • The inventory file must contain:
    • A "local" group with "localhost" using local connection.
    • A "webservers" group with a host named "web1" pointing to localhost using SSH connection.
  • You must be able to run Ansible commands without password prompts.

Tips

You'll be prompted for the labex user's password. You can find the password in the VNC terminal by running:

echo $PASSWORD

Example

After completing the challenge, running ansible --version should output something similar to:

ansible x.x.x
...

The content of /etc/ansible/hosts should look like:

[local]
localhost ansible_connection=local

[webservers]
web1 ansible_host=localhost ansible_connection=ssh ansible_user=labex

Running ansible all -m ping should return success for both localhost and web1.

Summary

In this challenge, you've demonstrated your ability to set up Ansible on a fresh Ubuntu 22.04 system. You've updated the system, installed Ansible, configured SSH for passwordless authentication, created an Ansible inventory, and verified the setup's functionality. These skills are fundamental for any system administrator or DevOps engineer working with Ansible. By completing this challenge, you've shown that you can independently deploy Ansible in a new environment, preparing you for real-world scenarios where you'll need to quickly set up automation tools on new systems.

Other Ansible Tutorials you may like