Reputation: 3407
I am trying to run a playbook from Ansible 2.3.1.0. My remote machine is a RHEL7 with Python installed to /usr/bin/python.
My playbook looks like this:
---
- hosts: my-test
remote_user: myuser
become: true
become_method: sudo
tasks:
#Extend /opt to 1GB
- name: Extend /opt 2048m.
lvol:
vg: rootvg
lv: rootvg-opt
size: 1024m
The error I receive:
fatal: [my-test.host.nu]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to my-test.host.nu closed.\r\n", "module_stdout": "/usr/bin/python: can't open file '/home/myuser/.ansible/tmp/ansible-tmp-1523204435.39-113929450187838/setup.py': [Errno 13] Permission denied\r\n", "msg": "MODULE FAILURE", "rc": 1}
The file "setup.py", created by Ansible, has permissions "700 myuser myuser" which I guess is a problem?
How can I make Ansible allow root to run the script? I am not even sure if that is the problem?
Upvotes: 4
Views: 30592
Reputation: 3407
I managed to pinpoint the problem. The setup.py file should never have been created in the home folder "/home/myuser" where root has no access.
I tried setting the environment variable TMPDIR and the variable "remote_tmp" in ansible.cfg as below.
ansible.cfg :
remote_tmp = /tmp/ansible-$USER
The problem was, I had missed to include the "[defaults]" "section header" before specifying the "remote_tmp" parameter. The below ansible.cfg file worked as expected.
ansible.cfg :
[defaults]
remote_tmp = /tmp/ansible-$USER
Upvotes: 6