community.general.ig_config (0.1.1) — module

Manage the configuration database on an Ingate SBC.

Authors: Ingate Systems AB (@ingatesystems)

preview | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Manage the configuration database on an Ingate SBC.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
    ig_config:
      client: "{{ client_rw }}"
      factory: true
    register: result
  - debug:
      var: result

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

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

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

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

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

  - name: Modify the last added DNS server
    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
  - debug:
      var: result

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

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

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

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

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

  - name: Store the preliminary configuration
    ig_config:
      client: "{{ client_rw }}"
      store: true
    register: result
  - debug:
      var: result

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

Inputs

    
add:
    description:
    - Add a row to a table.
    type: bool

get:
    description:
    - Return all rows in a table or a specific row.
    type: bool

path:
    description:
    - Where in the filesystem to store the downloaded configuration. Refer to the C(download)
      option.

rowid:
    description:
    - A row id.
    type: int

store:
    description:
    - Store the preliminary configuration.
    type: bool

table:
    description:
    - The name of the table.

client:
    description:
    - A dict object containing connection details.
    suboptions:
      address:
        description:
        - The hostname or IP address to the unit.
        required: true
        type: str
      password:
        description:
        - The password for the REST API user.
        required: true
        type: str
      port:
        description:
        - Which HTTP(S) port to connect to.
        type: int
      scheme:
        choices:
        - http
        - https
        description:
        - Which HTTP protocol to use.
        required: true
        type: str
      timeout:
        description:
        - The timeout (in seconds) for REST API requests.
        type: int
      username:
        description:
        - The username of the REST API user.
        required: true
        type: str
      validate_certs:
        aliases:
        - verify_ssl
        default: true
        description:
        - Verify the unit's HTTPS certificate.
        type: bool
      version:
        choices:
        - v1
        default: v1
        description:
        - REST API version.
        type: str

delete:
    description:
    - Delete all rows in a table or a specific row.
    type: bool

modify:
    description:
    - Modify a row in a table.
    type: bool

revert:
    description:
    - Reset the preliminary configuration.
    type: bool

columns:
    description:
    - A dict containing column names/values.

factory:
    description:
    - Reset the preliminary configuration to its factory defaults.
    type: bool

download:
    description:
    - Download the configuration database from the unit.
    type: bool

filename:
    description:
    - The name of the file to store the downloaded configuration in. Refer to the C(download)
      option.

no_response:
    description:
    - Expect no response when storing the preliminary configuration. Refer to the C(store)
      option.
    type: bool

return_rowid:
    description:
    - Get rowid(s) from a table where the columns match.
    type: bool

store_download:
    default: false
    description:
    - If the downloaded configuration should be stored on disk. Refer to the C(download)
      option.
    type: bool

Outputs

add:
  contains:
    data:
      description: Column names/values
      returned: success
      sample:
        number: '2'
        server: 10.48.254.33
      type: complex
    href:
      description: The REST API URL to the added row
      returned: success
      sample: http://192.168.1.1/api/v1/misc/dns_servers/2
      type: str
    id:
      description: The row id
      returned: success
      sample: 22
      type: int
  description: A list containing information about the added row
  returned: when C(add) is yes and success
  type: complex
delete:
  contains:
    data:
      description: Column names/values
      returned: success
      sample:
        number: '2'
        server: 10.48.254.33
      type: complex
    id:
      description: The row id
      returned: success
      sample: 22
      type: int
    table:
      description: The name of the table
      returned: success
      sample: misc.dns_servers
      type: str
  description: A list containing information about the deleted row(s)
  returned: when C(delete) is yes and success
  type: complex
download:
  contains:
    config:
      description: The configuration database
      returned: success
      type: str
    filename:
      description: A suggested name for the configuration
      returned: success
      sample: testname_2018-10-01T214040.cfg
      type: str
    mimetype:
      description: The mimetype
      returned: success
      sample: application/x-config-database
      type: str
  description: Configuration database and meta data
  returned: when C(download) is yes and success
  type: complex
factory:
  contains:
    msg:
      description: The command status message
      returned: success
      sample: reverted the configuration to the factory configuration.
      type: str
  description: A command status message
  returned: when C(factory) is yes and success
  type: complex
get:
  contains:
    data:
      description: Column names/values
      returned: success
      sample:
        number: '2'
        server: 10.48.254.33
      type: complex
    href:
      description: The REST API URL to the row
      returned: success
      sample: http://192.168.1.1/api/v1/misc/dns_servers/1
      type: str
    id:
      description: The row id
      returned: success
      sample: 1
      type: int
    table:
      description: The name of the table
      returned: success
      sample: Testname
      type: str
  description: A list containing information about the row(s)
  returned: when C(get) is yes and success
  type: complex
modify:
  contains:
    data:
      description: Column names/values
      returned: success
      sample:
        number: '2'
        server: 10.48.254.33
      type: complex
    href:
      description: The REST API URL to the modified row
      returned: success
      sample: http://192.168.1.1/api/v1/misc/dns_servers/1
      type: str
    id:
      description: The row id
      returned: success
      sample: 10
      type: int
    table:
      description: The name of the table
      returned: success
      sample: Testname
      type: str
  description: A list containing information about the modified row
  returned: when C(modify) is yes and success
  type: complex
return_rowid:
  description: The matched row id(s).
  returned: when C(return_rowid) is yes and success
  sample:
  - 1
  - 3
  type: list
revert:
  contains:
    msg:
      description: The command status message
      returned: success
      sample: reverted the configuration to the last applied configuration.
      type: str
  description: A command status message
  returned: when C(revert) is yes and success
  type: complex
store:
  contains:
    msg:
      description: The command status message
      returned: success
      sample: Successfully applied and saved the configuration.
      type: str
  description: A command status message
  returned: when C(store) is yes and success
  type: complex