• 博客
  • Ansible 社区论坛
  • 文档
Ansible Logo
Ansible 社区文档
Ansible

Ansible 入门

  • Ansible 入门指南
  • 执行环境入门指南

安装、升级和配置

  • 安装指南
  • Ansible 移植指南

使用 Ansible

  • 构建 Ansible 清单
  • 使用 Ansible 命令行工具
  • 使用 Ansible 剧本
  • 使用 Ansible vault 保护敏感数据
  • 使用 Ansible 模块和插件
  • 使用 Ansible 集合
  • 在 Windows 和 BSD 上使用 Ansible
  • Ansible 提示和技巧

为 Ansible 作出贡献

  • Ansible 社区指南
  • Ansible 集合贡献者指南
  • ansible-core 贡献者指南
  • 高级贡献者指南
  • Ansible 文档样式指南

扩展 Ansible

  • 开发者指南

常见的 Ansible 场景

  • 旧版公共云指南

网络自动化

  • 网络入门
  • 网络高级主题
  • 网络开发者指南

Ansible Galaxy

  • Galaxy 用户指南
  • Galaxy 开发者指南

参考和附录

  • 集合索引
    • Amazon 命名空间中的集合
    • Ansible 命名空间中的集合
    • Arista 命名空间中的集合
    • Awx 命名空间中的集合
    • Azure 命名空间中的集合
    • Check_point 命名空间中的集合
    • Chocolatey 命名空间中的集合
    • Cisco 命名空间中的集合
    • Cloud 命名空间中的集合
    • Cloudscale_ch 命名空间中的集合
    • Community 命名空间中的集合
    • Containers 命名空间中的集合
    • Cyberark 命名空间中的集合
    • Dellemc 命名空间中的集合
    • F5networks 命名空间中的集合
    • Fortinet 命名空间中的集合
    • Frr 命名空间中的集合
    • Gluster 命名空间中的集合
    • Google 命名空间中的集合
    • Grafana 命名空间中的集合
    • Hetzner 命名空间中的集合
    • Hpe 命名空间中的集合
    • Ibm 命名空间中的集合
    • Ieisystem 命名空间中的集合
    • Infinidat 命名空间中的集合
    • Infoblox 命名空间中的集合
    • Inspur 命名空间中的集合
    • Junipernetworks 命名空间中的集合
      • Junipernetworks.Junos
        • 描述
        • 插件索引
    • Kaytus 命名空间中的集合
    • Kubernetes 命名空间中的集合
    • Kubevirt 命名空间中的集合
    • Lowlydba 命名空间中的集合
    • Mellanox 命名空间中的集合
    • Microsoft 命名空间中的集合
    • Netapp 命名空间中的集合
    • Netapp_eseries 命名空间中的集合
    • Netbox 命名空间中的集合
    • Ngine_io 命名空间中的集合
    • Openstack 命名空间中的集合
    • Openvswitch 命名空间中的集合
    • Ovirt 命名空间中的集合
    • Purestorage 命名空间中的集合
    • Sensu 命名空间中的集合
    • Servicenow 命名空间中的集合
    • Splunk 命名空间中的集合
    • T_systems_mms 命名空间中的集合
    • Telekom_mms 命名空间中的集合
    • Theforeman 命名空间中的集合
    • Vmware 命名空间中的集合
    • Vultr 命名空间中的集合
    • Vyos 命名空间中的集合
    • Wti 命名空间中的集合
  • 所有模块和插件的索引
  • 剧本关键字
  • 返回值
  • Ansible 配置设置
  • 控制 Ansible 的行为:优先级规则
  • YAML 语法
  • Python 3 支持
  • 解释器发现
  • 发布和维护
  • 测试策略
  • 完整性测试
  • 常见问题
  • 词汇表
  • Ansible 参考:模块实用程序
  • 特殊变量
  • Red Hat Ansible Automation Platform
  • Ansible Automation Hub
  • 记录 Ansible 输出

路线图

  • Ansible 路线图
  • ansible-core 路线图




Ansible
  • 集合索引
  • Junipernetworks 命名空间中的集合
  • Junipernetworks.Junos
  • junipernetworks.junos.junos_lag_interfaces 模块 – 链路聚合 Juniper JUNOS 资源模块


junipernetworks.junos.junos_lag_interfaces 模块 – 链路聚合 Juniper JUNOS 资源模块

注意

