はじめに
以下の例のように、Playbook 内に無効な属性が指定されいる場合のデフォルトの挙動が Ansible 2.7 で変更されました。
- hosts: localhost gather_facts: no tasks: - name: invalid attribute test debug: msg: test xxxxx: yyyy # invalid attribute
Ansible 2.6 までは WARNING で処理継続
2.6 までは、以下のような WARNING メッセージが表示されました。 Playbook 自体の処理は継続されます。
$ ansible-playbook -i localhost, attr.yml
[WARNING]: Ignoring invalid attribute: xxxxxxxxxx
PLAY [localhost] ***********************************************************
TASK [invalid attribute test] **********************************************
ok: [localhost] => {
"msg": "test"
}
PLAY RECAP *****************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
Ansible 2.7 では ERROR で実行不可に
2.7 では、デフォルトで以下のような ERROR メッセージが表示され、Playbook が実行されません。
$ ansible-playbook -i localhost, attr.yml
ERROR! 'xxxxxxxxxx' is not a valid attribute for a Task
The error appears to have been in '/vagrant/a27/attr.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
- name: invalid attribute test
^ here
This error can be suppressed as a warning using the "invalid_task_attribute_failed" configuration
この動作は、Ansible 2.7 で追加された、無効なタスク属性の扱いを決める INVALID_TASK_ATTRIBUTE_FAILE という設定項目で変更できます。
True: ERROR として扱い、Playbookを実行しない(デフォルト)False: WARNING として扱い、Playbookの実行を継続する
設定の変更は以下のようにできます。
- ansible.cfg で
Falseにする場合
[defaults] invalid_task_attribute_failed=False
- 環境変数で
Falseにする場合
export ANSIBLE_INVALID_TASK_ATTRIBUTE_FAILED=False