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
Labs

Deploying Ansible

Ansible is a powerful automation tool that can be used for managing configuration state or even performing coordinated multi-system deployments. This activity is intended to provide the steps to get started with a simple Ansible configuration.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 30m
Published
Clock icon Jan 21, 2019

Contact sales

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

Table of Contents

  1. Challenge

    Install Ansible on the control host.

    Run the following commands on the control host:

    sudo yum install epel-release

    sudo yum install ansible

  2. Challenge

    Create an `ansible` user on both the control host and workstation host being sure to set a password you can remember.

    On each host, run the noted commands below. Make sure you set a password you can remember (you will need it later).

    Assuming you are logged in as cloud_user:

    sudo useradd ansible

    sudo passwd ansible

  3. Challenge

    Configure a pre-shared key for Ansible that allows the user to log in from `control` to `workstation` without a password.

    Assuming you are logged into control as cloud_user, run the following commands providing the appropriate passwords when prompted and default options otherwise:

    sudo -i -u ansible (provide cloud_user a sudo password)

    ssh-keygen (accept default options by pressing enter )

    ssh-copy-id workstation (provide ansible user a password)

    logout

  4. Challenge

    Configure the Ansible user on the workstation host so that Ansible may sudo without a password.

    1. Log into the workstation host as cloud_user and run the following commands:
      sudo visudo
    • Add text at the end of the file that is opened:
      ansible ALL=(ALL) NOPASSWD: ALL
    • Save file:
      (:wq in vim)
  5. Challenge

    Create a simple inventory in `/home/ansible/inventory` consisting of only the `workstation` host.

    1. On the control host as the ansible user run the following commands:

    vim /home/ansible/inventory (note: you may use any text editor with which you are comfortable)

    • Add the text "workstation" to the file and save using (:wq in vim).
  6. Challenge

    Write an Ansible playbook in `/home/ansible/git-setup.yml` on the control node that installs `git` on `workstation` then execute the playbook.

    1. On the control host as the ansible user run the following commands:
      vim /home/ansible/git-setup.yml (You may use any text editor with which your are comfortable.)
    • Add the following text to the file:
        --- # install git on target host
        - hosts: workstation
          become: yes
          tasks:
          - name: install git
            yum:
              name: git
              state: latest
    
    • Save (:wq in vim) and quit the text editor.

    • Run ansible-playbook -i /home/ansible/inventory /home/ansible/git-setup.yml.

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