Junosデバイス管理時のAnsibleコレクション、役割、およびモジュールのエラーのトラブルシューティング
問題
説明
Ansibleプレイブックの実行中に、制御ノードは、コレクションまたはロールが juniper.device
見つからなかった、タスクでアクションが検出されなかった、または Juniper.junos
モジュールを解決できなかったというエラーを生成します。例えば:
ERROR! the role 'Juniper.junos' was not found in /usr/share/ansible/roles:/etc/ansible/roles ...
または
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
または
ERROR! couldn't resolve module/action 'facts'. This often indicates a misspelling, missing collection, or incorrect module path.
原因
Ansible制御ノードは、 juniper.device
コレクションまたは Juniper.junos
役割と関連モジュールを見つけることができません。
ソリューション
コレクションとJuniper.junos
ロールはjuniper.device
、Ansible Galaxy の Web サイトでホストされています。コレクションまたはロールのモジュールを使用するには、コレクションまたはロールを Ansible 制御ノードにインストールし、プレイブックで参照する必要があります。
Ansible制御ノードにコレクションをインストールするjuniper.device
には、 コマンドを実行しjuniper.device
、ansible-galaxy collection install
.
user@ansible-cn:~$ sudo ansible-galaxy collection install juniper.device
Ansible制御ノードにロールをインストールするJuniper.junos
には、 コマンドを実行しJuniper.junos
、ansible-galaxy install
.
user@ansible-cn:~$ sudo ansible-galaxy install Juniper.junos
コレクションまたはロールを既定の場所にインストールしない場合は、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 }}"
ロール モジュールを使用するには Juniper.junos
、プレイブック プレイにロールを含める必要があります。例えば:
--- - name: Get Device Facts hosts: junos-all connection: local gather_facts: no roles: - Juniper.junos tasks: - name: Get device facts juniper_junos_facts: savedir: "{{ playbook_dir }}"