if i apply ping module using ansible i am getting below error:-
“changed”: false,
“msg”: “Failed to create temporary directory.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", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo ~/.ansible/tmp"&& mkdir "echo ~/.ansible/tmp/ansible-tmp-1624045005.71-29459-71519195524962" && echo ansible-tmp-1624045005.71-29459-71519195524962="echo ~/.ansible/tmp/ansible-tmp-1624045005.71-29459-71519195524962" ), exited with result 1”,
“unreachable”: true
}
the method that i followed to overcome this (but not able to):-
i had created the .ansible/tmp directory and given 777 permission (not worked)
2.given 777 permission to default directory of remote(not worked)
3.changing the remote_tmp path in ansible.cfg file(not worked)
4.changing log file path which also has 777 permission in ansible.cfg(not worked)
5.prmitted root login from sshd
please help me to over come this problem.
my controller node is of centos7 and remote is debian
Hi experts,
I am unable to ping to my remote servers via ansible.
Do other ansible commands on the same target machine work okay?
"msg": "Failed to create temporary directory.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\", for more error information use -vvv.
What's the definition of your tmp path in ansible.cfg?
My remote user has sudo permission and I tried changing remote_tmp to absolute path in remote host as /home/shared/.ansible/tmp
Nothing is working, if I do ssh manually to the remote will work.
temproot is the user to which I manually did the ssh and /home/shared is also belongs to the temproot user and even in my inventory also I specially mentioned user as temproot.
~/.ansible/tmp is the path in ansible.cfg
Please show us a playbook which exhibits this problem (the shortest example
you can provide which shows it would be good).
Also please copy and paste a short example of a manual SSH session where you
connect to the remote server as the same user that ansible is using and run
the same command you have in the playbook.
[root@in-6centos50-dt ansible]# ssh temproot@172.16.12.215 -p 8022 temproot@172.16.12.215’s password:
*********************************** Warning ***********************************
The Linux shell access is restricted to authorized users for business purposes.
Unauthorized access is a violation of the law.
ansible all -m ping
172.16.12.215 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory.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", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo ~/.ansible/tmp"&& mkdir "echo ~/.ansible/tmp/ansible-tmp-1624049640.76-30885-21861204789923" && echo ansible-tmp-1624049640.76-30885-21861204789923="echo ~/.ansible/tmp/ansible-tmp-1624049640.76-30885-21861204789923" ), exited with result 1”,
“unreachable”: true
ansible all -m ping
172.16.12.215 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory.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", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo ~/.ansible/tmp"&& mkdir "echo ~/.ansible/tmp/ansible-tmp-1624050122.9-31206-124246621969704" && echo ansible-tmp-1624050122.9-31206-124246621969704="echo ~/.ansible/tmp/ansible-tmp-1624050122.9-31206-124246621969704" ), exited with result 1”,
“unreachable”: true
When you run ping in Ansible playbook or ansible they are using the same module. Ansible Ping is not the same as ping. Ansible ping makes an ssh connection to the server.
When ansible runs a module it writes a file to the home directory of the user on the remote machine to get the right permissions. This can be overwritten in Ansible.cfg This error says iT cannot write to /tmp.it looks like this setting has been over written.
But i have given 777 permission to my ~ directory and in ansible.cfg also tried to change the directory path to something else like /home/temproot/.ansible/tmp and /tmp/.ansible/tmp other than already existing one.
but nothing worked for me. after that i have kept the config file as it is.
The problem is it is NOT writing to the home directory. It is writing to /tmp directory. Your user has not got rights to the directory. Look for that setting the error message tells you in the ansible.cfg and take it out. Behavior should be the same after that
Why do you have so much? I just have two or three entries in mine. Role path. and collections path? Are you just copying and pasting? What purpose do yoy need to have so many entries?
i just pasted the config file which i got during the ansible installation and made modification on that, can you please specify which entry exactly do i need to change in that config file?
i just moved my config file to some unknow directory but after doing that also i am getting the same error :-
ansible all -m ping
172.16.12.215 | UNREACHABLE! => {
“changed”: false,
“msg”: “Failed to create temporary directory.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", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p "echo ~/.ansible/tmp"&& mkdir "echo ~/.ansible/tmp/ansible-tmp-1624051861.58-31908-212868002608260" && echo ansible-tmp-1624051861.58-31908-212868002608260="echo ~/.ansible/tmp/ansible-tmp-1624051861.58-31908-212868002608260" ), exited with result 2”,
“unreachable”: true
}
What do the log files such as /var/log/auth.log and /var/log/syslog on the
Debian machine you are targetting tell you is happening when you run these
commands on the Centos ansible server?