• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Rowell Dionicio

Get Techie With It

  • Home
  • About
  • Resources
    • Archives
    • Book List
    • YouTube
  • Learn
    • DevNet Associate
    • PCNSA Certified
  • Blog
  • Contact
  • Show Search
Hide Search

YAML Basics for DevNet

October 21, 2019 By Rowell 1 Comment

Taking a look at the Cisco DevNet Associate exam topics (DEVASC 200-901), one of the first objectives is to compare different data formats. Those data formats you should be able to compare are XML, JSON, and YAML.

To start, I decided to take a look at YAML and what it has to offer from a very basic overview. I’m very new when it comes to DevOps or NetDevOps but this will become my notes of sorts as I look into the DevNet Associate certification.

Studying for the Cisco DevNet Associate Certification?

Let me know what your coding experience is in the comments below.

YAML is a human-readable structured data format which stands for Stands for Yet Another Markup Language or now YAML Ain’t Markup Language, depending on where you look 😉 The official documentation page states the latter.

Goals of YAML

  • Data serialization standard for programming languages.
  • Human-readable structured data format.
  • Portable between programming languages.
  • Consistent model.
  • Expressive and extensible.
  • Easy to implement and use.

A quick overview of YAML

  • Writable and readable.
  • Case sensitive
  • Files end in .yaml or .yml
  • Spaces are used instead of tabs (because various tools treat tabs differently)
  • Indentation is used for structure
  • Colons separate key-value pairs
  • Dashes create bullet lists
  • The start of a YAML file begins with three dashes

Data structures:

  • Mappings (hashes/dictionaries)
  • Sequences (arrays/lists)
  • Scalars (strings/numbers)

Working with Blocks
Block collections use indentation for scope and begin each entry on its new line. Block sequences use a dash and space to indicate each entry. Mappings use a colon and space to mark a key-value pair.

To create a comment, you must use a hash tag.

Sequence
A sequence entry will be denoted by a dash -.

 - netsw-idf-01
 - netsw-idf-02
 - netsw-idf-03 

Scalar
A scalar is just a single value. They can be strings, numbers, Boolean, or null values.

# scalars can be quoted
“GigabitEthernet1/0/1”

# scalars can also be unquoted
GigabitEthernet1/0/2 

Mapping Scalars to Sequences
Also creates an array.

routers:
    - rtr-idf-01
    - rtr-idf-02
switches:
    - netsw-idf-01
    - netsw-idf-02

Sample Inventory in YAML

—--
sites:
    - name: san-jose # This is a comment. Begin block 1.
        hosts:
            - hostname: r1
              host: 192.168.1.1
              os: cisco_ios
            - hostname: sw1
              host: 192.168.1.5
              os: cisco_ios
            - hostname: sw2
              host: 192.168.1.6
              os: junos

    - name: san-diego # This is a comment. Begin block 2.
        hosts:
            - hostname: r2
              host: 192.168.2.1
              os: cisco_ios
            - hostname: sw1
              host: 192.168.2.5
              os: cisco_ios

Have we created a list or a dictionary? List items which is a dictionary.

Here’s a sample YAML script used to configure a VLAN on a Cisco switch.

---
- hosts: cisco
  connection: network_cli
  tasks:
    - nxos_vlan:
      vlan_id: 10
      name: STORAGE

Share this:

  • Facebook
  • LinkedIn
  • Twitter

Related

Filed Under: Coding, DevNet Associate Tagged With: 200-901, devasc, devnet associate, yaml

About Rowell

Wi-Fi expert. Coffee addict ☕️. Tech nerd. Business owner.

Reader Interactions

Comments

  1. Nikhil says

    September 14, 2020 at 7:02 am

    Short and simple read. I will be looking forward to more blog posts on your site.
    I had studied basic programming probably 10 years back and still remember few things here and there. I have started studying Python and its fun so far but when it comes to integrating it with other DevOps tools, it gets on my nerves 🙂

    Reply

Leave a Reply Cancel reply

Primary Sidebar

Recent Posts

  • Passed Palo Alto Networks Certified Security Administrator (PCNSA)
  • 5 Years Running
  • Q4 2021 and Yearly Income Report
  • I PASSED JNCIA-MistAI
  • Admins and Role-Based Access Control – PCNSA

Categories

  • bschool
  • Certifications
  • Coding
  • DevNet Associate
  • Events
  • Lab
  • Networking
  • Personal
  • Podcasting
  • Professional
  • Reviews
  • Security
  • Short Stories
  • Uncategorized
  • Wireless

Archives

  • May 2022
  • January 2022
  • December 2021
  • November 2021
  • August 2021
  • July 2021
  • April 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • November 2018
  • September 2018
  • August 2018

Copyright © 2022 · Written by Rowell Dionicio · You're awesome.