Problem with Ansible on Network Automation appliance

I added Network Automation appliance to GNS3 so I can practice automation on Cisco routers

I configured everything properly but when I try to execute command

ansible myhosts -m ping -i inventory.ini

I get this:

192.168.1.1 | UNREACHABLE! => {

"changed": false,

"msg": "Failed to connect to the host via ssh: root@192.168.1.1: Permission denied (keyboard-interactive,password).",

"unreachable": true

}

I tried with command ansible myhosts -m ping -i inventory.ini --ask-pass

But then I get this :

192.168.1.1 | FAILED! => {

"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"

Of course I tried to install sshpass but I cannot, showing me this output

Reading package lists… Done

Building dependency tree

Reading state information… Done

Package sshpass is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source

E: Package ‘sshpass’ has no installation candidate

Does anyone knows a solution for this ?? I tried everything, last two days I am checking on Google and YouTube but haven’t found a solution for this.

Thank you!

Hi Skyglider,

I don’t have a GNS3 environment to test the appliance but did you do an “apt-get update” prior to attempting to install sshpass?

HI Joe, yes of course I I did “apt-get update” but that didn’t help

The sshpass package is available on Debian and Ubuntu,
what Linux distro are you running — what is a “GNS3 environment” based on? What do you have in /etc/apt/sources.list and what is in any files in /etc/apt/sources.list.d/?

Hi Chris ,

This is what I have in the output cat /etc/apt/sources.list

I need to share via online notepad link because I cannot post it here , system isn’t allowing me.

And this is what I have in the directory /etc/apt/sources.list.d/

root@NetworkAutomation-1:/etc/apt/sources.list.d# ls
ansible-ubuntu-ansible-focal.list ansible-ubuntu-ansible-focal.list.save

That’s very odd, unless the /etc/apt/sources.list.d/ansible-ubuntu-ansible-focal.list is the cause of the issue (what does it contain?) this line in your /etc/apt/sources.list:

deb http://archive.ubuntu.com/ubuntu/ focal universe

Should enable sshpass to be installed as the package is in universe for focal.

Perhaps try moving the /etc/apt/sources.list somewhere and replace the file with something like this:

deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu focal partner
deb [arch=amd64] https://apt.releases.hashicorp.com focal main

And then try:

apt-get update
apt-get install sshpass

Chris I tried what you proposed, I moved /etc/apt/sources.list to another directory and I created new file with the same name and added your links but that didn’t help , still is same

root@NetworkAutomation-1:~# apt-get install sshpass
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package sshpass is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘sshpass’ has no installation candidate

ansible-ubuntu-ansible-focal.list contains this:

root@NetworkAutomation-1:/etc/apt/sources.list.d# cat ansible-ubuntu-ansible-focal.list
deb Index of /ansible/ansible/ubuntu focal main
#deb-src Index of /ansible/ansible/ubuntu focal main

Are you able to update or install any packages?

Sorry I don’t know why apt isn’t working for you, perhaps directly down the package and install it, all the different versions are in this directory, for focal you want version 1.06-1:

wget https://archive.ubuntu.com/ubuntu/pool/universe/s/sshpass/sshpass_1.06-1_amd64.deb
dpkg -i sshpass_1.06-1_amd64.deb

No , I am not able to install any packages. Not sure what is the problem, I wasted a lot of time on this and I need to practice Ansible automation in networking. Thanks for your help. Do you know what is the best way to transfer the package sshpass_1.06-1_amd64.deb to the Appliance ?

If you can connect to the Internet download the package with wget or another CLI HTTP client, if it can’t connect to any external services you but you have SSH access to it you could scp the file onto the server?

I can connect it to the internet but wget is not working and I cannot install it. Also it wont allow me to ssh it because I need to install openssh-server and I cannot, wont allow me to install. So I am in some loop now with this. Have no idea what to do.