community.network.nclu 模块 – 使用 NCLU 配置网络接口
注意
此模块是 community.network 集合(版本 5.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.network
。
要在 playbook 中使用它,请指定:community.network.nclu
。
注意
community.network 集合已被弃用,将从 Ansible 12 中删除。有关更多信息,请参阅讨论主题。
已弃用
- 移除版本:
6.0.0 版本
- 原因:
此集合及其中的所有内容均未维护且已弃用。
- 替代方案:
未知。
概要
网络命令行实用程序接口,旨在更轻松地配置运行 ifupdown2 和 Quagga 的操作系统,例如 Cumulus Linux。 命令文档可在 https://docs.cumulusnetworks.com/cumulus-linux/System-Configuration/Network-Command-Line-Utility-NCLU/ 上找到
别名: network.cumulus.nclu
参数
参数 |
注释 |
---|---|
布尔值。 如果为 true,则在块之前执行“net abort”。 这会清除缓冲区中任何未提交的更改。与 atomic 互斥。 选项
|
|
如果为 true,则等同于 commit 和 abort 均为 true。与 commit 和 atomic 互斥。 选项
|
|
包含要运行的 net 命令的字符串列表。 与 template 互斥。 |
|
如果为 true,则在块的末尾执行“net commit”。与 atomic 互斥。 选项
|
|
如果 commit 或 atomic 为 true,则将记录到提交日志的提交描述。 默认值: |
|
带有 jinja2 格式的单个多行字符串。 此字符串将按行分割,每行将通过 net 运行。 与 commands 互斥。 |
注释
注意
支持 check_mode。 请注意,当使用 check_mode 时,abort 始终为 true。
示例
- name: Add two interfaces without committing any changes
community.network.nclu:
commands:
- add int swp1
- add int swp2
- name: Modify hostname to Cumulus-1 and commit the change
community.network.nclu:
commands:
- add hostname Cumulus-1
commit: true
- name: Add 48 interfaces and commit the change.
community.network.nclu:
template: |
{% for iface in range(1,49) %}
add int swp{{iface}}
{% endfor %}
commit: true
description: "Ansible - add swps1-48"
- name: Fetch Status Of Interface
community.network.nclu:
commands:
- show interface swp1
register: output
- name: Print Status Of Interface
ansible.builtin.debug:
var: output
- name: Fetch Details From All Interfaces In JSON Format
community.network.nclu:
commands:
- show interface json
register: output
- name: Print Interface Details
ansible.builtin.debug:
var: output["msg"]
- name: Atomically add an interface
community.network.nclu:
commands:
- add int swp1
atomic: true
description: "Ansible - add swp1"
- name: Remove IP address from interface swp1
community.network.nclu:
commands:
- del int swp1 ip address 1.1.1.1/24
- name: Configure BGP AS and add 2 EBGP neighbors using BGP Unnumbered
community.network.nclu:
commands:
- add bgp autonomous-system 65000
- add bgp neighbor swp51 interface remote-as external
- add bgp neighbor swp52 interface remote-as external
commit: true
- name: Configure BGP AS and Add 2 EBGP neighbors Using BGP Unnumbered via Template
community.network.nclu:
template: |
{% for neighbor in range(51,53) %}
add bgp neighbor swp{{neighbor}} interface remote-as external
add bgp autonomous-system 65000
{% endfor %}
atomic: true
- name: Check BGP Status
community.network.nclu:
commands:
- show bgp summary json
register: output
- name: Print BGP Status In JSON
ansible.builtin.debug:
var: output["msg"]
返回值
通用返回值记录在 此处,以下是此模块独有的字段
键 |
描述 |
---|---|
接口是否已更改 返回值: changed 示例: |
|
成功或失败的人类可读报告 返回值: always 示例: |
状态
此模块将在 6.0.0 版本中删除。 [已弃用]
有关更多信息,请参阅 已弃用。