Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon

Ad-Hoc Ansible Shell Scripts

One of the keys to success with Ansible is being able to run `ad-hoc` commands and in this particular exercise we will make use of scripting and ad-hoc commands to perform tasks. The value of `ad-hoc` commands in scripts is underscored by the fact that it is an objective of the *Red Hat Certified Ansible Specialist* exam. In this lab we will create a bash script and use it to perform Ansible Ad-hoc tasks. Note: Ansible has been setup and configured for use. *This course is not approved or sponsored by Red Hat.*

Google Cloud Platform icon

Path Info

Clock icon Intermediate
Clock icon 30m
Clock icon Sep 13, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Sign onto the Ansible Control Node Server as cloud_user and Change to the ansible User, Then Test Ansible Has Been Set Up

    Sign into the server called Ansible Control Node as cloud_user and change to the ansible user via the su - ansible command.

    Test that Ansible is working, with an ad-hoc command. One possible command to use is:

    ansible all -m ping
  2. Challenge

    Create a Bash Script Called That Accepts a Parameter and Uses an Ad-Hoc Ansible Command to Install Software

    Using Bash, create a script that accepts a variable on the command line and uses an ad-hoc Ansible command to install software on the node1 and node2 servers.

    The script should exit if no program to install has been typed in the command line.

  3. Challenge

    Test the Script to Ensure It Will Exit If a Command Line Argument Has Not Been Entered

    If no command line argument has been entered, the script should exit.

  4. Challenge

    Make Sure the Script is Executable and Use it to Install Elinks on the node1 and node2 Servers

    Ensure the script is executable, and run it to install ELinks on the nodes.

  5. Challenge

    Log into node1 and node2 and Ensure the ELinks Package Has Been Installed

    As the ansible user, log into the node1 and node2 servers, and ensure that ELinks has been installed.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

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.

Start learning by doing today

View Plans