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, <christian.tre...@itsv.at> wrote:

> hmm...does not work.
>
> TASK [hostgroups : command] ******************************
> ************************************************************
> ************************************************************
> *****************************
> failed: [AMTEST1 -> localhost] (item=roles/hostgroups/files/inventoryctl.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/inventoryctl.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/invento
> ryctl.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, christia...@itsv.at 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> 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  : ka...@2pisoftware.com
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RzRxNr__Ocsg6j8983KXpe--7euoPS1uFkf7%2BWJ%3DB6LA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to