When stuff doesn't work, you have to stop making assumptions.

Use the "command" module to run
a shell command to tell you the hostname, path and CWD on whatever host
Ansible is running these tasks on.

Then you will know what's what and can adjust your playbook.

Regards, K.



On Mon, Aug 6, 2018 at 11:24 PM, <[email protected]> wrote:

>
> no idea, there is only one $PATH (even if its not mine, whatever my path
> is) so i assume that ansible uses exactly that path. ansible runs as the
> root user here, so roots path should relevant.
>
> On Monday, August 6, 2018 at 2:54:21 PM UTC+2, Karl Auer wrote:
>>
>> Not in YOUR path, in the path Ansible is using when it executes the
>> script. Use the command module and find out what the path is, what the CWD
>> is.
>>
>> As to whether it is executing on the remote - what have you got in the
>> "hosts" line?
>>
>> Regards, K.
>>
>>
>> On Mon, Aug 6, 2018 at 10:47 PM, <[email protected]> wrote:
>>
>>> i put the script in path, same errror...
>>>
>>> TASK [hostgroups : command] ******************************
>>> ************************************************************
>>> ************************************************************
>>> *****************************
>>> failed: [AMTEST1 -> localhost] (item=inventoryctl.py group -U -n LNZ) =>
>>> {"changed": false, "cmd": "'inventoryctl.py group -U -n LNZ'", "item": 
>>> "inventoryctl.py
>>> group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
>>> failed: [AMTEST1 -> localhost] (item=inventoryctl.py host -U -H AMTEST1
>>> -g LNZ) => {"changed": false, "cmd": "'inventoryctl.py host -U -H
>>> AMTEST1 -g LNZ'", "item": "inventoryctl.py host -U -H AMTEST1 -g LNZ",
>>> "msg": "[Errno 2] No such file or directory", "rc": 2}
>>>
>>> PLAY RECAP ************************************************************
>>> ************************************************************
>>> ************************************************************
>>> ****************
>>> AMTEST1                    : ok=2    changed=2    unreachable=0
>>>  failed=1
>>>
>>> root@lpgaixmgmtlx01:/etc/ansible/aix>which inventoryctl.py
>>> /usr/bin/inventoryctl.py
>>>
>>>
>>> could it be that ansible tries to run the script on the remote node
>>> instead of local? this means it runs local right? ([AMTEST1 -> localhost
>>> ])
>>>
>>>
>>>
>>> On Monday, August 6, 2018 at 12:52:37 PM UTC+2, Karl Auer wrote:
>>>>
>>>> I have not done this myself, but I think that the script you are
>>>> running has to be in the search path ("$PATH") OR you have to specify an
>>>> absolute path ("/[...]/myscript.py") OR you have to specify a path relative
>>>> to the current working directory - that is, the directory that is the CWD
>>>> when ansible tries to execute the script.
>>>>
>>>> I think that the CWD is not what you think it is.You could find it out
>>>> by executing the command "pwd".
>>>>
>>>> Regards, K.
>>>>
>>>>
>>>> On Mon, Aug 6, 2018 at 8:17 PM, <[email protected]> wrote:
>>>>
>>>>> hmm...does not work.
>>>>>
>>>>> TASK [hostgroups : command] ******************************
>>>>> ************************************************************
>>>>> ************************************************************
>>>>> *****************************
>>>>> failed: [AMTEST1 -> localhost] (item=roles/hostgroups/files/i
>>>>> nventoryctl.py group -U -n LNZ) => {"changed": false, "cmd":
>>>>> "'roles/hostgroups/files/inventoryctl.py group -U -n LNZ'", "item":
>>>>> "roles/hostgroups/files/inventoryctl.py group -U -n LNZ", "msg": "[Errno
>>>>> 2] No such file or directory", "rc": 2}
>>>>> failed: [AMTEST1 -> localhost] (item=roles/hostgroups/files/i
>>>>> nventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false, "cmd":
>>>>> "'roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ'",
>>>>> "item": "roles/hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g
>>>>> LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
>>>>>
>>>>> PLAY RECAP ******************************
>>>>> ************************************************************
>>>>> ************************************************************
>>>>> **********************************************
>>>>> AMTEST1                    : ok=3    changed=2    unreachable=0
>>>>>  failed=1
>>>>>
>>>>> root@lpgaixmgmtlx01:/etc/ansible/aix>file roles/hostgroups/files/
>>>>> inventoryctl.py
>>>>> roles/hostgroups/files/inventoryctl.py: Python script, ASCII text
>>>>> executable
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Friday, August 3, 2018 at 7:11:51 PM UTC+2, Kai Stian Olstad wrote:
>>>>>>
>>>>>> On 03.08.2018 16:29, [email protected] wrote:
>>>>>> > i want to run a python script in a role. currently the script is in
>>>>>> the
>>>>>> > tasks directory but i also tried the file dir which also is not
>>>>>> > working.
>>>>>> > where i have to put this script so it can be found at runtime?
>>>>>>
>>>>>> It's using path to find the executable, is it not in the path you
>>>>>> need
>>>>>> to use relative path or absolute path.
>>>>>>
>>>>>>
>>>>>> > - local_action: command "{{ item }}"
>>>>>> >   with_items:
>>>>>> >           - "inventoryctl.py group -U -n LNZ"
>>>>>> >           - "inventoryctl.py host -U -H {{ inventory_hostname }} -g
>>>>>> > LNZ"
>>>>>> >   when: (itsv_machine_serial.stdout is match "IBM,02781A6BX") or
>>>>>> >         (itsv_machine_serial.stdout is match "IBM,02781A6CX") or
>>>>>> >         (itsv_machine_serial.stdout is match "IBM,02781A6DX")
>>>>>>
>>>>>> If you have roles/hostgroups/files/inventoryctl.py the command would
>>>>>> be
>>>>>>
>>>>>>    roles/hostgroups/files/inventoryctl.py
>>>>>>
>>>>>> --
>>>>>> Kai Stian Olstad
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Ansible Project" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/ansible-project/aa1c1828-
>>>>> 881f-49a3-bab4-6b3add73bb11%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/ansible-project/aa1c1828-881f-49a3-bab4-6b3add73bb11%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Karl Auer
>>>>
>>>> Email  : [email protected]
>>>> Website: http://2pisoftware.com
>>>>
>>>> GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>>>> Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ansible Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/ansible-project/c198d040-ee84-478f-b8f8-453f8050c08b%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/ansible-project/c198d040-ee84-478f-b8f8-453f8050c08b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Karl Auer
>>
>> Email  : [email protected]
>> Website: http://2pisoftware.com
>>
>> GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
>> Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/4ac914f0-da18-4635-ae0e-ff74a4e9461c%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/4ac914f0-da18-4635-ae0e-ff74a4e9461c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Karl Auer

Email  : [email protected]
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RnyPwgde6K85%3DThXNPmZ1J6v-JtjQXzLq%2BLkn63278LA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to