This blog post covers some quick tips, including Q/A and useful links from Day 2 Live Interactive training on Ansible for Beginners. covering Ansible Playbook, Modules & Privilege Escalation, Ansible Variables
Lab6, Lab7 from 9 Hands-On Labs
In Day 1 session, the previous week, we got an overview of Introduction to ansible, Ad-hoc commands.
We have already seen the basics of Playbook in Day1 now we continue to learn more on Playbook.
Playbook
First Playbook
---
- name: Enable Intranet Services
hosts: all
become: yes
tasks:
- name: Install httpd and firewalld
yum:
name:
- httpd
- firewalld
state: latest
Also Check: Our blog post on Ansible Tutorial. Click here
Privilege Escalation
- name: Ensure the httpd service is running
service:
name: httpd
state: started
become: yes
Modules

- ansible nodes -m shell -a “whoami”

- ansible nodes -m shell -a “whoami” -b

Variables
- hosts: all
vars:
greeting: Hello world!
tasks:
- name: Ansible Basic Variable Example
debug:
msg: "{{ greeting }}"
In the above playbook, the greeting variable is substituted by the value Hello world! when the playbook is run. The playbook simply prints the message Hello world! when executed.

Ansible Facts
Quiz Questions!
Check out these questions and see if you can answer them
What are the things Ansible can do?
A. Task automation
B.Configuration management
C.Deployment of application
D.All of the above
Which argument will you use to specify a variable for your Ansible playbook?
A. -c
B.-d
C.-e
D.None of them
Comment your answer in the comment box.
The right answer will be revealed in my next week’s blog.
Here is the answer to the question shared last week.
a. JSON format
b. YAML format
c. XML format
d. HTML format
Related Links/References
- Ansible Tutorial | Ansible Architecture | Ansible tower | Ansible Ad Hoc commands
- Ansible for beginners step-by-step activity guides hands-on-lab
- Ansible for Beginners | Overview | Architecture & Use Cases
Next Task For You
If you are considering in-depth learning about Ansible in the coming days, then do join our WAITLIST and don’t miss an opportunity to attend a free class and gain a plethora of insights on the basics of Ansible.


