Using advanced YAML syntax
As we mentioned throughout the first few chapters, Ansible relies heavily on YAML. As long as you keep creating more complex playbooks, you need to incorporate more complex variables, data structures, and arguments. Using advanced YAML syntax can help solve these complexities.
YAML multiline strings
In this recipe, you will learn how to use YAML multiline strings. The YAML documentation describes several different enumerations of handling multiline strings, but for Ansible, you will learn about literal and block formatting. The following are the steps involved:
Start by creating a new playbook called pb_yaml_multiline.yml. You will use the built-in debug method to output a text with more than one line. The | syntax is used for a literal block. A literal block will keep newline characters, and extra levels of indentation are also preserved:
root@cookbook-lab:~/cookbook-lab/chapters/ch03# vi pb_yaml_multiline.yml
---
- name:...