andrewrothstein / ansible-miniconda

MIT License
28 stars 26 forks source link

Add `miniconda_tmp_dir` var #25

Closed msabramo closed 2 years ago

msabramo commented 2 years ago

This is very nice to have, because on some systems, /tmp is mounted with noexec and running the miniconda installer from it errors out with something like:

TASK [ansible-miniconda : installing....] *****************************************************************
fatal: [18.207.199.152]: FAILED! => {"changed": true, "cmd": [
"bash", "/tmp/Miniconda3-py39_4.10.3-Linux-x86_64.sh", "-b", 
"-p", "/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64"], "delta": "0:00:01.159150", 
"end": "2022-04-21 19:09:05.179247", "msg": "non-zero return code", "rc": 1, 
"start": "2022-04-21 19:09:04.020097", 
"stderr": "/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64/conda.exe: error while loading shared libraries: 
libz.so.1: failed to map segment from shared object: Operation not permitted\n
/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64/conda.exe: error while loading shared libraries: 
libz.so.1: failed to map segment from shared object: Operation not permitted", 
"stderr_lines": [
"/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64/conda.exe: error while loading shared libraries: 
libz.so.1: failed to map segment from shared object: Operation not permitted", 
"/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64/conda.exe: error while loading shared libraries:
 libz.so.1: failed to map segment from shared object: Operation not permitted"], 
"stdout": "PREFIX=/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64\nUnpacking payload ...", 
"stdout_lines": ["PREFIX=/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64", "Unpacking payload ..."]}
/usr/local/Miniconda3-py39_4.10.3-Linux-x86_64/conda.exe: 
error while loading shared libraries: libz.so.1: failed to map segment from shared object: 
Operation not permitted

The solution is to allow using a different TMPDIR as described at https://stackoverflow.com/questions/60106630/conda-exe-error-while-loading-shared-libraries-libz-so-1

Without this, I get errors like the above while trying to provision an Amazon Linux EC2 instance. With this, I can put this in my playbook:

     - name: Include ansible-miniconda role
       import_role:
         name: ansible-miniconda
       vars:
         miniconda_make_sys_default: True
         miniconda_tmp_dir: "{{ ansible_env.HOME }}/tmp"
       tags: miniconda

and it works.

msabramo commented 2 years ago

Thanks for merging! Note that https://github.com/andrewrothstein/ansible-anaconda/pull/38 is an analogous PR for ansible-anaconda.