Current situation:
I can ssh to SwitchA with ssh client.
With the same playbook, it can ssh to the SwitchA by cronjob, but I can't execute the playbook manually and got the below error message.
How can I solve this issue and make it successful in executing this playbook manually?
ansible-playbook -i SwitchA.yml playbook.yml
Ansible debugging
<172.26.192.229> connection transport is cli
<172.26.192.229> using connection plugin network_cli (was local)
<172.26.192.229> starting connection from persistent connection plugin
<172.26.192.229> local domain socket does not exist, starting it
<172.26.192.229> control socket path is /home/xxxx/.ansible/pc/67b0b2e86d
<172.26.192.229> loaded cliconf plugin for network_os ce
<172.26.192.229>
The full traceback is:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/ansible/plugins/connection/paramiko_ssh.py", line 352, in _connect_uncached
**ssh_connect_kwargs
File "/usr/local/lib/python3.6/site-packages/paramiko/client.py", line 412, in connect
server_key = t.get_remote_server_key()
File "/usr/local/lib/python3.6/site-packages/paramiko/transport.py", line 834, in get_remote_server_key
raise SSHException("No existing session")
paramiko.ssh_exception.SSHException: No existing session
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/ansible-connection", line 104, in start
self.connection._connect()
File "/usr/local/lib/python3.6/site-packages/ansible/plugins/connection/network_cli.py", line 327, in _connect
ssh = self.paramiko_conn._connect()
File "/usr/local/lib/python3.6/site-packages/ansible/plugins/connection/paramiko_ssh.py", line 245, in _connect
self.ssh = SSH_CONNECTION_CACHE[cache_key] = self._connect_uncached()
File "/usr/local/lib/python3.6/site-packages/ansible/plugins/connection/paramiko_ssh.py", line 368, in _connect_uncached
raise AnsibleConnectionFailure(msg)
ansible.errors.AnsibleConnectionFailure: No existing session
fatal: [SwitchA]: FAILED! => {
"msg": "No existing session"
}
I found there a difference
Cronjob
"ansible_playbook_python": "/usr/bin/python2",
"ansible_python_interpreter": "python3",
"ansible_version": {
"full": "2.9.27",
"major": 2,
"minor": 9,
"revision": 27,
"string": "2.9.27"
}
Manual Execution
"ansible_python_interpreter": "python3",
"ansible_version": {
"full": "2.8.1",
"major": 2,
"minor": 8,
"revision": 1,
"string": "2.8.1"
}
My Playbook
connection: local
serial: 30
gather_facts: no
vars:
cli:
host: "{{ ansible_host }}"
port: 22
username: "{{ username }}"
password: "{{ password }}"
transport: cli
- name: "Testing"
ce_command:
commands: "{{ command_list }}"
provider: "{{ cli }}"
timeout: 900
register: MyResult
SwitchA debug:
SSH/7/RECV_PKT:Received ssh2 msg kex init packet.
SSH/7/KEX_DERECTION:Kex for direction is in.
SSH/7/CHOOSE_ENCRYPT:Chose encryption algorithm:aes128-ctr.
SSH/7/CHOOSE_MAC:Chose MAC algorithm:hmac-sha2-256.
SSH/7/KEX_DERECTION:Kex for direction is out.
SSH/7/CHOOSE_ENCRYPT:Chose encryption algorithm:aes128-ctr.
SSH/7/CHOOSE_MAC:Chose MAC algorithm:hmac-sha2-256.
SSH/7/CHOOSE_KEX:Choose Kex algorithm:diffie-hellman-group16-sha512.
SSH/7/KEX_UNSUPPORT:Unsupported Kex algorithm:ecdsa-sha2-nistp256!
SSH/7/FSM_MOVE:FSM moved from SSH_Sub1_KEX_Init to SSH_Sub1_KEX_GRP_Init.
SSH/7/RECV_PKT:Received ssh2 msg kexdh init packet.
SSH/7/FSM_MOVE:FSM moved from SSH_Sub1_KEX_GRP_Init to SSH_Sub1_KEX_GRP_Reply.
SSH/7/no_info:Begin to compute the dh shared key.
SSH/7/no_info:The line phylink is null. ulLineIndex = 6
SSH/7/no_info:Fail to inform to dh key result. ulRet = 0x1