Skip to content

Latest commit

 

History

History
executable file
·
170 lines (150 loc) · 2.62 KB

markup-lang-cheat-sheet.md

File metadata and controls

executable file
·
170 lines (150 loc) · 2.62 KB

Yet Another Markup Language cheat sheet

indentation

2 spaces

data types

  • string
  • number
  • boolean
  • list
  • map
host: ger-43
datacenter:
location: Germany
cab: "13"
cab_unit: 3

# block-style
list_of_strings:
- one
- two
- three
# flow-style
another_list_of_strings: [one,two,three]

# block-style
map_example:
  - element_1: one
  - element_2: two
# flow-style
map_example2: {element_1: one , element_2: two }

more comples example - list of maps

credentials:
  - name: 'user1'
    password: 'pass1'
  - name: 'user2'
    password: 'pass2'

comment

# this is comment in yaml
user_name: cherkavi # comment after the value
user_password: "my#secret#password"

multiline

  • one line string ( removing new line marker )
comments: >
Attention, high I/O
since 2019-10-01.
Fix in progress.
  • each line of text - with new line marker ( new line preserving )
downtime_sch: |
2019-10-05 - kernel upgrade
2019-02-02 - security fix

multi documents

---
name: first document

---
name: second document

# not necessary marker ...
...
---
name: third document

place of metadata, header

# this is metadata storage place
---
name: first document

anchor, reference

& - anchor

    • reference to anchor simple reference
---
host: my_host_01
description: &AUTO_GENERATE standard host without specific roles
---
host: my_host_02
description: *AUTO_GENERATE

reference to map

users:
  - name: a1 &user_a1    # define anchor "user_a1"
    manager:
  - name: a2
    manager: *user_a1    # reference to anchor "user_a1"

example with collection

---
host: my_host_01
roles: &special_roles
  - ssh_server
  - apache_server
---
host: my_host_02
roles: *special_roles

another yaml example, anchor reference

base: &base
    name: Everyone has same name

foo: &foo
    <<: *base
    age: 10

bar: &bar
    <<: *base
    age: 20  

TAG

set data type for value

  • seq
  • map
  • str
  • int
  • float
  • null
  • binary
  • omap ( Ordered map )
  • set ( unordered set )
name: Vitalii
id_1: 475123 !!str
id_2: !!str 475123 

assign external URI to tag ( external reference )

should be defined inside metadata

%TAG ! tag:hostdata:de_muc
---
# reference id is: DE_MUC
location: !DE_MUC Cosimabad   

local tag ( reference inside document )

JSON

JSON Hyper-Schema keyword:

  • "$id"
  • "$ref"
  • "$dynamicRef"