community.network.icx_config 模块 – 管理 Ruckus ICX 7000 系列交换机的配置部分

注意

此模块是 community.network 集合(版本 5.1.0)的一部分。

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

要安装它,请使用:ansible-galaxy collection install community.network

要在 playbook 中使用它,请指定:community.network.icx_config

注意

community.network 集合已弃用,并将从 Ansible 12 中删除。有关详细信息,请参阅讨论主题

已弃用

在以下版本中删除:

版本 6.0.0

原因:

此集合及其中的所有内容均未维护且已弃用。

替代方案:

未知。

概要

  • Ruckus ICX 配置使用简单的块缩进文件语法将配置分段。此模块提供了一种以确定性方式处理 ICX 配置部分的方法。

别名:network.icx.icx_config

参数

参数

注释

after

列表 / 元素=字符串

如果需要进行更改,则要追加到命令堆栈末尾的有序命令集。就像使用 *before* 一样,这允许 playbook 设计者追加一组命令,以便在命令集之后执行。

backup

布尔值

此参数将使模块在进行任何更改之前,从远程设备创建当前 running-config 的完整备份。备份文件写入 playbook 根目录或角色根目录中的 backup 文件夹(如果 playbook 是 ansible 角色的一部分)。如果该目录不存在,则会创建它。

选项

  • false ←(默认)

  • true

before

列表 / 元素=字符串

如果需要进行更改,则要推送到命令堆栈的有序命令集。这允许 playbook 设计者有机会在推送任何更改之前执行配置命令,而不会影响命令集与系统匹配的方式。

defaults

布尔值

此参数指定在获取远程设备运行配置时是否收集所有默认值。启用后,模块将通过发出命令 show running-config all 来获取当前配置。

选项

  • false ←(默认)

  • true

diff_against

字符串

当使用 ansible-playbook --diff 命令行参数时,该模块可以生成针对不同源的差异。

当此选项配置为 *startup* 时,该模块将返回运行配置与配置的差异。

当此选项配置为 *intended* 时,该模块将返回运行配置与 intended_config 参数中提供的配置之间的差异。

当此选项配置为 *running* 时,该模块将返回对设备配置所做的任何更改的运行配置的前后差异。

选项

  • "running"

  • "startup"

  • "intended"

diff_ignore_lines

列表 / 元素=字符串

使用此参数指定在差异期间应忽略的一行或多行。这用于配置中由系统自动更新的行。此参数采用正则表达式或精确行匹配列表。

intended_config

字符串

intended_config 提供节点应符合的主配置,并用于检查最终运行配置。此参数不会修改远程设备上的任何设置,并且严格用于检查当前设备的配置是否符合要求。指定此参数时,该任务还应修改 diff_against 值并将其设置为 *intended*。

lines

别名: commands

列表 / 元素=字符串

应在部分中配置的有序命令集。这些命令必须与设备运行配置中找到的命令完全相同。请务必注意配置命令语法,因为某些命令会自动被设备配置解析器修改。

match

字符串

指示模块如何执行当前设备配置中命令集的匹配。如果匹配设置为 *line*,则命令按行匹配。如果匹配设置为 *strict*,则命令行的匹配会考虑位置。如果匹配设置为 *exact*,则命令行必须是相等的匹配。最后,如果匹配设置为 *none*,则模块将不会尝试将源配置与远程设备上的运行配置进行比较。

选项

  • "line" ←(默认)

  • "strict"

  • "exact"

  • "none"

multiline_delimiter

字符串

当将多行配置元素推送到 ICX 设备时,将使用此参数。它指定用作定界字符的字符。这仅适用于配置操作。

默认值: "@"

父级

列表 / 元素=字符串

用于唯一标识命令所要检查的区段或层级的父级有序集合。如果省略 `parents` 参数,则将针对顶级或全局命令集检查这些命令。

替换

字符串

指示模块如何在设备上执行配置。如果 `replace` 参数设置为 *line*,则修改后的行将在配置模式下推送到设备。如果 `replace` 参数设置为 *block*,则如果任何行不正确,整个命令块将在配置模式下推送到设备。

