What Is YAML?

Jan 15 · 4 min read
Image for post
Image for post



Features of YAML

How YAML Works

integer: 25 
string: "25"
float: 25.0
boolean: Yes
--- # Shopping List in Block Format 
- milk
- eggs
- juice
--- # Shopping List in Inline Format [milk, eggs, juice]
data: |
Each of these
Will be broken up
data: >
This text is
wrapped and will
be formed into
a single paragraph


"json": [
"better for data interchange"
"yaml": [
"slim and flexible",
"better for configuration"
"object": {
"key": "value",
"array": [
"null_value": null
"boolean": true
"integer": 1
"paragraph": "Blank lines denotenparagraph breaksn",
"content": "Or wencan autonconvert line breaksnto save space"
# <- yaml supports comments, json does not # did you know you can embed json in yaml? # try uncommenting the next line # { foo: 'bar' } json: - rigid - better for data interchange yaml: - slim and flexible - better for configuration object: key: value array: - null_value: - boolean: true - integer: 1 paragraph: >
Blank lines denote

paragraph breaks
content: |-
Or we
can auto
convert line breaks
to save space

Examples of YAML

- hosts: webservers

http_port: 80
max_clients: 200

remote_user: root

- name: ensure apache is at the latest version
name: httpd
state: latest

- name: write the apache config file
src: /srv/httpd.j2
dest: /etc/httpd.conf
- restart apache

- name: ensure apache is running
name: httpd
state: started

- name: restart apache
name: httpd
state: restarted
ansible-playbook -i hosts/groups verify_apache.yml

Key Takeaways

The Startup

Medium's largest active publication, followed by +771K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store