0

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'

1 Answer 1

1

It seems it is only looking for '/usr/bin:/bin' paths.

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:

- command: <script_on_target_node>
  environment:
    PATH: <path_string>
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.