Ansible を使用する Telnet-Cisco スイッチが正しく動作しません。

Ansible を使用する Telnet-Cisco スイッチが正しく動作しません。

私の研究室にはciscoスイッチがあり、最初はTelnet接続で構成されていたので、これをAnsibleの初期設定(SSHアクセス、ホスト名、ドメインなど)に使用したいと思いました。

このモジュールを使用しようとしています。 https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/telnet_module.html#parameters

これは現在スクリプトですが、期待どおりに機能しません。

- name: Initial access with Telnet
  connection: local
  gather_facts: false
  hosts: wired
  tasks:
  - name: set SSH with telnet connection # Configure SSH access to the netowrk devices
    ansible.netcommon.telnet:
      port: 14038
      password: "mainpass"
      send_newline: yes
      prompts:
      - '[>]'
      commands:
      - enable

このプレイブックを実行すると、CLIには何も表示されず、終了するまで次のように保持されます。

sumaia@main-srv:~/ansible$ ansible-playbook init.yaml

PLAY [Initial access with Telnet] ***********************************************************************************************************************************************************************************************

TASK [set SSH with telnet connection] *******************************************************************************************************************************************************************************************
^C [ERROR]: User interrupted execution
sumaia@main-srv:~/ansible$

Puttyを使用してTelnetアクセスを確認しましたが、うまくいきました。

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
To log in to this device, use the following password/credentials:

enable password mainpass
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


9300>en
Password:
9300#

Telnet セッションを開始するときは、Enter キーを押してからパスワード入力を有効にする必要があります。これがプレイブックにどのように反映されるかはよくわかりません。

ベストアンサー1

スイッチはMOTDバナーを表示する前にキャリッジリターンを待つので、ansibleが探しているプロンプトを送信しません。この問題を解決するために私が見つけた唯一の方法は、 send_carriage_return パラメータを ansible.netcommon.telnet モジュールの四半期バージョンです。

おすすめ記事