DevOps Classroom notes 04/Mar/2025

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
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%