Junosデバイス管理時のAnsible収集およびモジュールエラーのトラブルシューティング
問題
形容
Ansible Playbook の実行中に、制御ノードは、 juniper.device コレクションが見つからなかった、タスクでアクションが検出されなかった、またはモジュールを解決できなかったというエラーを生成します。例えば:
ERROR! couldn't resolve module/action 'juniper.device.facts'. This often indicates a misspelling, missing collection, or incorrect module path.
又は
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
原因
Ansible制御ノードは、 juniper.device コレクションおよび関連モジュールを見つけることができません。
解決
juniper.deviceコレクションは、Ansible Galaxy の Web サイトでホストされています。コレクション内のモジュールを使用するには、コレクションを Ansible 制御ノードにインストールし、Playbook で参照する必要があります。
Ansible制御ノードに juniper.device コレクションをインストールするには、 ansible-galaxy collection install コマンドを実行し、 juniper.deviceを指定します。
user@ansible-cn:~$ ansible-galaxy collection install juniper.device
手記:
コレクションをデフォルトの場所にインストールしない場合は、Ansibleセットアップでそのパスを定義する必要があります。コレクションのインストールとパスの指定の詳細については、 公式の Ansible ドキュメントを参照してください。
juniper.device コレクション モジュールを使用するには、モジュールの実行時に完全修飾コレクション名を参照します。例えば:
---
- name: Get Device Facts
hosts: junos-all
connection: local
gather_facts: no
tasks:
- name: Get device facts
juniper.device.facts:
savedir: "{{ playbook_dir }}"