此模块是 junipernetworks.junos 集合 (版本 9.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。

要安装它,请使用:ansible-galaxy collection install junipernetworks.junos。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。

要在剧本中使用它,请指定:junipernetworks.junos.junos_lag_interfaces。

junipernetworks.junos 1.0.0 中的新增功能

  • 概要

  • 要求

  • 参数

  • 注释

  • 示例

  • 返回值

概要

  • 此模块管理 Juniper JUNOS 设备上链路聚合组的属性。

要求

执行此模块的主机需要以下要求。

  • ncclient (>=v0.6.4)

参数

参数

注释

config

列表 / 元素=字典

链路聚合组配置的列表。

link_protection

布尔值

此布尔值选项指示是否应为 LAG 接口启用链路保护。如果值为 True,则在 LAG 上启用链路保护;如果值为 False,则禁用链路保护。

选项

  • false

  • true

members

列表 / 元素=字典

链路聚合组的成员接口列表。该值可以是单个接口或接口列表。

ether_option_type

字符串

指定以太网接口的类型。

选项

  • "ether" ← (默认)

  • "gigether"

link_type

字符串

此选项的值将成员链路配置为 primary 或 backup。值 primary 为链路保护模式配置主接口,backup 为链路保护模式配置备份接口。

选项

  • "primary"

  • "backup"

member

字符串

成员接口的名称。

mode

字符串

LAG 模式。passive 值将以 passive 模式启用 LACP,即它将响应 LACP 数据包;active 将链路配置为启动 LACP 数据包的传输。

选项

  • "active"

  • "passive"

name

字符串 / 必填

链路聚合组 (LAG) 的名称。

running_config

字符串

此选项仅与状态 *parsed* 一起使用。

此选项的值应为通过执行命令 **show interfaces** 从 Junos 设备接收到的输出。

状态 *parsed* 从 running_config 选项读取配置并将其转换为 Ansible 结构化数据,该数据符合资源模块的 argspec,然后该值将返回结果中的 *parsed* 密钥中

state

字符串

模块完成后的配置状态

选项

  • "merged" ← (默认)

  • "replaced"

  • "overridden"

  • "deleted"

  • "gathered"

  • "rendered"

  • "parsed"

注释

注意

  • 此模块要求在被管理的远程设备上启用 netconf 系统服务。

  • 针对 vSRX JUNOS 版本 18.4R1 进行了测试。

  • 此模块与连接 netconf 一起使用。请参阅 Junos OS 平台选项。

示例

# Using merged

# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
#    ether-options {
#        802.3ad ae0;
#    }
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
#    ether-options {
#        802.3ad ae0;
#    }
# }
# ae0 {
#     description "lag interface";
# }
# ae1 {
#     description "lag interface 1";
# }

- name: "Delete LAG attributes of given interfaces (Note: This won't delete the interface itself)"
  junipernetworks.junos.junos_lag_interfaces:
    config:
      - name: ae0
      - name: ae1
    state: deleted

# After state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
# }


# Using merged

# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
# }

- name: Merge provided configuration with device configuration
  junipernetworks.junos.junos_lag_interfaces:
    config:
      - name: ae0
        members:
          - member: ge-0/0/1
            link_type: primary
          - member: ge-0/0/2
            link_type: backup
    state: merged

# After state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
#    ether-options {
#        802.3ad {
#            ae0;
#            primary;
#        }
#    }
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
#    ether-options {
#        802.3ad {
#            ae0;
#            backup;
#        }
#    }
# }


# Using merged

# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
#    ether-options {
#        802.3ad ae0;
#    }
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
#    ether-options {
#        802.3ad ae0;
#    }
# }
# ae0 {
#     description "lag interface";
# }
# ae3 {
#     description "lag interface 3";
# }

- name: Overrides all device LAG configuration with provided configuration
  junipernetworks.junos.junos_lag_interfaces:
    config:
      - name: ae0
        members:
          - member: ge-0/0/2
      - name: ae1
        members:
          - member: ge-0/0/1
        mode: passive
    state: overridden

# After state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
#    ether-options {
#        802.3ad ae1;
#    }
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
#    ether-options {
#        802.3ad ae0;
#    }
# }
# ae0 {
#     description "lag interface";
# }
# ae1 {
#    aggregated-ether-options {
#        lacp {
#            active;
#        }
#    }
# }


# Using merged

# Before state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
# }
# ge-0/0/3 {
#    description "Ansible configured interface 3";
# }

- name: Replace device LAG configuration with provided configuration
  junipernetworks.junos.junos_lag_interfaces:
    config:
      - name: ae0
        members:
          - member: ge-0/0/1
        mode: active
    state: replaced

# After state:
# -------------
# user@junos01# show interfaces
# ge-0/0/1 {
#    description "Ansible configured interface 1";
#    ether-options {
#        802.3ad ae0;
#    }
# }
# ge-0/0/2 {
#    description "Ansible configured interface 2";
# }
# ae0 {
#    aggregated-ether-options {
#        lacp {
#            active;
#        }
#    }
# }
# ge-0/0/3 {
#    description "Ansible configured interface 3";
# }
# Using gathered
# Before state:
# ------------
#
# ansible@cm123456tr21# show interfaces
# ge-0/0/1 {
#     ether-options {
#         802.3ad ae1;
#     }
# }
# ge-0/0/2 {
#     ether-options {
#         802.3ad ae1;
#     }
# }
# ge-0/0/3 {
#     ether-options {
#         802.3ad {
#             ae2;
#             primary;
#         }
#     }
# }
# ge-0/0/4 {
#     ether-options {
#         802.3ad {
#             ae2;
#             backup;
#         }
#     }
# }
# ge-1/0/0 {
#     unit 0 {
#         family inet {
#             address 192.168.100.1/24;
#             address 10.200.16.20/24;
#         }
#         family inet6;
#     }
# }
# ge-2/0/0 {
#     unit 0 {
#         family inet {
#             address 192.168.100.2/24;
#             address 10.200.16.21/24;
#         }
#         family inet6;
#     }
# }
# ge-3/0/0 {
#     unit 0 {
#         family inet {
#             address 192.168.100.3/24;
#             address 10.200.16.22/24;
#         }
#         family inet6;
#     }
# }
# ae1 {
#     description "Configured by Ansible";
#     aggregated-ether-options {
#         lacp {
#             active;
#         }
#     }
# }
# ae2 {
#     description "Configured by Ansible";
#     aggregated-ether-options {
#         link-protection;
#         lacp {
#             passive;
#         }
#     }
# }
# em1 {
#     description TEST;
# }
# fxp0 {
#     description ANSIBLE;
#     speed 1g;
#     link-mode automatic;
#     unit 0 {
#         family inet {
#             address 10.8.38.38/24;
#         }
#     }
# }
- name: Gather junos lag interfaces as in given arguments
  junipernetworks.junos.junos_lag_interfaces:
    state: gathered
# Task Output (redacted)
# -----------------------
#
# "gathered": [
#         {
#             "members": [
#                 {
#                     "member": "ge-0/0/1"
#                 },
#                 {
#                     "member": "ge-0/0/2"
#                 }
#             ],
#             "mode": "active",
#             "name": "ae1"
#         },
#         {
#             "link_protection": true,
#             "members": [
#                 {
#                     "link_type": "primary",
#                     "member": "ge-0/0/3"
#                 },
#                 {
#                     "link_type": "backup",
#                     "member": "ge-0/0/4"
#                 }
#             ],
#             "mode": "passive",
#             "name": "ae2"
#         }
#     ]
# After state:
# ------------
#
# ansible@cm123456tr21# show interfaces
# ge-0/0/1 {
#     ether-options {
#         802.3ad ae1;
#     }
# }
# ge-0/0/2 {
#     ether-options {
#         802.3ad ae1;
#     }
# }
# ge-0/0/3 {
#     ether-options {
#         802.3ad {
#             ae2;
#             primary;
#         }
#     }
# }
# ge-0/0/4 {
#     ether-options {
#         802.3ad {
#             ae2;
#             backup;
#         }
#     }
# }
# ge-1/0/0 {
#     unit 0 {
#         family inet {
#             address 192.168.100.1/24;
#             address 10.200.16.20/24;
#         }
#         family inet6;
#     }
# }
# ge-2/0/0 {
#     unit 0 {
#         family inet {
#             address 192.168.100.2/24;
#             address 10.200.16.21/24;
#         }
#         family inet6;
#     }
# }
# ge-3/0/0 {
#     unit 0 {
#         family inet {
#             address 192.168.100.3/24;
#             address 10.200.16.22/24;
#         }
#         family inet6;
#     }
# }
# ae1 {
#     description "Configured by Ansible";
#     aggregated-ether-options {
#         lacp {
#             active;
#         }
#     }
# }
# ae2 {
#     description "Configured by Ansible";
#     aggregated-ether-options {
#         link-protection;
#         lacp {
#             passive;
#         }
#     }
# }
# em1 {
#     description TEST;
# }
# fxp0 {
#     description ANSIBLE;
#     speed 1g;
#     link-mode automatic;
#     unit 0 {
#         family inet {
#             address 10.8.38.38/24;
#         }
#     }
# }
# Using parsed
# parsed.cfg
# ------------
#
# <?xml version="1.0" encoding="UTF-8"?>
# <rpc-reply message-id="urn:uuid:0cadb4e8-5bba-47f4-986e-72906227007f">
#     <configuration changed-seconds="1590139550" changed-localtime="2020-05-22 09:25:50 UTC">
# <interfaces>
#         <interface>
#             <name>ge-0/0/1</name>
#             <ether-options>
#                 <ieee-802.3ad>
#                     <bundle>ae1</bundle>
#                 </ieee-802.3ad>
#             </ether-options>
#         </interface>
#         <interface>
#             <name>ge-0/0/2</name>
#             <ether-options>
#                 <ieee-802.3ad>
#                     <bundle>ae1</bundle>
#                 </ieee-802.3ad>
#             </ether-options>
#         </interface>
#         <interface>
#             <name>ge-0/0/3</name>
#             <ether-options>
#                 <ieee-802.3ad>
#                     <bundle>ae2</bundle>
#                     <primary/>
#                 </ieee-802.3ad>
#             </ether-options>
#         </interface>
#         <interface>
#             <name>ge-0/0/4</name>
#             <ether-options>
#                 <ieee-802.3ad>
#                     <bundle>ae2</bundle>
#                     <backup/>
#                 </ieee-802.3ad>
#             </ether-options>
#         </interface>
#         <interface>
#             <name>ge-1/0/0</name>
#             <unit>
#                 <name>0</name>
#                 <family>
#                     <inet>
#                         <address>
#                             <name>192.168.100.1/24</name>
#                         </address>
#                         <address>
#                             <name>10.200.16.20/24</name>
#                         </address>
#                     </inet>
#                     <inet6>
#                     </inet6>
#                 </family>
#             </unit>
#         </interface>
#         <interface>
#             <name>ge-2/0/0</name>
#             <unit>
#                 <name>0</name>
#                 <family>
#                     <inet>
#                         <address>
#                             <name>192.168.100.2/24</name>
#                         </address>
#                         <address>
#                             <name>10.200.16.21/24</name>
#                         </address>
#                     </inet>
#                     <inet6>
#                     </inet6>
#                 </family>
#             </unit>
#         </interface>
#         <interface>
#             <name>ge-3/0/0</name>
#             <unit>
#                 <name>0</name>
#                 <family>
#                     <inet>
#                         <address>
#                             <name>192.168.100.3/24</name>
#                         </address>
#                         <address>
#                             <name>10.200.16.22/24</name>
#                         </address>
#                     </inet>
#                     <inet6>
#                     </inet6>
#                 </family>
#             </unit>
#         </interface>
#         <interface>
#             <name>ae1</name>
#             <description>Configured by Ansible</description>
#             <aggregated-ether-options>
#                 <lacp>
#                     <active/>
#                 </lacp>
#             </aggregated-ether-options>
#         </interface>
#         <interface>
#             <name>ae2</name>
#             <description>Configured by Ansible</description>
#             <aggregated-ether-options>
#                 <link-protection>
#                 </link-protection>
#                 <lacp>
#                     <passive/>
#                 </lacp>
#             </aggregated-ether-options>
#         </interface>
#         <interface>
#             <name>em1</name>
#             <description>TEST</description>
#         </interface>
#         <interface>
#             <name>fxp0</name>
#             <description>ANSIBLE</description>
#             <speed>1g</speed>
#             <link-mode>automatic</link-mode>
#             <unit>
#                 <name>0</name>
#                 <family>
#                     <inet>
#                         <address>
#                             <name>10.8.38.38/24</name>
#                         </address>
#                     </inet>
#                 </family>
#             </unit>
#         </interface>
#     </interfaces>
#     </configuration>
# </rpc-reply>
# - name: Convert interfaces config to argspec without connecting to the appliance
#   junipernetworks.junos.junos_lag_interfaces:
#     running_config: "{{ lookup('file', './parsed.cfg') }}"
#     state: parsed
# Task Output (redacted)
# -----------------------
# "parsed": [
#         {
#             "members": [
#                 {
#                     "member": "ge-0/0/1"
#                 },
#                 {
#                     "member": "ge-0/0/2"
#                 }
#             ],
#             "mode": "active",
#             "name": "ae1"
#         },
#         {
#             "link_protection": true,
#             "members": [
#                 {
#                     "link_type": "primary",
#                     "member": "ge-0/0/3"
#                 },
#                 {
#                     "link_type": "backup",
#                     "member": "ge-0/0/4"
#                 }
#             ],
#             "mode": "passive",
#             "name": "ae2"
#         }
#     ]
# Using rendered
- name: Render platform specific xml from task input using rendered state
  junipernetworks.junos.junos_lag_interfaces:
    config:
      - name: ae1
        members:
          - member: ge-0/0/1
          - member: ge-0/0/2
        mode: active

      - name: ae2
        link_protection: true
        members:
          - member: ge-0/0/3
            link_type: primary
          - member: ge-0/0/4
            link_type: backup
        mode: passive
# Task Output (redacted)
# -----------------------
# "rendered": "<nc:interfaces
#     xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
#     <nc:interface>
#         <nc:name>ae1</nc:name>
#         <nc:aggregated-ether-options>
#             <nc:lacp>
#                 <nc:active/>
#             </nc:lacp>
#         </nc:aggregated-ether-options>
#     </nc:interface>
#     <nc:interface>
#         <nc:name>ge-0/0/1</nc:name>
#         <nc:ether-options>
#             <nc:ieee-802.3ad>
#                 <nc:bundle>ae1</nc:bundle>
#             </nc:ieee-802.3ad>
#         </nc:ether-options>
#     </nc:interface>
#     <nc:interface>
#         <nc:name>ge-0/0/2</nc:name>
#         <nc:ether-options>
#             <nc:ieee-802.3ad>
#                 <nc:bundle>ae1</nc:bundle>
#             </nc:ieee-802.3ad>
#         </nc:ether-options>
#     </nc:interface>
#     <nc:interface>
#         <nc:name>ae2</nc:name>
#         <nc:aggregated-ether-options>
#             <nc:lacp>
#                 <nc:passive/>
#             </nc:lacp>
#             <nc:link-protection/>
#         </nc:aggregated-ether-options>
#     </nc:interface>
#     <nc:interface>
#         <nc:name>ge-0/0/3</nc:name>
#         <nc:ether-options>
#             <nc:ieee-802.3ad>
#                 <nc:bundle>ae2</nc:bundle>
#                 <nc:primary/>
#             </nc:ieee-802.3ad>
#         </nc:ether-options>
#     </nc:interface>
#     <nc:interface>
#         <nc:name>ge-0/0/4</nc:name>
#         <nc:ether-options>
#             <nc:ieee-802.3ad>
#                 <nc:bundle>ae2</nc:bundle>
#                 <nc:backup/>
#             </nc:ieee-802.3ad>
#         </nc:ether-options>
#     </nc:interface>
# </nc:interfaces>"

返回值

此处记录了常见的返回值 此处,以下是此模块独有的字段

键

描述

after

列表 / 元素=字符串

模块完成后的配置作为结构化数据。

返回:已更改时

示例: ["The configuration returned will always be in the same format\n of the parameters above.\n"]

before

列表 / 元素=字符串

模块调用之前的配置作为结构化数据。

返回:始终返回

示例: ["The configuration returned will always be in the same format\n of the parameters above.\n"]

xml

列表 / 元素=字符串

推送到远程设备的 xml rpc 有效负载集。

返回:始终返回

示例: ["<nc:interfaces xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> <nc:interface> <nc:name>ae1</nc:name> <nc:aggregated-ether-options> <nc:lacp> <nc:active/> </nc:lacp> </nc:aggregated-ether-options> </nc:interface> <nc:interface> <nc:name>ge-0/0/1</nc:name> <nc:ether-options> <nc:ieee-802.3ad> <nc:bundle>ae1</nc:bundle> </nc:ieee-802.3ad> </nc:ether-options> </nc:interface> <nc:interface> <nc:name>ge-0/0/2</nc:name> <nc:ether-options> <nc:ieee-802.3ad> <nc:bundle>ae1</nc:bundle> </nc:ieee-802.3ad> </nc:ether-options> </nc:interface> <nc:interface> <nc:name>ae2</nc:name> <nc:aggregated-ether-options> <nc:lacp> <nc:passive/> </nc:lacp> <nc:link-protection/> </nc:aggregated-ether-options> </nc:interface> <nc:interface> <nc:name>ge-0/0/3</nc:name> <nc:ether-options> <nc:ieee-802.3ad> <nc:bundle>ae2</nc:bundle> <nc:primary/> </nc:ieee-802.3ad> </nc:ether-options> </nc:interface> <nc:interface> <nc:name>ge-0/0/4</nc:name> <nc:ether-options> <nc:ieee-802.3ad> <nc:bundle>ae2</nc:bundle> <nc:backup/> </nc:ieee-802.3ad> </nc:ether-options> </nc:interface> </nc:interfaces>", "xml 2", "xml 3"]

作者

  • Ganesh Nalawade (@ganeshrn)

资源链接

  • 问题追踪器
  • 代码仓库
上一页 下一页

© 版权所有 Ansible 项目贡献者。 上次更新于 2024年12月19日。