Slide 1

Slide 1 text

YAML: ain’t: markup: - language @KeithResar

Slide 2

Slide 2 text

An: unfortunate: series: of: - indents @KeithResar

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

@KeithResar

Slide 5

Slide 5 text

@KeithResar

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

@KeithResar ANSIBLE YAML --- - hosts: localhost tasks: - debug: msg: "Hello World"

Slide 9

Slide 9 text

@KeithResar KUBERNETES YAML --- apiVersion: v1 kind: Pod metadata: ... spec: ... status: ...

Slide 10

Slide 10 text

@KeithResar CALENZEN YAML --- name: Zoom US Level 1 (2018-09-05) level: 1 priority: 102 driver: RegexV1 key_type: ... detect_regex: … output: ...

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

@KeithResar RFC 822 From: [email protected] To: [email protected], ∙ ∙ ∙ "[email protected]" Unstructured Text Key/Value pairs Multi-line folding CRLF followed by LWSP character Delimiting and Quoting Optional, not part of string, c-style escape sequences

Slide 14

Slide 14 text

@KeithResar OTHER PRIOR ART ● Indentation-based scoping from Python ● End of line normalization from HTML ● Collections & scalar data types from Perl, Python, Ruby ● Incremental interfaces and streaming one-pass interfaces supports large documents

Slide 15

Slide 15 text

@KeithResar COMPARING YAML WITH JSON ● Simplicity & universality ● Lowest common denominator ● Trivial to generate and parse JSON ● Human readability ● Arbitrary native data structures ● Complex processing across environments YAML

Slide 16

Slide 16 text

@KeithResar YAML ⊇ JSON JSON's RFC4627 requires that mappings keys merely “SHOULD” be unique, while YAML insists they “MUST” be. Technically, YAML therefore complies with the JSON spec, choosing to treat duplicates as an error. In practice, since JSON is silent on the semantics of such duplicates, the only portable JSON files are those with unique keys, which are therefore valid YAML files.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

@KeithResar QUOTING --- plain: look ma no quotes, but the most limited single_quotes: - 'keith''s single quotes' - 'bare \ is ok' double_quotes: - "only flow that can express arbitrary strings" - "\\ escape sequences, but must quote \" and \\"

Slide 20

Slide 20 text

@KeithResar BLOCKS --- # literal style - a: | multi-line ∙ ∙ ∙ text block # folded style - b: > multi-line ∙ ∙ ∙ text block Becomes: multi-line Text block Becomes: Multi-line text block

Slide 21

Slide 21 text

@KeithResar BLOCK CHOMPING --- # clip (default) - includes final line break - a: | text # strip - excludes final line break & trailing empty lines - a: |- text # keep - includes all trailing line breaks - a: |+ text

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

@KeithResar DIRECTIVES --- --- ... Start of Stream Separate directives from content End of Document Used for streaming comm channels

Slide 25

Slide 25 text

@KeithResar TAGS IN _FAILSAFE_ SCHEMA --- - just a string - true - a: 1 b: 2 - - a - b

Slide 26

Slide 26 text

@KeithResar TAGS IN _FAILSAFE_ SCHEMA --- - !!str just a string - !!str true - !!map a: 1 b: 2 - !!seq - a - b

Slide 27

Slide 27 text

@KeithResar TAGS IN _JSON_ SCHEMA --- - just a string - true - a: 1 b: 2 - - a - b

Slide 28

Slide 28 text

@KeithResar TAGS IN _CUSTOM_ SCHEMA %TAG !foo! tag:example.com,2002: --- invoice1: !foo!invoice ... invoice2: ! ...

Slide 29

Slide 29 text

@KeithResar

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

@KeithResar

Slide 33

Slide 33 text

@KeithResar LINTING ● YMMV re: quality - check web and python ● yamllint ● ansible-lint

Slide 34

Slide 34 text

@KeithResar EDITORS ● vim ● Atom ● Eclipse ● Visual Studio Code

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

@KeithResar GO FARTHER WITH THESE _RESOURCES_ YAML Ain’t Markup Language (YAML™) Version 1.2 Spec https://yaml.org/spec/1.2/spec.html Ansible Lint Documentation https://docs.ansible.com/ansible-lint/

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

THANKS @KeithResar