Difference between revisions of "YAML"

From rbachwiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
===Syntax===
===Syntax===


* Key value pair
== Key Value Pairs ==
* "microservice" becomes an object with directives under it.
* "microservice" becomes an object with directives under it.
  microservice:
  microservice:
Line 11: Line 11:
   version: 1.7
   version: 1.7


* Create a list
== Create a List ==
 
   microservice: #list name
   microservice: #list name
   - app: user-auth #items of the list
   - app: user-auth #items of the list
Line 21: Line 22:
     port: 9002
     port: 9002
     version:
     version:
    - 1.9
      - 1.9
    - 2.0
      - 2.0
    - 2.1
      - 2.1
#can be written as
      version: [1.9, 2.0, 2.1]
 
==Multiline String ==
 
miltilineString: |
  this is a multiline string
  and this is the next line
  next line
 
==Single line string, use the ">"==
* written on multiple lines, but will display as a single line
 
singleLineString: >
  this is a line
  another line
  yet another line, but it will be displayed on a single line because of the >
 
[[Category:Ansible]]

Latest revision as of 15:18, 9 August 2022

YAML

Serialization Language

Syntax

Key Value Pairs

  • "microservice" becomes an object with directives under it.
microservice:
  app: user-auth
  port: 9000
  #comment
  version: 1.7

Create a List

 microservice: #list name
  - app: user-auth #items of the list
    port: 9000
    #comment
    version: 1.7
    deployed: true #boolean value
  - app: shopping-cart
    port: 9002
    version:
      - 1.9
      - 2.0
      - 2.1
#can be written as 
     version: [1.9, 2.0, 2.1]

Multiline String

miltilineString: |
  this is a multiline string
  and this is the next line
  next line

Single line string, use the ">"

  • written on multiple lines, but will display as a single line
singleLineString: >
  this is a line
  another line
  yet another line, but it will be displayed on a single line because of the >