选项

  • "line" ←(默认)

  • "block"

running_config

别名: config

字符串

默认情况下,该模块将连接到远程设备并检索当前的运行配置,以用作与源内容进行比较的基础。有时,不希望任务为剧本中的每个任务获取当前的运行配置。`running_config` 参数允许实现者传入配置,用作比较的基础配置。

save_when

字符串

当对设备运行配置进行更改时,默认情况下,这些更改不会复制到非易失性存储。使用此参数将在之前更改此行为。如果参数设置为 *always*,则运行配置将始终复制到启动配置,并且 *modified* 标志将始终设置为 True。如果参数设置为 *modified*,则只有自上次保存到配置以来运行配置发生更改时,才将其复制到启动配置。如果参数设置为 *never*,则运行配置将永远不会复制到配置。如果参数设置为 *changed*,则只有在任务进行了更改时,运行配置才会复制到配置。

选项

  • "always"

  • "never" ← (默认)

  • "modified"

  • "changed"

src

字符串

指定包含要加载的配置或配置模板的源文件路径。源文件的路径可以是 Ansible 控制主机上的完整路径,也可以是剧本或角色根目录的相对路径。此参数与 `lines`、`parents` 互斥。

注释

注意

示例

- name: Configure top level configuration
  community.network.icx_config:
    lines: hostname {{ inventory_hostname }}

- name: Configure interface settings
  community.network.icx_config:
    lines:
      - port-name test string
      - ip address 172.31.1.1 255.255.255.0
    parents: interface ethernet 1/1/2

- name: Configure ip helpers on multiple interfaces
  community.network.icx_config:
    lines:
      - ip helper-address 172.26.1.10
      - ip helper-address 172.26.3.8
    parents: "{{ item }}"
  with_items:
    - interface ethernet 1/1/2
    - interface ethernet 1/1/3

- name: Load new acl into device
  community.network.icx_config:
    lines:
      - permit ip host 192.0.2.1 any log
      - permit ip host 192.0.2.2 any log
      - permit ip host 192.0.2.3 any log
      - permit ip host 192.0.2.4 any log
    parents: ip access-list extended test
    before: no ip access-list extended test
    match: exact

- name: Check the running-config against master config
  community.network.icx_config:
    diff_against: intended
    intended_config: "{{ lookup('file', 'master.cfg') }}"

- name: Check the configuration against the running-config
  community.network.icx_config:
    diff_against: startup
    diff_ignore_lines:
      - ntp clock .*

- name: For idempotency, use full-form commands
  community.network.icx_config:
    lines:
      # - en
      - enable
    # parents: int eth1/0/11
    parents: interface ethernet 1/1/2

# Set boot image based on comparison to a group_var (version) and the version
# that is returned from the `icx_facts` module
- name: SETTING BOOT IMAGE
  community.network.icx_config:
    lines:
      - no boot system
      - boot system flash bootflash:{{new_image}}
    host: "{{ inventory_hostname }}"
  when: ansible_net_version != version

- name: Render template onto an ICX device
  community.network.icx_config:
    backup: true
    src: "{{ lookup('file', 'config.j2') }}"

返回值

常用的返回值已在此处记录这里,以下是此模块特有的字段

描述

backup_path

字符串

备份文件的完整路径

返回: 当 backup 为 yes 时

示例: "/playbooks/ansible/backup/icx_config.2016-07-16@22:28:34"

commands

列表 / 元素=字符串

将推送到远程设备的命令集

返回: 始终

示例: ["hostname foo", "router ospf 1", "router-id 192.0.2.1"]

updates

列表 / 元素=字符串

将推送到远程设备的命令集

返回: 始终

示例: ["hostname foo", "router ospf 1", "router-id 192.0.2.1"]

状态

  • 此模块将在 6.0.0 版本中删除。 *[已弃用]*

  • 有关详细信息,请参阅已弃用

作者

  • Ruckus Wireless (@Commscope)