snippetMinor
Ansible no user $HOME by default - so how do I run commands
Viewed 0 times
commandsuserdefaulthomehowansiblerun
Problem
I have thousands of servers that, by default, for security and space do not create a
This seems to be posing a problem for Ansible as it keeps trying to
Here is the error with the server name changed for security reasons;
```
☁ .ansible ansible-playbook get_fleet_info.yml -vvvv
fatal: [ldap-corp-search-server.com]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017\r\ndebug1: Reading configuration data /home/eekfonky/.ssh/config\r\ndebug1: /home/eekfonky/.ssh/config line 2: Applying options for \r\ndebug3: /home/eekfonky/.ssh/config line 9: Including file /home/eekfonky/.ssh/bastions-config depth 0\r\ndebug1: Reading configuration data /home/eekfonky/.ssh/bastions-config\r\ndebug1: /home/eekfonky/.ssh/bastions-config line 10: Applying options for .corp.amazon.com\r\ndebug1: /home/ekfonky/.ssh/bastions-config line 35: Applying options for .pdx.server.com\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 27395\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session:
$HOME when you ssh in.This seems to be posing a problem for Ansible as it keeps trying to
chdir to home that does not exist. Can I get Ansible to use another directory in the ansible.cfg or just stop this behaviour completely?ansible.cfg[defaults]
inventory = /home/welshch/.ansible/hosts
remote_tmp = /tmp
local_tmp = ~/.ansible/tmp
interpreter_python = auto_silent
roles_path = /home/eekfonky/.ansible/roles
host_key_checking = FalseHere is the error with the server name changed for security reasons;
```
☁ .ansible ansible-playbook get_fleet_info.yml -vvvv
fatal: [ldap-corp-search-server.com]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"module_stderr": "OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017\r\ndebug1: Reading configuration data /home/eekfonky/.ssh/config\r\ndebug1: /home/eekfonky/.ssh/config line 2: Applying options for \r\ndebug3: /home/eekfonky/.ssh/config line 9: Including file /home/eekfonky/.ssh/bastions-config depth 0\r\ndebug1: Reading configuration data /home/eekfonky/.ssh/bastions-config\r\ndebug1: /home/eekfonky/.ssh/bastions-config line 10: Applying options for .corp.amazon.com\r\ndebug1: /home/ekfonky/.ssh/bastions-config line 35: Applying options for .pdx.server.com\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 58: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 27395\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session:
Solution
I assume that you are referring to verbose output similar like
Can I get Ansible to use another directory ...
According an older documentation (v2.3), it is possible to change that value. The configuration parameter
When Ansible gets ready to send a module to a remote machine ... The default location is a subdirectory of the user’s home directory. If you’d like to change that, you can do so by altering this setting
According
Further Q&A
it should be the variable
TASK [Task] *****************************************************************************************************************
task path: taskFile:
...
ESTABLISH ... CONNECTION FOR USER: {{ ansible_user }}
EXEC /bin/sh -c 'echo ~{{ ansible_user }} && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/{{ ansible_user }}/.ansible/tmp `"&& mkdir "` echo /home/{{ ansible_user }}/.ansible/tmp/ansible-tmp-1234567890 `" && echo ansible-tmp-1234567890="` echo /home/{{ ansible_user }}/.ansible/tmp/ansible-tmp-1234567890 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/find.py
...Can I get Ansible to use another directory ...
According an older documentation (v2.3), it is possible to change that value. The configuration parameter
local_tmp might still be available in latest version.When Ansible gets ready to send a module to a remote machine ... The default location is a subdirectory of the user’s home directory. If you’d like to change that, you can do so by altering this setting
According
Further Q&A
- Ansible temp dir change
it should be the variable
remote_tmp.Code Snippets
TASK [Task] *****************************************************************************************************************
task path: taskFile:<lineNumber>
...
<IP> ESTABLISH ... CONNECTION FOR USER: {{ ansible_user }}
<IP> EXEC /bin/sh -c 'echo ~{{ ansible_user }} && sleep 0'
<IP> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/{{ ansible_user }}/.ansible/tmp `"&& mkdir "` echo /home/{{ ansible_user }}/.ansible/tmp/ansible-tmp-1234567890 `" && echo ansible-tmp-1234567890="` echo /home/{{ ansible_user }}/.ansible/tmp/ansible-tmp-1234567890 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/find.py
...Context
StackExchange DevOps Q#15660, answer score: 2
Revisions (0)
No revisions yet.