andrewrothstein / ansible-miniconda

MIT License
28 stars 26 forks source link

Ensure that miniconda_tmp_dir exists fails to set mode with default `/tmp` value #33

Open HarryWeppner opened 8 months ago

HarryWeppner commented 8 months ago

@andrewrothstein, when attempting to use the newly published role v6.3.0, the added check that the miniconda_tmp_dir exists fails as it can't change the mode on the default /tmp directory.

TASK [andrewrothstein.miniconda : Ensure that /tmp directory exists] ********************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: PermissionError: [Errno 1] Operation not permitted: b'/tmp'
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/harryweppner/.ansible/tmp/ansible-tmp-1709145014.3165748-87070-269424488826438/AnsiballZ_file.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/harryweppner/.ansible/tmp/ansible-tmp-1709145014.3165748-87070-269424488826438/AnsiballZ_file.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/harryweppner/.ansible/tmp/ansible-tmp-1709145014.3165748-87070-269424488826438/AnsiballZ_file.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.file', init_globals=dict(_module_fqn='ansible.modules.file', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in run_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansible_ansible.builtin.file_payload_rfzrg7bx/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 987, in <module>\n  File \"/tmp/ansible_ansible.builtin.file_payload_rfzrg7bx/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 973, in main\n  File \"/tmp/ansible_ansible.builtin.file_payload_rfzrg7bx/ansible_ansible.builtin.file_payload.zip/ansible/modules/file.py\", line 680, in ensure_directory\n  File \"/tmp/ansible_ansible.builtin.file_payload_rfzrg7bx/ansible_ansible.builtin.file_payload.zip/ansible/module_utils/basic.py\", line 1159, in set_fs_attributes_if_different\n  File \"/tmp/ansible_ansible.builtin.file_payload_rfzrg7bx/ansible_ansible.builtin.file_payload.zip/ansible/module_utils/basic.py\", line 919, in set_mode_if_different\nPermissionError: [Errno 1] Operation not permitted: b'/tmp'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
HarryWeppner commented 8 months ago

I am working around this by using another directory as the miniconda_tmp_dir.

bromeara commented 5 months ago

I also ran into this error, I tried resolving it by adding the become: {{escalate_ansible}} to the task but that changed the permissions of the /tmp directory for me from 777 to 744 which broke a lot of other things on the system.

Pandemonium1986 commented 1 week ago

Same error here. /tmp is a special folder in the unix system with permissions of type 1777 (or sticky bit on the other). Setting “/tmp” as the default and making sure in the tasks that the folder is 755 has consequences for any unix system. I suggest simply changing the default value of miniconda_tmp_dir to “/tmp/miniconda”. This solves the problem in the default execution of the role