bin_ansible_callbacksがTrueに設定されている場合、Ansibleはすべての障害情報のみを出力します。

bin_ansible_callbacksがTrueに設定されている場合、Ansibleはすべての障害情報のみを出力します。

構成変数を使用してansibleから一時コマンドを実行すると、成功およびbin_ansible_callbacks = False失敗時に、、、、、およびのansible出力が提供されます。ansible_factschangedrcstderrstderr_linesstdoutstdout_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_callbackstderr_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 = Trueansibleは変数を正常に設定した場合にのみ出力しますok: [hostname]stdout_callback = yamlこの場合)。

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 = Truestdout_lines無視されずに失敗を続行することは可能ですか?stderr_lines

私は私が得たのと同じ情報が欲しいbin_ansible_callbacks = Falseが、提供された形式bin_ansible_callbacks = True(具体的にstdout_callback = yaml設定された)が欲しい。

ベストアンサー1

おすすめ記事