I have a python script that runs "vgs" command to check the free space in the volume groups available and then creates lvm , using lvcreate command.
When I run this python script locally, I can run it without issues and the lvm gets created as well. But if I run it using Ansible playbook, I've tried with both 'command' and 'shell' modules, it is unable to locate the path for vgs
command and fails. It seems it is only looking for /usr/bin:/bin
paths. Please help.
which: no vgs in (/usr/bin:/bin)", "No Volume Groups Found", "Space Found in Volume Group:"], "warnings": []}
"stderr": "sh: -c: line 0: syntax error near unexpected token `('\nsh: -c: line 0: `{ which: no vgs in (/usr/bin:/bin) -o VG_NAME --noheadings --units m ; } 2>&1'
Because interactive and non-interactive shell sessions call different set of rc-files. If you set
PATH
in rc-files that are sourced only by interactive shell, those settings won't be reflected in non-interactive shells.Add
PATH
as an environment variable to the task: