| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
from __future__ import absolute_import, division, print_function |
| 7 |
__metaclass__ = type |
| 8 |
|
| 9 |
DOCUMENTATION = ''' |
| 10 |
--- |
| 11 |
module: nios_dns_view |
| 12 |
author: "Peter Sprygada (@privateip)" |
| 13 |
short_description: Configure Infoblox NIOS DNS views |
| 14 |
version_added: "1.0.0" |
| 15 |
description: |
| 16 |
- Adds and/or removes instances of DNS view objects from |
| 17 |
Infoblox NIOS servers. This module manages NIOS C(view) objects |
| 18 |
using the Infoblox WAPI interface over REST. |
| 19 |
- Updates instances of DNS view object from Infoblox NIOS servers. |
| 20 |
requirements: |
| 21 |
- infoblox-client |
| 22 |
extends_documentation_fragment: infoblox.nios_modules.nios |
| 23 |
notes: |
| 24 |
- This module supports C(check_mode). |
| 25 |
options: |
| 26 |
name: |
| 27 |
description: |
| 28 |
- Specifies the fully qualified hostname to add or remove from |
| 29 |
the system. User can also update the hostname as it is possible |
| 30 |
to pass a dict containing I(new_name), I(old_name). See examples. |
| 31 |
required: true |
| 32 |
aliases: |
| 33 |
- view |
| 34 |
type: str |
| 35 |
network_view: |
| 36 |
description: |
| 37 |
- Specifies the name of the network view to assign the configured |
| 38 |
DNS view to. The network view must already be configured on the |
| 39 |
target system. |
| 40 |
default: default |
| 41 |
type: str |
| 42 |
extattrs: |
| 43 |
description: |
| 44 |
- Allows for the configuration of Extensible Attributes on the |
| 45 |
instance of the object. This argument accepts a set of key / value |
| 46 |
pairs for configuration. |
| 47 |
type: dict |
| 48 |
comment: |
| 49 |
description: |
| 50 |
- Configures a text string comment to be associated with the instance |
| 51 |
of this object. The provided text string will be configured on the |
| 52 |
object instance. |
| 53 |
type: str |
| 54 |
state: |
| 55 |
description: |
| 56 |
- Configures the intended state of the instance of the object on |
| 57 |
the NIOS server. When this value is set to C(present), the object |
| 58 |
is configured on the device and when this value is set to C(absent) |
| 59 |
the value is removed (if necessary) from the device. |
| 60 |
default: present |
| 61 |
choices: |
| 62 |
- present |
| 63 |
- absent |
| 64 |
type: str |
| 65 |
|
| 66 |
''' |
| 67 |
|
| 68 |
EXAMPLES = ''' |
| 69 |
- name: Configure a new dns view instance |
| 70 |
infoblox.nios_modules.nios_dns_view: |
| 71 |
name: ansible-dns |
| 72 |
state: present |
| 73 |
provider: |
| 74 |
host: "{{ inventory_hostname_short }}" |
| 75 |
username: admin |
| 76 |
password: admin |
| 77 |
connection: local |
| 78 |
|
| 79 |
- name: Update the comment for dns view |
| 80 |
infoblox.nios_modules.nios_dns_view: |
| 81 |
name: ansible-dns |
| 82 |
comment: this is an example comment |
| 83 |
state: present |
| 84 |
provider: |
| 85 |
host: "{{ inventory_hostname_short }}" |
| 86 |
username: admin |
| 87 |
password: admin |
| 88 |
connection: local |
| 89 |
|
| 90 |
- name: Remove the dns view instance |
| 91 |
infoblox.nios_modules.nios_dns_view: |
| 92 |
name: ansible-dns |
| 93 |
state: absent |
| 94 |
provider: |
| 95 |
host: "{{ inventory_hostname_short }}" |
| 96 |
username: admin |
| 97 |
password: admin |
| 98 |
connection: local |
| 99 |
|
| 100 |
- name: Update the dns view instance |
| 101 |
infoblox.nios_modules.nios_dns_view: |
| 102 |
name: {new_name: ansible-dns-new, old_name: ansible-dns} |
| 103 |
state: present |
| 104 |
provider: |
| 105 |
host: "{{ inventory_hostname_short }}" |
| 106 |
username: admin |
| 107 |
password: admin |
| 108 |
connection: local |
| 109 |
''' |
| 110 |
|
| 111 |
RETURN = ''' # ''' |
| 112 |
|
| 113 |
from ansible.module_utils.basic import AnsibleModule |
| 114 |
from ..module_utils.api import WapiModule |
| 115 |
from ..module_utils.api import NIOS_DNS_VIEW |
| 116 |
from ..module_utils.api import normalize_ib_spec |
| 117 |
|
| 118 |
|
| 119 |
def main(): |
| 120 |
''' Main entry point for module execution |
| 121 |
''' |
| 122 |
ib_spec = dict( |
| 123 |
name=dict(required=True, aliases=['view'], ib_req=True), |
| 124 |
network_view=dict(default='default', ib_req=True), |
| 125 |
|
| 126 |
extattrs=dict(type='dict'), |
| 127 |
comment=dict() |
| 128 |
) |
| 129 |
|
| 130 |
argument_spec = dict( |
| 131 |
provider=dict(required=True), |
| 132 |
state=dict(default='present', choices=['present', 'absent']) |
| 133 |
) |
| 134 |
|
| 135 |
argument_spec.update(normalize_ib_spec(ib_spec)) |
| 136 |
argument_spec.update(WapiModule.provider_spec) |
| 137 |
|
| 138 |
module = AnsibleModule(argument_spec=argument_spec, |
| 139 |
supports_check_mode=True) |
| 140 |
|
| 141 |
wapi = WapiModule(module) |
| 142 |
result = wapi.run(NIOS_DNS_VIEW, ib_spec) |
| 143 |
|
| 144 |
module.exit_json(**result) |
| 145 |
|
| 146 |
|
| 147 |
if __name__ == '__main__': |
| 148 |
main() |