当 bin_ansible_callbacks 设置为 True 时,Ansible 仅输出所有失败信息

当 bin_ansible_callbacks 设置为 True 时,Ansible 仅输出所有失败信息

使用配置变量在 ansible 中运行 adhoc 命令bin_ansible_callbacks = False,在成功和失败的 ansible 输出ansible_factschangedrcstderrstderr_linesstdout和 上stdout_lines

hostname.example.com | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "rc": 0,
    "stderr": "",
    "stderr_lines": [],
    "stdout": "Info: Using environment 'development'\nInfo: Retrieving pluginfacts\nInfo: Retrieving plugin\nInfo: Retrieving locales\nInfo: Lodaing facts\nInfo: Caching catalog for hostname.example.com\nInfo: Applying configuration version '1660221776'\nNotice: Applied catalog in 12.29 seconds\n",
    "stdout_lines": [
        "Info: Using environment 'development'",
        "Info: Retrieving pluginfacts",
        "Info: Retrieving plugin",
        "Info: Retrieving locales",
        "Info: Loading facts",
        "Info: Caching catalog for hostname.example.com",
        "Info: Applying configuration version '1660221776'",
        "Notice: Applied catalog in 12.29 seconds"
    ]
}

当配置变量bin_ansible_callbacks = True, 出现故障时,ansible 具有类似的输出,采用 , 指定的格式stdout_callback,但stderr_linesstdout_lines被省略。

PLAY [Ansible Ad-Hoc]

TASK [puppet]
fatal: [hostname.example.com]: FAILED! => changed=false
  ansible_facts:
      discovered_interpreter_python: /usr/bin/python
  disabled: false
  error: true
  msg: puppet did not run
  rc: 1
  stderr: |-
      Error: Connection to https://puppet:8140/puppet-ca/v1 failed, trying next route: Request to https://puppet:8140/puppet-ca/v1 timed out connect operation after 120.001 seconds
      Wrapped exception:
      Error: No more routes to ca
      Error: Could not run: No more routes to ca
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

PLAY RECAP
hostname.example.com    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

但是,当配置变量bin_ansible_callbacks = True, 成功时,ansible 只会输出ok: [hostname]stdout_callback = yaml在本例中为 with )。

PLAY [Ansible Ad-Hoc]

TASK [puppet]
ok: [hostname.example.com]

PLAY RECAP
hostname.example.com    : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

是否可以使用临时命令在成功时输出所有这些字段bin_ansible_callbacks = True?是否可以在失败时保留stdout_lines而不被忽略?stderr_lines

我想要与我获得的信息相同的信息bin_ansible_callbacks = False,但具有提供的格式bin_ansible_callbacks = True(特别是stdout_callback = yamlset)。

相关内容