error while playing ansible playbook
I just installed ansible on a server in aws and then created a playbook to run the same but while running i am getting error as below :
ERROR! 'copy' is not a valid attribute for a Play
The error appears to have been in '/root/amritha/pega-cloud-infrastructure/ansible/roles/datadog-pegalogs-apptier/tasks/main.yml': line 3, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: copy the pattern_search.txt file which has patterns to be grepped
^ here
And my playbook is as follows:
- name: copy the pattern_search.txt file which has patterns to be grepped
copy: src=pattern_search.txt dest=/root/pattern_search.txt owner=root group=root mode=755
- name: copy the logsearchtest.sh script which greps patterns and prints pattern.txt file
copy: src=logsearchtest.sh dest=/root/logsearchtest.sh owner=root group=root mode=755
script: /root/logsearchtest.sh
- name: schedule cron to run every 5 minutes
#cron: */5 * * * * root /root/logsearchtest.sh -c "script to grep patterns;"
cron: name="logsearch script for grepping pega alert logs" minute="5" job="/root/logsearchtest.sh > /dev/null"
- name: copy parsers.py fucntion to datadog lib path
copy: src=parsers.py dest=/opt/datadog-agent/agent/checks/libs/parsers.py owner=root group=root mode=755
- name: copy datadog agent configuration file
copy: src=datadog-agent.conf dest=/etc/datadog.conf owner=root group=root mode=755
Also please note that I have a directory inside that I have files
and tasks
folder. And the files
folder has all mentioned files and tasks
folder has the above playbook.
I assume you are running ansible-playbook /blah/tasks/whatever.yml?
If so, that's your problem. The proper structure for a playbook is:
---
name: my playbook
roles:
- Arole
- Brole
# other playbok attributes
tasks:
- name: copy stuff
copy: src=foo dest=bar
- name: include cool tasks
include: ../tasks/snafu.yml
when: poobar == "fubar"