我只是安装在aws服务器上,然后创build一个剧本运行相同,但在运行时,我得到如下错误:
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.
违规行似乎是:
- name: copy the pattern_search.txt file which has patterns to be grepped ^ here
而我的剧本如下:
- 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
另外请注意,我有一个目录里面,我有files和tasks文件夹。 而files夹中的所有提到的文件和tasks文件夹都有上面的剧本。
我假设你正在运行ansible-playbook /blah/tasks/whatever.yml?
如果是这样,那就是你的问题。 剧本的正确结构是:
--- 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"