我尝试在我的任务中使用带参数include_vars的vars文件。因为我将分离接口/主机和凭证的变量。没有此选项,任务运行时没有语法错误。但如果我把这个选项放在我的任务中,我会收到消息:
ERROR! conflicting action statements
The error appears to have been in '/home/devops/ansible/roles/dev/nrpe_config/tasks/main.yml': line 27, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: copy Check Files for ENV from templates
^ here
The error appears to have been in
'/home/devops/ansible/roles/dev/nrpe_config/tasks/main.yml': line 27,
column 7, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: copy Check Files for ENV from templates
^ here
我的任务:
- name: copy Check Files for Env from templates
template: src={{item}} dest=/home/nrpe/{{item}} owner=nrpe group=nrpe mode=u+x backup=yes
with_fileglob:
- "/etc/ansible/roles/nrpe_config/nrpe_scripts/templates/env/*"
include_vars: file='interfaces.yml' name=interfaces
树文件
├── tasks
│ ├── main.bak
│ └── main.yml
└── vars
├── interfaces.yml
└── main.yml
问候niesel
答案 0 :(得分:0)
include_vars
和template
是两个不同的模块,您可以在一个任务中使用它们,而不是两个:
- name: include vars
include_vars: file='interfaces.yml' name=interfaces
- name: copy Check Files for Env from templates
template: src={{item}} dest=/home/nrpe/{{item}} owner=nrpe group=nrpe mode=u+x backup=yes
with_fileglob:
- "/etc/ansible/roles/nrpe_config/nrpe_scripts/templates/env/*"