YAML

/ˈjæməl/, 专门用于写配置文件

YAML is easier for humans to read and write than other common data formats like XML

key/value pairs
https://docs.ansible.com/ansi...

List

All members of a list are lines beginning at the same indentation level starting with a "- " (a dash and a space):

# A list of tasty fruits
fruits:
  - Apple
  - Orange
  - Strawberry
  - Mango

或者

fruits: ['Apple', 'Orange', 'Strawberry', 'Mango']

Dictionary

A dictionary is represented in a simple key: value form (the colon must be followed by a space):

# An employee record
martin:
    name: Martin D'vloper
    job: Developer
    skill: Elite

或者

martin: {name: Martin D'vloper, job: Developer, skill: Elite}

Boolean

likes_emacs: true
uses_cvs: false

Multiple Lines

Values can span multiple lines using | or >. Spanning multiple lines using a | will include the newlines. Using a > will ignore newlines; it’s used to make what would otherwise be a very long line easier to read and edit. In either case the indentation will be ignored. Examples are:

include_newlines: |
            exactly as you see
            will appear these three
            lines of poetry

ignore_newlines: >
            this is really a
            single line of text
            despite appearances

引号

foo: "somebody said I should put a colon here: so I did"
windows_drive: "c:"

黄挤挤
73 声望2 粉丝

« 上一篇
Shell编程
下一篇 »
Linux Tips