Solaris 10 - '~' directory created in home directory - unarchive fails

I have set of servers that are Solaris 10. When ansible is invoked against the remote hosts, it creates a ‘~’ directory in the home directory instead of viewing ‘~’ as the users home directory.

xx64473z:apache$ pwd
/export/home/apache/~/.ansible/tmp
xx64473z:apache$ ls -l
total 8
drwx------ 2 apache staff 512 Oct 11 11:13 ansible-tmp-1507734837.83-37778909106509
drwx------ 2 apache staff 512 Oct 11 11:14 ansible-tmp-1507734843.04-65780739271966
drwx------ 2 apache staff 512 Oct 11 11:14 ansible-tmp-1507734843.27-42994154513941
drwx------ 2 apache staff 512 Oct 11 11:14 ansible-tmp-1507734846.05-28584204910152

The ansible commands run except for unarchive which receives the following error:

fatal: [xx64473z.xx.xxxxxx]: FAILED! => {“changed”: false, “failed”: true, “msg”: “Source ‘/export/home/apache/.ansible/tmp/ansible-tmp-1507734843.04-65780739271966/source’ failed to transfer”}

It is looking for the source file in the what should be the default remote_tmp directory. But since the directory is actually ‘/export/home/apache/~/.ansible/tmp’, it is not able to find the source and fails.

Here is my ansible host version:

ansible 2.3.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Aug 29 2016, 10:12:21) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

And the remove server info:
“ansible_distribution”: “Solaris”,
“ansible_distribution_release”: “Oracle Solaris 10 1/13 s10s_u11wos_24a SPARC”,
“ansible_distribution_version”: “10”,

I do not know if this is considered a bug. I know I can override the remote_tmp in the ansible.cfg file, but do not want to make this a global change. Ansible works correctly on all of the other hosts.

Is it possible to set remote_tmp for a single playbook? Or for a subset of servers?

Any suggestions on how to get around this error?

Making remote_tmp finer grained is on the roadmap for 2.5. That includes per host remote_tmp.

https://github.com/ansible/ansible/issues/31022 is a tracking bug for remote_tmp related bugs and features which
are intended to be fixed during 2.5 devel.

https://github.com/ansible/ansible/issues/20886 from that list sounds similar to this issue.

More notes inline below…

I do not know if this is considered a bug. I know I can override the remote_tmp in the ansible.cfg file, but do not want to make this a global change. Ansible works correctly on all of the other hosts.

If ~/ is not being evaluated properly that sounds like a bug to me. Could you post an example
playbook that triggers that? And the output from ansible-playbook with ‘-vvvv’ verbosity for
a run that does the wrong thing.

Was this working before 2.3.2.0 ? If so, what versions?

Are you able to test against 2.4.0.0 as well? There have been a lot changes to unarchive in 2.4

and some of the file/path handling code that could change the behavior. I don’t see anything
obvious in the changes that definitely fixes that though.

https://github.com/ansible/ansible/pull/21874 and https://github.com/ansible/ansible/pull/24732
and https://github.com/ansible/ansible/commit/1fb53e6aaf052c34b8715b1f4e9bbe38c3f1c95c

could be candidates though.

I believe there is a bug for this open[1]_. If you change remote_tmp
to use $HOME instead of ~ I believe that workaround will fix your
issue on Solaris (but may introduce a problem on platforms where the
HOME environment variable is not set). The problem ultimately comes
down to Solaris 10 not shipping with a POSIX compliant /bin/sh. I
believe some users in the bg report said that they do have a POSIX
compliant sh in another path so an alternative that would probably
work would be to set ansible_shell_executable pointing to the POSIX
compatible sh for the Solaris 10 host .

.. _[1]: https://github.com/ansible/ansible/issues/21594
-Toshio

As mentioned above, we are looking at making all this 'per host
configurable' in 2.5 so you can alter either shell or remote_tmp for
the 'solaris hosts' to avoid this issue. The current default works on
most platforms and $HOME sadly does not, which is why we are not
likely to change it.

I set the remote_tmp to $HOME and it works for Solaris. My environment is RedHat, Windows, Solaris, AIX and maybe some other stragglers. I haven’t had issues with deploys so far, but have not had the time to test everything. I have bash on the Solaris box, so I may try the ansible_shell_executable.

Looking forward to the 2.5 release so I can set it fine grained. These global config changes concern me given the size and growth of our ansible deployment env.

If ansible_shell_executable works you should be able to set it
per-host (or for a group of hosts). So you will be able to get the
fine-grained setting you want (it's just not obvious from the symptoms
that setting the shell is the solution).

-Toshio

started work on this, it still depends on other parts being there,
https://github.com/ansible/ansible/pull/31677

it will make shells and 'remote options' more configurable, including
tmp of course.

Careful on changing ansible_shell_executable, you have to make sure
ansible_shell_type matches.