Ansible setup on Azure
- Watch classroom recording
Ansible Terms
- In Ansible to perform configuration management we write playbooks or build adhoc commands
- Playbook based approach is preferred for repetitive tasks
- Ansible playbook for now can be called as a way of expressing desired state which has the following structure

- Playbook is collection of play’s & each play will have tasks which define the desired state
---
- name: update os packages and install apache
become: yes
hosts: all
tasks:
- name: update packages
ansible.builtin.apt:
name: apache2
update_cache: yes
state: present
- name: install utilities
become: yes
hosts: all
tasks:
- name: update utils
ansible.builtin.apt:
name:
- git
- tree
update_cache: yes
state: present
YAML
- Ansible playbook are written in yaml format.
- YAML is collection of name value (key value) pairs
- YAML was designed to be both machine readable as well as human readable
- each key value syntax
<key>: <value>
- yaml
<key1>: <value1>
<key2>: <value2>
..
<keyn>: <valuen>
-
values are of multiple types
- text: the value can be with or without quotes. quotes can be single or double
yaml
course: DevOps
course: 'DevOps'
course: "DevOps"
- number
yaml
age: 15
age: 15.1
- boolean
yaml
online: True
online: yes
online: False
online: no
- list: this is used to represent multiple items
“`yaml
languages: ["english", "hindi", "telugu"]
languages:</li>
<li>english</li>
<li>hindi</li>
<li>telugu
“`
- map/object: this is collection of name value pairs describing a single key
“`yaml
address:
flatno: 601
building: nilgiri
city: hyderabad
address: { 'flatno': 601, 'building': 'nilgiri', 'city': 'hyderabad' }</li>
</ul>
“`
-
Refer Here for Ansible YAML Tutorial
- Exercises:
- What does
--- signify in yaml
- yaml has two extensions
.yml or .yaml
- abbreviate yml and yaml why we have two extensions
- Setup ansible on AWS and Azure with two node setups
Writing YAML for Ansible Playbook
- We need to follow the structure defined by ansible
- This will be discussed in next session
Like this:
Like Loading...