我正在运行我的第一本易理解的剧本,尽管我完全按照视频操作,但还是出现了错误



我的第一个Ansible剧本看起来像

---
  - name: iluvnano
    hosts: linux
    tasks:
      - name: ensure nano is there
        apt: 
        name: nano
        state: latest

我得到错误

ERROR! conflicting action statements: apt, state
The error appears to be in '/root/test.yml': line 5, column 9, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
tasks:
  - name: ensure nano is there
    ^ here

根据apt模块的文档和示例

- name: Install apache httpd  (state=present is optional)
  apt:
    name: apache2
    state: present

你的缩进不正确。所以这个错误只是由打字错误引起的,你可以使用

  - name: ensure nano is there
    apt: 
      name: nano
      state: latest

最新更新