Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Using Ansible to Get Clients to a Specific State

Often you'll find yourself wanting to get a group of servers set up from scratch rather than running individual configuration commands. Often it can seem like a daunting task to write a single playbook to handle a chain of tasks, switching host groups, calling multiple modules, and more.This lab will give you the opportunity to practice writing a playbook that will run all of that at once. *This course is not approved or sponsored by Red Hat.*

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 07, 2025
Duration
45m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Install the "linuxacademy-backup-software" Package throughout Our Environment
    1. This section of our playbook should look like:
    ---
    - name: Install backup software
      hosts: all
      become: yes
      tasks:
       - name:  yum command
         yum:
          name: linuxacademy-backup-software
          state: present
         ignore_errors: yes    
    
  2. Challenge

    Install httpd on the webserver Group
    1. The next section of the playbook should look like this:
    - name: Install httpd
      hosts: webservers
      become: yes
      tasks:
       - name: httpd install
         yum:
          name: httpd
          state: present
       - name: Service management for httpd
         service:
          name: httpd
          state: started
          enabled: yes
    
  3. Challenge

    Start and Enable the httpd Service on the webserver Group
    1. Continuing from the last task, the next section should look like this:
       - name: Service management for httpd
         service:
          name: httpd
          state: started
          enabled: yes
    
  4. Challenge

    Create a dba User Account on the dbserver Group
    1. This portion of our playbook should look like this:
    - name: DB server management
      hosts: dbservers
      become: yes
      tasks:
       - name: Add user
         user:
          name: dba
          state: present
    
  5. Challenge

    Copy /root/DBAstuff.txt to the New User's Home Directory
    1. Continuing along from the last task, this portion of our playbook should look like this:
       - name: Copy DB user data
         copy:
          src: /root/DBAstuff.txt
          dest: /home/dba/DBAstuff.txt
          owner: dba
          group: dba
          mode: 0600
    
  6. Challenge

    Create index.html in /var/www/html on the Web Server
    1. This portion of our playbook should look like this:
    - name: Set up index.html on webservers
      hosts: webservers
      become: yes
      tasks:
       - name: Create and populate index.html
         lineinfile:
          path: /var/www/html/index.html
          line: Waiting for content.
          create: yes
          owner: apache
          group: apache
          mode: 0644
    
  7. Challenge

    Install Git on the webserver and dbserver Groups, If It Is Not Already Installed
    1. This next portion of our playbook should look like this:
    - name: Enable devs to easily populate content
      hosts: webservers:dbservers
      become: yes
      tasks:
       - name: Install git
         yum:
          name: git
          state: present
    
  8. Challenge

    Create Red Hat Server-Specific Files
    1. This last portion of our playbook should look like this:
    - name: Red Hat specific configuration
      hosts: all
      become: yes
      tasks:
       - name: Populate file with IP addresses
         lineinfile:
          path: /root/addresses
          line: "{{ ansible_facts['all_ipv4_addresses'] }}"
          create: yes
         when: ansible_facts['os_family'] == 'RedHat'
    
  9. Challenge

    Running the Playbook
    1. To set our playbook in motion, run this:
    ansible-playbook state.yml
    
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight