Hm.

I haven't used command much myself, but I think you have to give it
space-delimited commands.

Could it be that you are actually telling Ansible to execute a command
called "inventoryctl.py host -U -H AMTEST1 -g LNZ", rather than a command
called "inventoryctl.py" with arguments "host", "-U', "-H", "AMTEST1",
"-g", and "LNZ" ?!?

Not sure how to fix that.

Regards, K.


On Tue, Aug 7, 2018 at 12:08 AM, <christian.tre...@itsv.at> wrote:

> even using {{ role_path}} does not work, this slowly is getting out of
> hand...
>
> - local_action: command "{{ item }}"
>   with_items:
>           - "pwd"
>           - "{{ role_path }}/files/inventoryctl.py group -U -n LNZ"
>           - "{{ role_path }}/files/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")
>
>
> TASK [hostgroups : command] ******************************
> ************************************************************
> ************************************************************
> *****************************
> changed: [AMTEST1 -> localhost] => (item=pwd)
> failed: [AMTEST1 -> localhost] (item=/etc/ansible/aix/roles/hostgroups/
> files/inventoryctl.py group -U -n LNZ) => {"changed": false, "cmd":
> "'/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py group -U -n
> LNZ'", "item": "/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py
> group -U -n LNZ", "msg": "[Errno 2] No such file or directory", "rc": 2}
> failed: [AMTEST1 -> localhost] (item=/etc/ansible/aix/roles/hostgroups/
> files/inventoryctl.py host -U -H AMTEST1 -g LNZ) => {"changed": false,
> "cmd": "'/etc/ansible/aix/roles/hostgroups/files/inventoryctl.py host -U
> -H AMTEST1 -g LNZ'", "item": "/etc/ansible/aix/roles/
> hostgroups/files/inventoryctl.py host -U -H AMTEST1 -g LNZ", "msg": "[Errno
> 2] No such file or directory", "rc": 2}
>
>
>
>
>
> On Monday, August 6, 2018 at 3:47:56 PM UTC+2, christia...@itsv.at wrote:
>>
>> ---
>> # tasks file for hostgroups
>> - shell: /usr/bin/uname -L | cut -d ' ' -f2
>>   register: itsv_lparname
>>
>> - command: /usr/sbin/lsattr -El sys0 -a systemid -F value
>>   register: itsv_machine_serial
>>
>> - command: pwd
>>
>> - local_action: command "{{ item }}"
>>   with_items:
>>           - "pwd"
>>           - "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")
>>
>>
>> output:
>>
>> root@lpgaixmgmtlx01:/etc/ansible/aix>ansible-playbook -i AMTEST1,
>> testplay.yml
>>
>> PLAY [run test play] ******************************
>> ************************************************************
>> ************************************************************
>> ************************************
>>
>> TASK [hostgroups : shell] ******************************
>> ************************************************************
>> ************************************************************
>> *******************************
>> changed: [AMTEST1]
>>
>> TASK [hostgroups : command] ******************************
>> ************************************************************
>> ************************************************************
>> *****************************
>> changed: [AMTEST1]
>>
>> TASK [hostgroups : command] ******************************
>> ************************************************************
>> ************************************************************
>> *****************************
>> changed: [AMTEST1]
>>
>> TASK [hostgroups : command] ******************************
>> ************************************************************
>> ************************************************************
>> *****************************
>> changed: [AMTEST1 -> localhost] => (item=pwd)
>> 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=3    changed=3    unreachable=0    failed
>> =1
>>
>>
>>
>>
>>
>> On Monday, August 6, 2018 at 3:36:11 PM UTC+2, Karl Auer wrote:
>>>
>>> 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, <christia...@itsv.at> 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, <christia...@itsv.at> 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, <christia...@itsv.at> 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, 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-proje...@googlegroups.com.
>>>>>>>> To post to this group, send email to ansible...@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-proje...@googlegroups.com.
>>>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/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  : 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-proje...@googlegroups.com.
>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>>> gid/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  : 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/3389c79e-de8b-4a47-adb3-5071dbbc7ee9%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/3389c79e-de8b-4a47-adb3-5071dbbc7ee9%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%2BT08RVf%2B%3DtHrn2Sn9nbVg5G-Rbg4-8h_o%3DbB7W7MwEdCePsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to