错误!如果我使用完整的模块名称,则在任务中未检测到任何操作

Ansible ERROR! no action detected in task if I use full module name

我尝试在远程系统上进行简单的 apt 更新。我的剧本看起来像这样

---
- hosts: all
  become: true
  tasks:
  - name: update
    ansible.builtin.apt:
      update_cache: yes

当我 运行 它时,我得到了错误

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/opt/LabOS/ansible/test_pb.yml': line 6, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
  - name: update
    ^ here

但是,如果我删除模块路径 (ansible.builtin.),它 运行 就好了。根据文档,这两种表示法都应该有效。我在这里错过了什么?

我的ansible-playbook版本是2.7.7

模块的(可选)全名如 ansible.builtin.apt 仅适用于 ansible 版本 2.10。

由于您使用的是旧版本,因此会报错,您只能使用模块的简称,例如:apt