Yes Dick,
I tried that way as well still I am getting same error as you can see my playbook
playbook:
---
- hosts: atrium
gather_facts: no
tasks:
- name: running ok clean
command: ok clean
chdir=/home/admin/onos
warn=no
register: result
- debug: var=result
Here 'ok clean' is the command to run onos,Which I wanted to pass to remote server still it is giving me following error
Error Message:
FAILED! => {"changed": false, "cmd": "ok clean", "failed": true, "msg": "[Errno 2] No such file or directory", "rc": 2}
[WARNING]: Could not create retry file '/etc/ansible-atrium/atrium.retry'. [Errno 13] Permission denied: u'/etc/ansible-
atrium/atrium.retry'
I wrote one more playbook to check the root cause of error.
playbook:
---
- hosts: atrium
gather_facts: no
tasks:
- name: running ok clean
command: "{{item}}"
args:
chdir: "onos/"
with_items:
- "ls -lt"
- "ifconfig"
register: result
- debug: result
As you can see I am running two different commands I include double quotes before sending commands,Now I am not getting any error If I run 'ls -lt' since it cames with space and earlier it was giving me error but now it not.And when I am passing 'ok clean' command I am getting following error
playbook with 'ok clean':
---
- hosts: atrium
gather_facts: no
tasks:
- name: running ok clean
command: "{{item}}"
args:
chdir: "onos/"
with_items:
- "ls -lt"
- "ifconfig"
- "ok clean"
register: result
- debug: var=result
Error message:
changed: [192.168.2.129] => (item=ls -lt)
changed: [192.168.2.129] => (item=ifconfig)
failed: [192.168.2.129] (item=ok clean) => {"cmd": "ok clean", "failed": true, "item": "ok clean", "msg": "[Errno 2] No such file or directory", "rc": 2}
[WARNING]: Could not create retry file '/etc/ansible-atrium/atrium2.retry'. [Errno 13] Permission denied: u'/etc/ansible-
atrium/atrium2.retry'
It giving me same error for 'ok clean' command. And if I run the same command manually in the the remote VM it running perfectly. So can help me to get rid of this error, Am I missing something here ?