Ansible - 带有项目的模板不起作用

Ansible - 带有项目的模板不起作用

我在 ansible 剧本中运行这个程序,从 ansible 角色的目录“模板”复制文件,但出现错误...

- name:  "Copy templates"
templates: src={{item.src}} dest={{item.dest}}
with_items:
    - { src: 'tpl1', dest: '/etc/tpl1' }
    - { src: 'tpl2', dest: '/etc/tpl2' }
    - { src: 'tpl3', dest: '/etc/tpl3' }

错误输出:

ERROR! couldn't resolve module/action 'templates'. This often indicates a misspelling, missing collection, or incorrect module path.

The error appears to be in '/home/myuser/Desktop/mydir/roles/rolename/tasks/main.yml': line 73, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


- name:  "Copy templates"
^ here

你能帮助我吗?

答案1

该模块被命名为template, 不是templates

- name: "Copy templates"
  template:
    src="{{item.src}}"
    dest="{{item.dest}}"

相关内容