YAML

1. Basic YAML Syntax 

 - YAML is composed of key-value pairs, lists, and dictionaries 
 - Files open withthree hyphens on the first line and close with three periods 
- List items are designed with a single hyphen and space 
 - Each list item should have the same indertation Dictioneries are designated with a colon and a space followed by idented key-value pairs 


  2. Multiline Line Values 
- It is frequently useful when working on Ansible playbooks to format input with line breaks 
 - YAML has a means of letting us do this 
 - The pipe and right angle bracket (| and >) may be used to allow for line breaks within YAML 
 - Pipe will take each line break as part of the input in the data that follows it 
 - The right-angle bracket will ignore line breaks in the dbilityata that follows it 
 - A typical use case is breaking up parametr for readability 

 Example 

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

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

 3.Quotes and When to Use Them 
-YAML has a relatively small set of special characters: [] {} : > |
- You must use double quotes to escape a special character
- Technically, you  only need to escape a colon if it is followed by a space
- You will frequently need to escape curly braces () as they are special to both YAML and Ansible:
- Boolean values auto-convert in YAML
- If you want a literal "Yes" , you must use quotes
- Floating Point Numbers are taken as numeric unless quoted


 4.

Komentarze

Popularne posty z tego bloga

Kubernetes

Helm

Ansible Tower / AWX