Automate Common Admin Tasks with Ansible
In this lab, you’ll practice building an Ansible project automating common systems administration tasks, such as file and user account management. When you’re finished, you’ll have a basic Ansible playbook that manages a fleet of Linux servers.
Terms and conditions apply.
Lab info
Lab author
Challenge
Getting Started in the Lab Environment
Here are the initial instructions and explanation of the lab environment. Read this while your environment is busy creating itself from nothing. Yes, this violates physics; we know. How fun!
Challenge
Build YAML-Based Ansible Inventory
To start with, you will build a simple Ansible inventory from scratch by creating and populating a YAML file containing reachability and authentication information for two Linux hosts that will be managed by Ansible. You will also learn how to confirm the Ansible inventory is structured properly through the "ansible-inventory" command.
Challenge
Confirming Host Reachability with Ansible
You will verify that Ansible can connect to both Linux hosts using information within the Ansible inventory file, and will do this via a series of ad hoc Ansible commands.
Challenge
Creating Files and Directories with Ansible
Here, you will create a simple Ansible playbook that creates specific directories and files on Ansible-managed hosts. You will use a simple technique to have Ansible populate specific files with static content. You will also manage the permissions and ownership of files and directories on Ansible-managed hosts. Through this challenge, the concept of idempotency–where Ansible automation does not make changes to managed hosts unless changes need to be made–will be reinforced.
Challenge
Creating and Managing User Accounts on Hosts
You will now build off the Ansible playbook developed in the previous challenge by adding tasks to create user accounts on your Ansible-managed hosts. You will also learn how to manage group membership of the newly created user accounts.
Challenge
Managing File Permissions and Ownership
In prior challenges, you created a new file and a new directory, as well as a new user account and a new group. Now, you will tie both concepts together; in this challenge, you will augment your Ansible playbook to factor in file permissions and ownership.
Challenge
Scoping Ansible Execution against Hosts
Finally, you will continue to iterate on the Ansible playbook developed in previous challenges by adding tags to tasks within your Ansible playbook. You will then learn how to leverage tags, as well as limit the execution of Ansible automation to specific hosts in your inventory.
Challenge
The Last Challenge
Welcome to the final challenge! This is your last chance to experiment in the environment. Clicking Finish Lab will end this little world that flittered into existence just for you.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.
Recommended prerequisites
- Basic understanding of Linux shell/command line interface–how to execute commands, review manual pages of commands, use flags to modify command line execution, pipes, etc.
- Basic understanding of the Linux file system and user accounts–how files and directories are structured on Linux systems, how file permissions and ownership work on Linux systems, and how user accounts are created, accessed, and managed.
- Basic understanding of Ansible concepts. As this lab loosely covers the same material as the “Getting Started with Ansible” Pluralsight course, it is assumed the learner has completed this course, and has a conceptual understanding of how Ansible works.