每次在Ansible剧本中使用不同的参数运行命令

问题描述 投票:0回答:2

我正在尝试在Ansible中运行命令,以便在我的网络中找到邻居:

- name: Get neighbors
  junos_rpc:
    rpc: "get-lldp-interface-neighbors"
    output: 'xml'
    args:
      interface_device: A
  register: net_topology

所以我的问题出在此任务中,我需要遍历列表并为interface_device提供另一个arg,并且每次都将结果也注册到另一个变量'net_topology'中。

loops ansible ansible-2.x
2个回答
2
投票
- name: Get neighbors
  junos_rpc:
    rpc: "get-lldp-interface-neighbors"
    output: 'xml'
    args:
      interface_device: "{{ item }}"
  loop:
    - A
    - B
    - C
  register: net_topology


0
投票

实际上,我所做的与上述类似,但是我只是以不同的方式传递了清单:

© www.soinside.com 2019 - 2024. All rights reserved.