| 1 |
|
| 2 |
c |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
from __future__ import absolute_import, division, print_function |
| 9 |
__metaclass__ = type |
| 10 |
|
| 11 |
DOCUMENTATION = ''' |
| 12 |
--- |
| 13 |
module: nios_nsgroup_forwardingmember |
| 14 |
short_description: Configure Infoblox DNS Nameserver Forwarding Member Groups |
| 15 |
extends_documentation_fragment: infoblox.nios_modules.nios |
| 16 |
author: |
| 17 |
- Mauricio Teixeira (@badnetmask) |
| 18 |
version_added: "1.7.0" |
| 19 |
description: |
| 20 |
- Adds and/or removes nameserver groups of type "Forwarding Member" from Infoblox NIOS servers. |
| 21 |
This module manages NIOS C(nsgroup:forwardstubserver) objects using the Infoblox. WAPI interface over REST. |
| 22 |
requirements: |
| 23 |
- infoblox_client |
| 24 |
options: |
| 25 |
name: |
| 26 |
description: |
| 27 |
- Specifies the name of the NIOS nameserver group to be managed. |
| 28 |
required: true |
| 29 |
type: str |
| 30 |
forwarding_servers: |
| 31 |
description: |
| 32 |
- Specifies the list of forwarding member servers to be used |
| 33 |
required: true |
| 34 |
type: list |
| 35 |
elements: dict |
| 36 |
suboptions: |
| 37 |
name: |
| 38 |
description: |
| 39 |
- The name of the forwarding grid member in FQDN format |
| 40 |
required: true |
| 41 |
type: str |
| 42 |
forwarders_only: |
| 43 |
description: |
| 44 |
- Determines if the appliance sends queries to forwarders only, and not to other internal or Internet root servers. |
| 45 |
required: false |
| 46 |
type: bool |
| 47 |
default: false |
| 48 |
use_override_forwarders: |
| 49 |
description: |
| 50 |
- When using c(forward_to) option, and this is set to C(True), only the defined custom forwarders will be used (no recurse to root nameservers). |
| 51 |
required: false |
| 52 |
type: bool |
| 53 |
default: false |
| 54 |
forward_to: |
| 55 |
description: |
| 56 |
- The information for the remote name server to which you want the Infoblox appliance to forward queries for a specified domain name. |
| 57 |
required: false |
| 58 |
type: list |
| 59 |
default: [] |
| 60 |
elements: dict |
| 61 |
suboptions: |
| 62 |
name: |
| 63 |
description: |
| 64 |
- Provide the name of the server |
| 65 |
required: true |
| 66 |
type: str |
| 67 |
address: |
| 68 |
description: |
| 69 |
- Provide the IP address of the server |
| 70 |
required: true |
| 71 |
type: str |
| 72 |
extattrs: |
| 73 |
description: |
| 74 |
- Allows for the configuration of Extensible Attributes on the |
| 75 |
instance of the object. This argument accepts a set of key / value |
| 76 |
pairs for configuration. |
| 77 |
required: false |
| 78 |
type: dict |
| 79 |
comment: |
| 80 |
description: |
| 81 |
- Configures a text string comment to be associated with the instance |
| 82 |
of this object. The provided text string will be configured on the |
| 83 |
object instance. |
| 84 |
required: false |
| 85 |
type: str |
| 86 |
state: |
| 87 |
description: |
| 88 |
- Configures the intended state of the instance of the object on |
| 89 |
the NIOS server. When this value is set to C(present), the object |
| 90 |
is configured on the device and when this value is set to C(absent) |
| 91 |
the value is removed (if necessary) from the device. |
| 92 |
choices: [present, absent] |
| 93 |
default: present |
| 94 |
type: str |
| 95 |
''' |
| 96 |
|
| 97 |
EXAMPLES = ''' |
| 98 |
- name: create infoblox nameserver forwarding member group |
| 99 |
infoblox.nios_modules.nios_nsgroup_forwardingmember: |
| 100 |
name: my-forwardingmember-group |
| 101 |
comment: "this is a forwarding member nameserver group" |
| 102 |
forwarding_servers: |
| 103 |
- name: member.localdomain |
| 104 |
state: present |
| 105 |
provider: |
| 106 |
host: "{{ inventory_hostname_short }}" |
| 107 |
username: admin |
| 108 |
password: admin |
| 109 |
connection: local |
| 110 |
|
| 111 |
- name: create infoblox nameserver forwarding member group with external forwarders |
| 112 |
infoblox.nios_modules.nios_nsgroup_forwardingmember: |
| 113 |
name: my-forwardingmember-group |
| 114 |
comment: "this is a forwarding member nameserver group with external forwarders" |
| 115 |
forwarding_servers: |
| 116 |
- name: member.localdomain |
| 117 |
use_override_forwarders: true |
| 118 |
forward_to: |
| 119 |
- name: ns1 |
| 120 |
address: 192.168.10.1 |
| 121 |
state: present |
| 122 |
provider: |
| 123 |
host: "{{ inventory_hostname_short }}" |
| 124 |
username: admin |
| 125 |
password: admin |
| 126 |
connection: local |
| 127 |
''' |
| 128 |
|
| 129 |
RETURN = ''' # ''' |
| 130 |
|
| 131 |
from ansible.module_utils.basic import AnsibleModule |
| 132 |
from ..module_utils.api import WapiModule |
| 133 |
from ..module_utils.api import NIOS_NSGROUP_FORWARDINGMEMBER |
| 134 |
from ..module_utils.api import normalize_ib_spec |
| 135 |
|
| 136 |
|
| 137 |
def main(): |
| 138 |
'''entrypoint for module execution.''' |
| 139 |
|
| 140 |
argument_spec = dict( |
| 141 |
provider=dict(required=True), |
| 142 |
state=dict(default='present', choices=['present', 'absent']), |
| 143 |
) |
| 144 |
|
| 145 |
forward_to_spec = dict( |
| 146 |
name=dict(required=True), |
| 147 |
address=dict(required=True), |
| 148 |
) |
| 149 |
|
| 150 |
forwarding_servers_spec = dict( |
| 151 |
name=dict(required=True), |
| 152 |
forwarders_only=dict(type='bool', default=False), |
| 153 |
forward_to=dict(type='list', elements='dict', options=forward_to_spec, default=[], required=False), |
| 154 |
use_override_forwarders=dict(type='bool', default=False), |
| 155 |
) |
| 156 |
|
| 157 |
ib_spec = dict( |
| 158 |
name=dict(required=True, ib_req=True), |
| 159 |
forwarding_servers=dict(type='list', elements='dict', required=True, options=forwarding_servers_spec), |
| 160 |
extattrs=dict(type='dict'), |
| 161 |
comment=dict(), |
| 162 |
) |
| 163 |
|
| 164 |
argument_spec.update(normalize_ib_spec(ib_spec)) |
| 165 |
argument_spec.update(WapiModule.provider_spec) |
| 166 |
|
| 167 |
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) |
| 168 |
|
| 169 |
wapi = WapiModule(module) |
| 170 |
result = wapi.run(NIOS_NSGROUP_FORWARDINGMEMBER, ib_spec) |
| 171 |
|
| 172 |
module.exit_json(**result) |
| 173 |
|
| 174 |
|
| 175 |
if __name__ == '__main__': |
| 176 |
main() |