报错环境
一、ansible—yaml
[root@server1 ~]# vim Apcha.yaml
- hosts: mysql
remote_user: root
tasks:- name: yum httpd
yum: name=httpd - name: start httpd
service: name=httpd state=started - name: stop firewalld
service: name=firewalld state=stopped - name: index.html
copy: content=this is Apcha dest=/var/www/html/index.html
- name: yum httpd
报错信息:
[root@server1 ~]# ansible-playbook Apcha.yaml --syntax-check
ERROR! this task ‘copy’ has extra params, which is only allowed in the following modules: shell, win_shell, include_vars, ansible.builtin.import_tasks, add_host, ansible.legacy.meta, ansible.builtin.include_vars, ansible.legacy.include_role, raw, ansible.legacy.add_host, include_role, meta, ansible.builtin.meta, ansible.legacy.include, ansible.legacy.import_role, ansible.builtin.include_role, ansible.legacy.include_vars, ansible.legacy.include_tasks, set_fact, include, import_tasks, ansible.legacy.set_fact, ansible.builtin.set_fact, script, ansible.builtin.group_by, ansible.builtin.import_role, import_role, ansible.builtin.include_tasks, include_tasks, ansible.legacy.group_by, ansible.builtin.include, group_by, command, ansible.builtin.add_host, ansible.legacy.import_tasks, win_command
The error appears to be in ‘/root/Apcha.yaml’: line 9, column 19, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
service: name=firewalld state=stopped
^ here
There appears to be both ‘k=v’ shorthand syntax and YAML in this task. Only one syntax may be used.
解决:没有加引号
copy: content="this is Apcha" dest=/var/www/html/index.html