我想用多行字符串定义一个数组。
我尝试了这种方法,并且有效
vars:
multi_line_strings_array: ["Hello\nWorld\n", "This\nis really\ngreat", "that\nit works"]
它适用于小的多行字符串,但是如果字符串变大,则会出现可读性问题。
有没有更好的方法来定义多行字符串数组,以使可读性不是问题。
答案 0 :(得分:0)
您可以定义多行变量,如下所示-https://adminswerk.de/multi-line-string-yaml-ansible-I/
---
- hosts: localhost
connection: local
vars:
my_pattern: |
With his own sword,
Which he did wave against my throat, I have ta’en
His head from him.
tasks:
- debug:
var: my_pattern