For security reasons, we have /tmp
mounted with noexec-flag. Since docker need the exec-flag, running any docker-compose command like docker-compose --version
would result in the following error:
docker-compose: error while loading shared libraries: libz.so.1: failed to map segment from shared object
This could be fixed on the CLI by setting the TMPDIR
env variable to a local path like the home directory. But in Ansible this doesn't work, since it's not spawning a login shell. We got an Ansible playbook with a lot of docker-compose
cli calls and they ignore TMPDIR
exported in e.g. /etc/environment
.
It only works when specifying TMPDIR
as environment variable with an absolute path like this:
- name: Check if all applications are is running
shell: |
docker-compose ps | grep Up | wc -l
changed_when: running.stdout != item.services_num
register: running
with_items:
- "{{ docker_applications }}"
environment:
TMPDIR: /home/myuser
Since this results in many code changes and overhead, I'm searching how to set this globally. remote_tmp
should be able to fix this, so I set it in ansible.cfg
:
[defaults]
remote_tmp = /home/myuser
This doesn't work and I can't find the directive in the Ansible 2.9, 2.8 or 2.9 docs.