Changes

Jump to: navigation, search

Introduction to YAML

805 bytes added, 00:51, 25 November 2019
YAML File and Python
::: id: '98765432'
= Some examples: file written in YAML =
== Ansible playbooks YAML File and Python ==File name: students.yaml
<pre>
students:
id_number: 112001987
program: CNS
</pre>
The above file contains data equivalent to the following dictionary data object in Python:
<pre>
{'students': [{'id_number': '012345678', 'name': 'David', 'program': 'CTY'},
{'id_number': 112001987, 'name': 'Raymond', 'program': 'CNS'}]}
</pre>
 
== Ansible playbooks ==
File Name: get_os_version.yaml
<pre>
---
- hosts: all
remote_user: rchan
tasks:
- name: Print Linux distribution and version
debug:
msg: '{{ ansible_distribution }} {{ ansible_distribution_version }}'
</pre>
The file above contains data equivalent to the following data object in Python:
<pre>
[{'hosts': 'all', 'remote_user': 'rchan', 'tasks': [{'debug': {'msg': '{{ ansible_distribution }}
{{ ansible_distribution_version }}'}, 'name': 'Print Linux distribution and version'}]}]
</pre>
1,760
edits

Navigation menu