You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although it's probably ill-advised, connecting to a remote node with password authentication is still a valid use-case for Ansible. However, after much experimenting it seems clear that docker-ansible does not support password authentication out of the box.
These should be the minimum steps to reproduce:
Create a new inventory file containing a single host that allows SSH password authentication.
Run a simple ping test using ansible:latest-tools (should apply to any version really).
$ docker run --rm -it \
-e USER=ansible \
-v $(pwd):/data \
cytopia/ansible:latest-tools ansible all --ask-pass -i temp-inventory -m ping
Enter the remote user's password when prompted.
[INFO] Running container with user 'ansible'
[INFO] Adjusting local user with uid:1000 and gid:1000
[INFO] Adjusting ownership on directory: ~/.gnupg/
[INFO] Adjusting ownership on directory: ~/.ssh/
[INFO] ansible> ansible all --ask-pass -i temp-inventory -m ping
SSH password:
The result will be a failure with this message:
127.0.0.1 | FAILED! => {
"msg": "to use the 'ssh' connection type with passwords or pkcs11_provider, you must install the sshpass program"
}
Running the following commands demonstrates that adding the sshpass package should be all that is needed to provide password authentication:
$ docker run --rm -it \
-v (pwd):/data \
--net=host \
cytopia/ansible:latest-tools sh
[INFO] root> sh
/data # apk add sshpass
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
(1/1) Installing sshpass (1.06-r0)
Executing busybox-1.32.1-r7.trigger
OK: 111 MiB in 86 packages
/data # ANSIBLE_HOST_KEY_CHECKING=False ansible all --ask-pass -i temp-inventory -m ping
SSH password:
[WARNING]: Platform linux on host 127.0.0.1 is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another Python interpreter could
change the meaning of that path. See https://docs.ansible.com/ansible-core/2.12/reference_appendices/interpreter_discovery.html for more information.
127.0.0.1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3.9"
},
"changed": false,
"ping": "pong"
}
The text was updated successfully, but these errors were encountered:
Although it's probably ill-advised, connecting to a remote node with password authentication is still a valid use-case for Ansible. However, after much experimenting it seems clear that
docker-ansible
does not support password authentication out of the box.These should be the minimum steps to reproduce:
ansible:latest-tools
(should apply to any version really).The result will be a failure with this message:
Running the following commands demonstrates that adding the
sshpass
package should be all that is needed to provide password authentication:The text was updated successfully, but these errors were encountered: