DevOps Classroom Series – 10/Mar/2020

YAML

  • Representing data in the form of name value pairs
  • Both Machine readable & human readable
  • Uses significant Whitespaces
  • Refer Here for yaml basics

Samples

  1. Yaml representing movie
---
name: KGF Chapter 1
languages:
  - Kannada
  - Telugu
  - Hindi
  - Tamil
  - Malayalam
Cast:
  - Yash
  - Anant Nag
  - Prashant
Category: Action

  1. Movies in bookmyshow in YAML
---
Now Showing:
  - name: Bheesma
    Rating: 84
    Screens:
      - name: PVR Panjagutta
        show timings:
		  - 11:00
		  - 14:00
	      - 18:00
	      - 21:00
	    price: 300
  - name: Hit
	Rating: 87
	Screens:
	  - name: Inox GVK
		show timings:
		  - 12:00
		  - 16:00
	    price: 200
	  - name: Gokul
	    show timings:
		  - 11:15
		  - 14:15
	      - 18:15
	      - 21:15
	    price: 150

  • After writing YAML validate with any online YAML validator such as http://www.yamllint.com/
  • Now have a look at sample ansible playbook
---
- hosts: all
  become: yes
  tasks:
    - name: install java and update packages
      apt:
        name: openjdk-8-jdk
        update: yes
        state: present
    - name: download spring pet clinic
      get_url:
        url: https://get.spc.com/jar
        dest: /home/ubuntu/spc.jar
        state: present
    - name: execute java jar
      command: java -jar /home/ubuntu/spc.jar

Leave a Reply

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

About learningthoughtsadmin