Ansible 2.7多行ansible_managed

时间:2018-10-23 12:41:20

标签: ansible ansible-2.x

Python3

Ansible 2.7

有人在ansible.cfg中有多行// get value of input from form (email or username in the same input) $email_or_username = $request->input('email_or_username'); // check if $email_or_username is an email if(filter_var($email_or_username, FILTER_VALIDATE_EMAIL)) { // user sent his email // check if user email exists in database $user_email = User::where('email', '=', $request->input('email_or_username'))->first(); if ($user_email) { // email exists in database if (Auth::attempt(['email' => $email_or_username, 'password' => $request->input('password')])) { // success } else { // error password } } else { // error: user not found } } else { // user sent his username // check if username exists in database $username = User::where('name', '=', $request->input('email_or_username'))->first(); if ($username) { // username exists in database if (Auth::attempt(['name' => $email_or_username, 'password' => $request->input('password')])) { // success } else { // error password } } else { // error: user not found } } 行的示例吗?

在ansible的过去,我能够做到...

ansible_managed

现在它必须已修复,因为它在第二行之后会中断。

1 个答案:

答案 0 :(得分:2)

我可以带您到达那里的大部分地方(如果您不受#的束缚,则可以一直到达您):

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'
+++++++++++++++++++++++++++++

#字符需要加引号。

  

除了'和'以外,还有许多特殊字符(或保留字符),不能用作无引号标量的第一个字符:[] {}> | *&!%#`@,。

在您的示例中,该方法本来可以正常工作,但无论进行什么更改都不可能。您可以在每个包含#的行周围加上引号,但会将其添加到输出中。

例如:

"###########################"
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