$ ansible --version
ansible 2.10.5
...
python version = 3.9.1 (default, Dec 13 2020, 11:55:53) [GCC 10.2.0]
用意した Playbook。
---
- hosts: localhost
tasks:
- name: Test
debug:
msg: 'hello'
no_log: "{{ foo }}"
# become: "{{ foo }}"
未定義の変数を no_log
に使用したときのエラーが少し分かり辛い。
意図してやっている可能性がある?
$ ansible-playbook no-log-error.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] ********************************************************************************************************************
TASK [Gathering Facts] **************************************************************************************************************
ok: [localhost]
TASK [Test] *************************************************************************************************************************
fatal: [localhost]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}
PLAY RECAP **************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
一方で例えば become に未定義の変数を使用した場合は、
$ ansible-playbook no-log-error.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [localhost] ********************************************************************************************************************
TASK [Gathering Facts] **************************************************************************************************************
ok: [localhost]
TASK [Test] *************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The field 'become' has an invalid value, which includes an undefined variable. The error was: 'foo' is undefined"}
PLAY RECAP **************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0