严重错误!冲突的动作语句:var,include_tasks

时间:2019-12-16 00:27:18

标签: ansible

以下是我的代码:

- hosts: 11RRvEPG01
  gather_facts: no
  vars_files:
    - /etc/ansible/epg/epg_command.yml
  vars:
    - output: []  
  tasks:
    - name: run epg command
      eric_eccli_command:
        commands: "{{item}}"
      with_items: "{{epg_command}}"
      register: command_output

    - name: show execution output
      include_tasks:
        file: /etc/ansible/epg_check_output.yml
      var: 
        output: "{{item.stdout|last}}"
      with_items: "{{command_output.results}}" 

我在运行时收到错误消息:

  

错误!冲突的操作语句:var,include_tasks

1 个答案:

答案 0 :(得分:0)

正确的语法是

- name: show execution output
  include_tasks:
    file: /etc/ansible/epg_check_output.yml
  vars: 
    output: "{{ item.stdout|last }}"
  with_items: "{{ command_output.results }}" 

(将{{1}的var改为vars