Could not make dir /$HOME/.ansible/cp: [Errno 13] Permission denied: '/$HOME

1.9k Views Asked by At

I've got a python script that uses the ansible package to ping some remote servers. When executed manually (python devmanager.py) it works ok, but when the script is managed with supervisor it raises the following error:

Could not make dir /$HOME/.ansible/cp: [Errno 13] Permission denied: '/$HOME

The ansible command is quite simple:

    runner = ansible.runner.Runner(
            module_name='ping',
            module_args='',
            forks=10,
            inventory=inventory
    )

Same user in source and target systems. I've check permissions for the $HOME folder and didn't find anything weird.

Any idea what's is going on? Doesn't it know to translate the $HOME variable?

2

There are 2 best solutions below

0
plaes On

Yes, it seems that it doesn't escape the $HOME variable and tries to write under /$HOME.

3
SPM On

You may give a try by altering the parameter "remote_tmp" in ansible.cfg.

Default:-$HOME/.ansible/tmp

Update:-/tmp/.ansible/tmp

On this case who ever the user try to run the playbook will have enough permission to create necessary temporary files in /tmp directory.