Ansible 2.7 多行 ansible_managed
Ansible 2.7 Multi Line ansible_managed
Python3
Ansible 2.7
有人在 ansible.cfg 中有多行 ansible_managed
行的示例吗?
在过去的 ansible 时代,我能够做到...
ansible_managed = "#############################
Dev Team Back Again
By: {uid} on {host}
Using template: {file}
#############################"
现在肯定已经修复了,因为它在第二行之后就被截断了。
我可以带你走完大部分路(如果你不受 #
的束缚,我可以一路带你):
ansible_managed =
+++++++++++++++++++++++++++++
Dev Team Back Again
By: {uid} on {host}
Using template: {file}
+++++++++++++++++++++++++++++
会给你输出:
+++++++++++++++++++++++++++++
Dev Team Back Again
By: redacted_user on redacted_host
Using template: b'/Users/redacted_user/./template.yml'
+++++++++++++++++++++++++++++
#
字符需要加引号。
In addition to ' and " there are a number of characters that are special (or reserved) and cannot be used as the first character of an unquoted scalar: [] {} > | * & ! % # ` @ ,.
在您的示例中,这本来可以正常工作,但无论进行何种更改,都不可能。您可以在包含 #
的每一行周围加上引号,但它会将它们添加到输出中。
例如:
"###########################"
Dev Team Back Again
By: redacted_user on redacted_host
Using template: b'/Users/redacted_user/./template.yml'
"###########################"
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
Python3
Ansible 2.7
有人在 ansible.cfg 中有多行 ansible_managed
行的示例吗?
在过去的 ansible 时代,我能够做到...
ansible_managed = "#############################
Dev Team Back Again
By: {uid} on {host}
Using template: {file}
#############################"
现在肯定已经修复了,因为它在第二行之后就被截断了。
我可以带你走完大部分路(如果你不受 #
的束缚,我可以一路带你):
ansible_managed =
+++++++++++++++++++++++++++++
Dev Team Back Again
By: {uid} on {host}
Using template: {file}
+++++++++++++++++++++++++++++
会给你输出:
+++++++++++++++++++++++++++++
Dev Team Back Again
By: redacted_user on redacted_host
Using template: b'/Users/redacted_user/./template.yml'
+++++++++++++++++++++++++++++
#
字符需要加引号。
In addition to ' and " there are a number of characters that are special (or reserved) and cannot be used as the first character of an unquoted scalar: [] {} > | * & ! % # ` @ ,.
在您的示例中,这本来可以正常工作,但无论进行何种更改,都不可能。您可以在包含 #
的每一行周围加上引号,但它会将它们添加到输出中。
例如:
"###########################"
Dev Team Back Again
By: redacted_user on redacted_host
Using template: b'/Users/redacted_user/./template.yml'
"###########################"
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html