首页 > 解决方案 > 在块中运行 eos_config 任务时出现 Ansible 错误

问题描述

我有一个可将一些配置更改推送到 eos 设备的 ansible playbook

---
- name: Access list
  hosts: myhosts
  connection: network_cli

  tasks:

    - name: run change type 1
      block:
        - name: Interface change
          eos_config:
            lines:
              - description {{ change.description.server }} }
              - no logging event link-status
          parents: interface "{{ interface }}"

        - name: Portchannel change
          eos_config:
            lines:
              - description {{ change.description.server }} {{ change.description.nic }}
              - switchport trunk allowed vlan none
            parents: interface "{{ portchannel }}"
      when: changetype == 1 

但这会引发错误

ERROR! 'parents' is not a valid attribute for a Task
The offending line appears to be:
  block:
    - name: Interface change (change type 1)
      ^ here

有没有办法在一个块中运行 eos_config 命令?

标签: ansible

解决方案


根据@zeitounator 的评论,缩进是错误的。


推荐阅读