community.network.ig_config 模块 – 管理 Ingate SBC 上的配置数据库。

注意

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

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

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

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

注意

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

已弃用

移除于:

6.0.0 版本

原因:

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

替代方案:

未知。

概要

  • 管理 Ingate SBC 上的配置数据库。

别名:network.ingate.ig_config

要求

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

  • ingatesdk >= 1.0.6

参数

参数

注释

add

布尔值

向表中添加一行。

选项

  • false

  • true

client

字符串

包含连接详细信息的字典对象。

address

字符串 / 必需

设备的主机名或 IP 地址。

password

字符串 / 必需

REST API 用户的密码。

port

整数

要连接到的 HTTP(S) 端口。

scheme

字符串 / 必需

要使用的 HTTP 协议。

选项

  • "http"

  • "https"

timeout

整数

REST API 请求的超时时间(以秒为单位)。

username

字符串 / 必需

REST API 用户的用户名。

validate_certs

别名:verify_ssl

布尔值

验证设备的 HTTPS 证书。

选项

  • false

  • true ← (默认)

version

字符串

REST API 版本。

选项

  • "v1" ← (默认)

columns

字符串

包含列名/值的字典。

delete

布尔值

删除表中的所有行或特定行。

选项

  • false

  • true

download

布尔值

从设备下载配置数据库。

选项

  • false

  • true

factory

布尔值

将初步配置重置为其出厂默认值。

选项

  • false

  • true

filename

字符串

用于存储下载的配置的文件名。请参考 download 选项。

get

布尔值

返回表中的所有行或特定行。

选项

  • false

  • true

modify

布尔值

修改表中的一行。

选项

  • false

  • true

no_response

布尔值

存储初步配置时不希望有响应。请参考 store 选项。

选项

  • false ← (默认)

  • true

path

字符串

在文件系统中存储下载的配置的位置。请参考 download 选项。

return_rowid

布尔值

获取表中列匹配的 rowid。

选项

  • false

  • true

revert

布尔值

重置初步配置。

选项

  • false

  • true

rowid

整数

行 ID。

store

布尔值

存储初步配置。

选项

  • false

  • true

store_download

布尔值

是否应将下载的配置存储在磁盘上。请参考 download 选项。

选项

  • false ← (默认)

  • true

table

字符串

表名。

注释

注意

  • 如果 store_download 设置为 True,并且省略了 pathfilename,则文件将使用自动文件名存储在当前目录中。

  • 此模块要求在主机上安装 Ingate Python SDK。要安装 SDK,请在 shell 中使用 pip 命令 pip install ingatesdk

示例

- name: Add/remove DNS servers
  hosts: 192.168.1.1
  connection: local
  vars:
    client_rw:
      version: v1
      address: "{{ inventory_hostname }}"
      scheme: http
      username: alice
      password: foobar
  tasks:

  - name: Load factory defaults
    community.network.ig_config:
      client: "{{ client_rw }}"
      factory: true
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Revert to last known applied configuration
    community.network.ig_config:
      client: "{{ client_rw }}"
      revert: true
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Change the unit name
    community.network.ig_config:
      client: "{{ client_rw }}"
      modify: true
      table: misc.unitname
      columns:
        unitname: "Test Ansible"
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Add a DNS server
    community.network.ig_config:
      client: "{{ client_rw }}"
      add: true
      table: misc.dns_servers
      columns:
        server: 192.168.1.21
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Add a DNS server
    community.network.ig_config:
      client: "{{ client_rw }}"
      add: true
      table: misc.dns_servers
      columns:
        server: 192.168.1.22
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Add a DNS server
    community.network.ig_config:
      client: "{{ client_rw }}"
      add: true
      table: misc.dns_servers
      columns:
        server: 192.168.1.23
    register: last_dns
  - ansible.builtin.debug:
      var: last_dns

  - name: Modify the last added DNS server
    community.network.ig_config:
      client: "{{ client_rw }}"
      modify: true
      table: misc.dns_servers
      rowid: "{{ last_dns['add'][0]['id'] }}"
      columns:
        server: 192.168.1.24
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Return the last added DNS server
    community.network.ig_config:
      client: "{{ client_rw }}"
      get: true
      table: misc.dns_servers
      rowid: "{{ last_dns['add'][0]['id'] }}"
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Remove last added DNS server
    community.network.ig_config:
      client: "{{ client_rw }}"
      delete: true
      table: misc.dns_servers
      rowid: "{{ last_dns['add'][0]['id'] }}"
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Return the all rows from table misc.dns_servers
    community.network.ig_config:
      client: "{{ client_rw }}"
      get: true
      table: misc.dns_servers
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Remove remaining DNS servers
    community.network.ig_config:
      client: "{{ client_rw }}"
      delete: true
      table: misc.dns_servers
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Get rowid for interface eth0
    community.network.ig_config:
      client: "{{ client_rw }}"
      return_rowid: true
      table: network.local_nets
      columns:
        interface: eth0
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Store the preliminary configuration
    community.network.ig_config:
      client: "{{ client_rw }}"
      store: true
    register: result
  - ansible.builtin.debug:
      var: result

  - name: Do backup of the configuration database
    community.network.ig_config:
      client: "{{ client_rw }}"
      download: true
      store_download: true
    register: result
  - ansible.builtin.debug:
      var: result

