こんにちは、LinuCエバンジェリストこと、鯨井貴博@opensourcetechです。
今回は Ansibleで Playbookを実行した時に、
"command timeout triggered, timeout value is 10 secs."と表示され FAILEDとなった時への対応方法を紹介します。
事象内容
以下は、JuniperのJunosに対してPlaybookで設定を投入しているものですが、
実施時に以下のように実行失敗(FAILED)となっています。
XYZ:ansible_test Xjapan$ ansible-playbook -i inventory5 junos_test11.yaml
PLAY [junos] *******************************************************************
TASK [delete services] *********************************************************
fatal: [192.168.111.1]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 10 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}
PLAY RECAP *********************************************************************
192.168.111.1 : ok=0 changed=0 unreachable=0 failed=1
発生する状況としては、以下のように設定の反映に10秒以上の時間を要するなどのケースとなります。
以下では、Junosの設定ファイルへ追加設定を反映させる commitコマンドに13秒程度かかっています。
事象の原因
原因は、コマンドを実行した際にデバイスからのレスポンスを待つタイムアウト値があるのですが、それがデフォルトで10秒に設定されていることにあります。
Ansible Configuration Settings — Ansible Documentation
事象への対応方法
ansible.cfgに以下の設定を追加します。
command_timeout = 30
その他、
以下にあるパラメータのtimeoutをPlaybookに書くなどすれば対応できそうです。
※未検証
junos_config - Manage configuration on devices running Juniper JUNOS — Ansible Documentation
Example: Using Ansible to Configure Devices - TechLibrary - Juniper Networks