- Lab
- A Cloud Guru
Ansible Commonly Used Modules
Ansible has many built in modules, but some are used a lot more than others. In this lab we're going to reinforce the usage of some of the more common ones, so that they're easier for you to remember when the time comes. *This course is not approved or sponsored by Red Hat.*
Path Info
Table of Contents
-
Challenge
Verify Connectivity in the Environment
On the command line run
ansible -m ping all
. -
Challenge
Install httpd
Your playbook,
webservers.yml
should look something like this:--- # Common Modules Playbook # - name: Common Modules Playbook become: yes hosts: webservers tasks: - name: Install httpd on webservers yum: name: httpd state: present
-
Challenge
Start and Enable the httpd Service
In this task all we have to do is add the following to the
webservers.yml
playbook:- name: Start the httpd service service: name: httpd state: started enabled: yes
-
Challenge
Create a dba User Account
Your playbook,
dbserver.yml
, should look similar to this:--- - name: DB server playbook become: yes hosts: dbservers tasks: - name: Add the 'dba' user to the dbservers user: name: dba
-
Challenge
Copy the Required File
You can add to your
dbserver.yml
playbook something similar to the following:- name: Copy required DBA files copy: src: /root/DBAstuff.txt dest: /home/dba/ owner: dba group: dba mode: 0600
-
Challenge
Create /var/www/html/index.html
The final addition to your
webserver.yml
playbook should look similar to:- name: Create index.html file: path: /var/www/html/index.html state: touch
-
Challenge
Clone the Ansible Git Repository into /opt on adminservers
Your admin.yml playbook will look something like this:
--- - name: Use git to clone the Ansible repo hosts: admins become: yes tasks: - name: Install git yum: name: git state: present - name: Use the git module git: repo: https://github.com/ansible/ansible.git dest: /opt
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.