返回值

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

描述

add

复杂类型

包含有关已添加行的信息的列表

返回:add 为 yes 且成功时

data

复杂类型

列名/值

返回:成功

示例: {"number": "2", "server": "10.48.254.33"}

href

字符串

已添加行的 REST API URL

返回:成功

示例: "http://192.168.1.1/api/v1/misc/dns_servers/2"

id

整数

行 ID

返回:成功

示例: 22

delete

复杂类型

包含有关已删除行信息的列表

返回:delete 为 yes 且成功时

data

复杂类型

列名/值

返回:成功

示例: {"number": "2", "server": "10.48.254.33"}

id

整数

行 ID

返回:成功

示例: 22

table

字符串

表名

返回:成功

示例: "misc.dns_servers"

download

复杂类型

配置数据库和元数据

返回:download 为 yes 且成功时

config

字符串

配置数据库

返回:成功

filename

字符串

建议的配置名称

返回:成功

示例: "testname_2018-10-01T214040.cfg"

mimetype

字符串

MIME 类型

返回:成功

示例: "application/x-config-database"

factory

复杂类型

命令状态消息

返回:factory 为 yes 且成功时

msg

字符串

命令状态消息

返回:成功

示例: "已将配置恢复为出厂配置。"

get

复杂类型

包含有关行信息的列表

返回:get 为 yes 且成功时

data

复杂类型

列名/值

返回:成功

示例: {"number": "2", "server": "10.48.254.33"}

href

字符串

指向行的 REST API URL

返回:成功

示例: "http://192.168.1.1/api/v1/misc/dns_servers/1"

id

整数

行 ID

返回:成功

示例: 1

table

字符串

表名

返回:成功

示例: "Testname"

modify

复杂类型

包含有关已修改行信息的列表

返回:modify 为 yes 且成功时

data

复杂类型

列名/值

返回:成功

示例: {"number": "2", "server": "10.48.254.33"}

href

字符串

指向已修改行的 REST API URL

返回:成功

示例: "http://192.168.1.1/api/v1/misc/dns_servers/1"

id

整数

行 ID

返回:成功

示例: 10

table

字符串

表名

返回:成功

示例: "Testname"

return_rowid

列表 / 元素=字符串

匹配的行 ID。

返回:return_rowid 为 yes 且成功时

示例: [1, 3]

revert

复杂类型

命令状态消息

返回:revert 为 yes 且成功时

msg

字符串

命令状态消息

返回:成功

示例: "已将配置恢复为上次应用的配置。"

store

复杂类型

命令状态消息

返回:store 为 yes 且成功时

msg

字符串

命令状态消息

返回:成功

示例: "已成功应用并保存配置。"

状态

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

  • 更多信息请参见 已弃用

作者

  • Ingate Systems AB (@ingatesystems)