�
�Udac @` s� d d l m Z m Z m Z e Z i d g d 6d d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
m Z y d d
l m Z e Z Wn e k
r� e Z n Xd � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functiont previewt statust communityt supported_bys 1.1t metadata_versions
---
module: ig_config
short_description: Manage the configuration database on an Ingate SBC.
description:
- Manage the configuration database on an Ingate SBC.
version_added: 2.8
extends_documentation_fragment: ingate
options:
add:
description:
- Add a row to a table.
type: bool
delete:
description:
- Delete all rows in a table or a specific row.
type: bool
get:
description:
- Return 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
factory:
description:
- Reset the preliminary configuration to its factory defaults.
type: bool
store:
description:
- Store the preliminary configuration.
type: bool
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
download:
description:
- Download the configuration database from the unit.
type: bool
store_download:
description:
- If the downloaded configuration should be stored on disk.
Refer to the C(download) option.
type: bool
default: false
path:
description:
- Where in the filesystem to store the downloaded configuration.
Refer to the C(download) option.
filename:
description:
- The name of the file to store the downloaded configuration in.
Refer to the C(download) option.
table:
description:
- The name of the table.
rowid:
description:
- A row id.
type: int
columns:
description:
- A dict containing column names/values.
notes:
- If C(store_download) is set to True, and C(path) and C(filename) is omitted,
the file will be stored in the current directory with an automatic filename.
author:
- Ingate Systems AB (@ingatesystems)
sI
- 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
sH
add:
description: A list containing information about the added row
returned: when C(add) is yes and success
type: complex
contains:
href:
description: The REST API URL to the added row
returned: success
type: str
sample: http://192.168.1.1/api/v1/misc/dns_servers/2
data:
description: Column names/values
returned: success
type: complex
sample: {'number': '2', 'server': '10.48.254.33'}
id:
description: The row id
returned: success
type: int
sample: 22
delete:
description: A list containing information about the deleted row(s)
returned: when C(delete) is yes and success
type: complex
contains:
table:
description: The name of the table
returned: success
type: str
sample: misc.dns_servers
data:
description: Column names/values
returned: success
type: complex
sample: {'number': '2', 'server': '10.48.254.33'}
id:
description: The row id
returned: success
type: int
sample: 22
get:
description: A list containing information about the row(s)
returned: when C(get) is yes and success
type: complex
contains:
table:
description: The name of the table
returned: success
type: str
sample: Testname
href:
description: The REST API URL to the row
returned: success
type: str
sample: http://192.168.1.1/api/v1/misc/dns_servers/1
data:
description: Column names/values
returned: success
type: complex
sample: {'number': '2', 'server': '10.48.254.33'}
id:
description: The row id
returned: success
type: int
sample: 1
modify:
description: A list containing information about the modified row
returned: when C(modify) is yes and success
type: complex
contains:
table:
description: The name of the table
returned: success
type: str
sample: Testname
href:
description: The REST API URL to the modified row
returned: success
type: str
sample: http://192.168.1.1/api/v1/misc/dns_servers/1
data:
description: Column names/values
returned: success
type: complex
sample: {'number': '2', 'server': '10.48.254.33'}
id:
description: The row id
returned: success
type: int
sample: 10
revert:
description: A command status message
returned: when C(revert) is yes and success
type: complex
contains:
msg:
description: The command status message
returned: success
type: str
sample: reverted the configuration to the last applied configuration.
factory:
description: A command status message
returned: when C(factory) is yes and success
type: complex
contains:
msg:
description: The command status message
returned: success
type: str
sample: reverted the configuration to the factory configuration.
store:
description: A command status message
returned: when C(store) is yes and success
type: complex
contains:
msg:
description: The command status message
returned: success
type: str
sample: Successfully applied and saved the configuration.
return_rowid:
description: The matched row id(s).
returned: when C(return_rowid) is yes and success
type: list
sample: [1, 3]
download:
description: Configuration database and meta data
returned: when C(download) is yes and success
type: complex
contains:
config:
description: The configuration database
returned: success
type: str
filename:
description: A suggested name for the configuration
returned: success
type: str
sample: testname_2018-10-01T214040.cfg
mimetype:
description: The mimetype
returned: success
type: str
sample: application/x-config-database
( t
AnsibleModule( t ingate_argument_spect ingate_create_client( t ingatesdkc C` s, t | j � } | j j d � rZ | j d } | j d } | j | | � } t d | f S| j j d � r� t } | j d } | j j d � } | r� | j | d | �} n | j | � } | r� t } n | d | f S| j j d � rT| j d } | j j d � } | r)| j | d | �} n | j | � } | rGt } n | d | f S| j j d � r�| j d } | j d } | j j d � } | r�| j
| d | | �} n | j | | � } | r�t } n | d | f S| j j d � r#| j � } | r| d d
} n t d | f S| j j d � re| j
� } | rX| d d } n t d | f S| j j d
� r�| j j d � } | j d | � } | r�| d d } n t d
| f S| j j d � r�| j d } | j d } | j | � } g } x� | D]} } t }
xT | j � D]F \ } } | | d k rBq n | d | | k s`t }
Pq t }
q W|
r| j | d � qqWt d | f S| j j d � r| j j d � }
| j j d � } | j j d � } | j d
|
d | d | � } | r| d d } n t d | f St d i f S( Nt addt tablet columnst deletet rowidt gett modifyt reverti s revert-editst factorys load-factoryt storet no_responses
store-editt return_rowidt datat idt downloadt store_downloadt patht filenames download-configt ( R
t paramsR t add_rowt Truet Falset
delete_rowt delete_tablet dump_rowt
dump_tablet
modify_rowt modify_single_rowt revert_editst load_factoryt
store_editt itemst appendt download_config( t modulet
api_clientR
R t responset changedR R t rowidst rowt matcht namet valueR R R ( ( sL /usr/lib/python2.7/site-packages/ansible/modules/network/ingate/ig_config.pyt make_request� s�
c
# C` sE t d t d d � d t d d � d t d d � d t d d � d t d d � d t d d � d t d d � d
t d d d t � d t d d � d
t d d � d t d d d t � d t � d t � d t � d t d d � d t d d � � } d g } d d d d d d d d d
g g } d t d d g f d t d g f d t d g f d t d d g f d t d d g f g } t d | d | d | d | d t � } t s�| j d d � n t d t � } y<