Unable to manage AVOCENT CONSOLE servers over Ansible

Hello ,

root@ubuntu-16-04-4-server-amd64:/# ansible --version
ansible 2.8.5
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.12 (default, Oct 8 2019, 14:14:10) [GCC 5.4.0 20160609]

I wanted to manage Avocent Console servers using ansible play books but i am not able to ping to Avocent Console Server hosts from Ansible Controller, please see the error output mentioned below.

root@ubuntu-16-04-4-server-amd64:/# ansible -m ping all
10.219.14.74 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,keyboard-interactive).”,
“unreachable”: true
}
[DEPRECATION WARNING]: Distribution Ubuntu 16.04 on host 10.219.83.180 should use /usr/bin/python3, but is using /usr/bin/python for backward compatibility with prior
Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See
https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
10.219.83.180 | SUCCESS => {
“ansible_facts”: {
“discovered_interpreter_python”: “/usr/bin/python”
},
“changed”: false,
“ping”: “pong”
}

10.219.13.72 | UNREACHABLE! => {
“changed”: false,
“msg”: “Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp". Failed command was: ( umask 77 && mkdir -p "echo /bin/sh: -c: line 1: syntax error: unexpected end of file/.ansible/tmp/ansible-tmp-1571343763.29-193564225595742" && echo ansible-tmp-1571343763.29-193564225595742="echo /bin/sh: -c: line 1: syntax error: unexpected end of file/.ansible/tmp/ansible-tmp-1571343763.29-193564225595742" ), exited with result 1, stdout output: /bin/bash: -c: line 0: syntax error near unexpected token ('\r\n/bin/bash: -c: line 0: /bin/sh -c ( umask 77 && mkdir -p "echo /bin/sh: -c: line 1: syntax error: unexpected end of file/.ansible/tmp/ansible-tmp-1571343763.29-193564225595742" && echo ansible-tmp-1571343763.29-193564225595742%3’\r\n”,
“unreachable”: true

in the above output 10.219.13.72 and 10.219.14.74 ip’s are belongs to Avocent Console Servers and the one which is successful is my Ubuntu VM.
any help in resolving the issue is highly appreciable.

Thanks a lot in Advance

Ansible need a proper shell and Python on the remote node to work, I doubt Avocent Console has that.

If it has a proper shell the raw module might work, if not your only choice is the expect module.

Hi Kai Stian Olstad.

Thanks for the revert, when i tried expect module in play book i am seeing below error

root@ubuntu-16-04-4-server-amd64:/etc/ansible# ansible-playbook consoleservers.yml
ERROR! conflicting action statements: command, expect

The error appears to be in ‘/etc/ansible/consoleservers.yml’: line 4, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:

  • name: Reboot
    ^ here

if i comment expect in playbook then playbook runs well but still host is uneachable, please see below output

root@ubuntu-16-04-4-server-amd64:/etc/ansible# ansible-playbook consoleservers.y ml

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [10.219.14.74]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to conn ect to the host via ssh: Permission denied (publickey,keyboard-interactive).”, " unreachable": true}

PLAY RECAP *********************************************************************
10.219.14.74 : ok=0 changed=0 unreachable=1 failed=0 s kipped=0 rescued=0 ignored=0

below is the playbook i am trying, the agenda of playbook is to reboot the console server. i have used expect module in two different places but no luck, could you please suggest.
i am very new to ansible.

  • hosts: all
    #expect:
    tasks:
  • name: Reboot

expect:

command: reboot
#responses:
#(?i)password: “linux”
#no_log: true

Think of expect as your automated human, so your command is actually the ssh command the user would type.
And this must run on localhost host, with conneection: local or delegate_to: localhost.

- name: reboot
   expect:
     command: ssh <something>
     responses:
       <text to wait for>: <the respose to type in>