I want to run a.sh on remote hosts and fetch all output files. output file with timestamp. You can see below my ansible tasks.
---
- name: 'abcd'
hosts: 'all'
gather_facts: 'false'
tasks:
- name : 'Copy the script to /tmp/ and set permission'
copy :
src : 'a.sh'
dest: '/tmp'
mode: '0700'
- name: 'Execute the script'
shell: >
/tmp/a.sh
register: 'results'
- name: 'Display output'
debug:
msg: '{{ results.stdout }}'
- name: 'Remove script'
file:
path: '/tmp/a.sh'
state: 'absent'
- name: 'fetch'
shell: "ls /tmp/test_Prereq_*"
register: path_files
fetch :
src : '/tmp/"{{item}}"'
dest : '/home/vj/testout'
with_items: '{{ path_files.stdout }}'
ansible-playbook report_task.yml --limit
ERROR! conflicting action statements: shell, fetch
The error appears to have been in '/home/vicheruk/report_task.yml': line 24, column 8, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
state: 'absent'
- name: 'fetch'
^ here
Any ideas?