ANSIBLE不起作用 - 语法检查

时间:2017-12-02 19:13:51

标签: ansible yaml

我试图在ansible上设置我的第一本剧本。 Hovever ......无论我试图测试哪个例子,我都会收到类似的错误:

"xyz is not a valid attribute for a Play"

例如:

 $ cat a2.yml
- name: Update and upgrade
  become: true
  apt:
    upgrade: yes
    update_cache: yes


$ ansible-playbook a2.yml --syntax-check
ERROR! 'apt' is not a valid attribute for a Play

The error appears to have been in '/home/pi/My/ansible/a2.yml': line 1, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name: Update and upgrade
  ^ here

怎么了?

PS。

$ ansible --version
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/pi/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170124]

1 个答案:

答案 0 :(得分:1)

请参阅Playbooks Intro文档。 您的参赛作品应为task项。

---
- hosts: ...
  tasks:
    - name: Update and upgrade
      become: true
      apt:
        upgrade: yes
        update_cache: yes