Ansible Failed Authentication

74 views
Skip to first unread message

VeGeTa-X

unread,
Feb 22, 2019, 4:56:07 PM2/22/19
to Ansible Project
I am starting out at ansible with a basic playbook to learn ansible I am getting the error message below I know the user and creds are correct I have logged into that switch from
ansible server can someone please let me know what I am missing?



#error message

TASK [Gathering Facts] ************************************************************************************************************************************************

fatal: [vegeta01_temp]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: \n****************************************************************************Permission denied (publickey,password,keyboard-interactive).", "unreachable": true}



---

 

- name: nxos_facts module

  hosts: vegeta_core

  vars:

    ssh:

      host: “{{ansible_host}”

      username: “{{vegeta}”

      password: “{{abc123}”

 

    nxapi:

      host: "{{ ansible_host }}"

      username: "{{ vegeta }}”

      password: "{{ abc123 }}"

      transport: nxapi

      use_ssl: no

      validate_certs: no

      port: 80 

 

 

  tasks:

    - name: nxos_facts ssh

      nxos_facts:

        provider: "{{ssh}}"

 

    - name: nxos_facts nxapi

      nxos_facts:

        provider: "{{ nxapi }}"   

Wawrzek Niewodniczanski

unread,
Feb 23, 2019, 8:58:52 AM2/23/19
to ansible...@googlegroups.com
On Fri, 22 Feb 2019 at 21:56, VeGeTa-X <almo...@gmail.com> wrote:
>
[...]
> please let me know what I am missing?

There might be something else, but these 3 lines look wrong, just one
"}" should be two.
> ssh:
> host: “{{ansible_host}”
> username: “{{vegeta}”
> password: “{{abc123}”

Also can you ssh to that server with the username you define as
variable "{{ vegeta }}".

Wawrzek



--
Dr Wawrzyniec Niewodniczański or Wawrzek for short
PhD in Quantum Chemistry & MSc in Molecular Engineering
WWW: http://wawrzek.name E-MAIL: jo...@wawrzek.name
Linux User #177124

VeGeTa-X

unread,
Feb 23, 2019, 6:11:45 PM2/23/19
to Ansible Project
ok fixed the username and password and I am still not able to login using the playbook

Also to answer your question yes I am able to login using vegeta with just plain ssh into switch 

VeGeTa-X

unread,
Feb 23, 2019, 6:19:37 PM2/23/19
to Ansible Project
also here is a copy are my settings of for ansible.cfg and version I am running

ansible 2.7.8

  config file = /etc/ansible/ansible.cfg

  configured module search path = ['/usr/share/ansible']

  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible

  executable location = /usr/local/bin/ansible

  python version = 3.6.8 (default, Feb 22 2019, 12:24:32) [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)]

[root@ansiblevm ansible]#

 

 

 

 

cat ansible.cfg | grep -v "#"

 

 

[defaults]

 

 

library        = /usr/share/ansible/

remote_tmp     = $HOME/.ansible/tmp

forks          = 5

 

 

timeout = 10

 

 

log_path = /var/log/ansible.log

 

 

[inventory]

 

 

[privilege_escalation]

 

[paramiko_connection]

 

[ssh_connection]

 

 

[persistent_connection]

 

 

[accelerate]

 

[selinux]

 

[colors]

[diff]

d...@linder.org

unread,
Feb 24, 2019, 2:22:49 PM2/24/19
to Ansible Project
On Saturday, February 23, 2019 at 5:11:45 PM UTC-6, VeGeTa-X wrote:
ok fixed the username and password and I am still not able to login using the playbook

Please provide the new error message you're getting.  Can you do a simple "ansible ping" (https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html#your-first-commands).

Dan

VeGeTa-X

unread,
Feb 25, 2019, 1:05:33 PM2/25/19
to Ansible Project
when I do a  ansible all -i inventory/inv_sjc_core -u vegeta -m ping -k it does not authenticate but if I do a "ssh -l vegeta vegeta01_temp" it works


vegeta01_temp | 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 Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.2506652-80180766644234 `\" && echo ansible-tmp-1551117540.2506652-80180766644234=\"` echo Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.2506652-80180766644234 `\" ), exited with result 16, stdout output: Syntax error while parsing '/bin/sh -c '( umask 77 && mkdir -p \"` echo Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.2506652-80180766644234 `\" && echo ansible-tmp-1551117540.2506652-80180766644234=\"` echo Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.2506652-80180766644234 `\" ) && sleep 0''\n\n\nCmd exec error.\n",

    "unreachable": true

}

vegeta02_temp | 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 Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.287293-48560425026336 `\" && echo ansible-tmp-1551117540.287293-48560425026336=\"` echo Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.287293-48560425026336 `\" ), exited with result 16, stdout output: Syntax error while parsing '/bin/sh -c '( umask 77 && mkdir -p \"` echo Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.287293-48560425026336 `\" && echo ansible-tmp-1551117540.287293-48560425026336=\"` echo Cmd exec error./.ansible/tmp/ansible-tmp-1551117540.287293-48560425026336 `\" ) && sleep 0''\n\n\nCmd exec error.\n",

    "unreachable": true

}

[root@ansiblevm ansible]#

VeGeTa-X

unread,
Feb 25, 2019, 1:31:32 PM2/25/19
to Ansible Project
ok fixed my issue I was missing "connection:local" in my playbook thx for your help

VeGeTa-X

unread,
Feb 25, 2019, 2:22:30 PM2/25/19
to Ansible Project

before my issue I was missing connection: local now I am able to run and I am getting message below I have doubled checked my username and password below is my .yaml syntax

TASK [show version] ***************************************************************************************************************************************************

fatal: [vegetacore01_temp]: FAILED! => {"msg": "Invalid/incorrect username/password. Private key file is encrypted"}

fatal: [vegetacore02_temp]: FAILED! => {"msg": "Invalid/incorrect username/password. Private key file is encrypted"}

 

---

- name: INE_NXOS

  hosts: sjc_core

  connection: local

 

 

  vars:

    cli:

      host: "{{ inventory_hostname }}"

      username: vegeta

      password: abc123

      transport: cli

 

  tasks:

    - name: show version

      nxos_command:

        commands: show version

        provivder: "{{ cli }}"

Reply all
Reply to author
Forward
0 new messages