| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
from __future__ import absolute_import, division, print_function |
| 7 |
__metaclass__ = type |
| 8 |
|
| 9 |
DOCUMENTATION = ''' |
| 10 |
--- |
| 11 |
module: nios_extensible_attribute |
| 12 |
author: |
| 13 |
- "Matthew Dennett (@matthewdennett)" |
| 14 |
- "Hugues Malphettes (@hmalphettes)" |
| 15 |
short_description: Configure Infoblox NIOS extensible attribute definition |
| 16 |
version_added: "1.7.0" |
| 17 |
description: |
| 18 |
- Adds and/or removes a extensible attribute definition objects from |
| 19 |
Infoblox NIOS servers. This module manages NIOS C(extensibleattributedef) |
| 20 |
objects using the Infoblox WAPI interface over REST. |
| 21 |
requirements: |
| 22 |
- infoblox-client |
| 23 |
extends_documentation_fragment: infoblox.nios_modules.nios |
| 24 |
notes: |
| 25 |
- This module supports C(check_mode). |
| 26 |
options: |
| 27 |
comment: |
| 28 |
description: |
| 29 |
- Configures a text string comment to be associated with the instance |
| 30 |
of this object. The provided text string will be configured on the |
| 31 |
object instance. |
| 32 |
type: str |
| 33 |
default_value: |
| 34 |
description: |
| 35 |
- Configures the default value which is pre populated in the GUI when |
| 36 |
this attribute is used. Email, URL and string types the value is a |
| 37 |
with a maximum of 256 characters. |
| 38 |
type: str |
| 39 |
list_values: |
| 40 |
description: |
| 41 |
- Configures a list of preset values associated with the instance of this |
| 42 |
object. Only applicable when the attribute type is set to ENUM. |
| 43 |
type: list |
| 44 |
elements: str |
| 45 |
max: |
| 46 |
description: |
| 47 |
- Configures the maximum value to be associated with the instance of |
| 48 |
this object. When provided for an extensible attribute of type |
| 49 |
STRING the value represents the maximum number of characters the string |
| 50 |
can contain. When provided for an extensible attribute of type INTEGER |
| 51 |
the value represents the maximum integer value permitted.Not |
| 52 |
applicable for other attributes types. |
| 53 |
type: int |
| 54 |
min: |
| 55 |
description: |
| 56 |
- Configures the minimum value to be associated with the instance of |
| 57 |
this object. When provided for an extensible attribute of type |
| 58 |
STRING the value represents the minimum number of characters the string |
| 59 |
can contain. When provided for an extensible attribute of type INTEGER |
| 60 |
the value represents the minimum integer value permitted. Not |
| 61 |
applicable for other attributes types. |
| 62 |
type: int |
| 63 |
name: |
| 64 |
description: |
| 65 |
- Configures the intended name of the instance of the object on the |
| 66 |
NIOS server. |
| 67 |
type: str |
| 68 |
required: true |
| 69 |
type: |
| 70 |
description: |
| 71 |
- Configures the intended type for this attribute object definition |
| 72 |
on the NIOS server. |
| 73 |
type: str |
| 74 |
default: STRING |
| 75 |
choices: |
| 76 |
- DATE |
| 77 |
- EMAIL |
| 78 |
- ENUM |
| 79 |
- INTEGER |
| 80 |
- STRING |
| 81 |
- URL |
| 82 |
flags: |
| 83 |
description: |
| 84 |
- This field contains extensible attribute flags. |
| 85 |
The possible values are (A)udited, (C)loud API, Cloud (G)master, (I)nheritable, (L)isted, (M)andatory value, |
| 86 |
MGM (P)rivate, (R)ead Only, (S)ort enum values, Multiple (V)alues. |
| 87 |
If there are two or more flags in the field, you must list them according to the order they are listed above. |
| 88 |
For example, "CR" is a valid value for the "flags" field because C = Cloud API is listed before R = Read only. |
| 89 |
However, the value "RC" is invalid because the order for the "flags" field is broken. |
| 90 |
type: str |
| 91 |
state: |
| 92 |
description: |
| 93 |
- Configures the intended state of the instance of the object on |
| 94 |
the NIOS server. When this value is set to C(present), the object |
| 95 |
is configured on the device and when this value is set to C(absent) |
| 96 |
the value is removed (if necessary) from the device. |
| 97 |
type: str |
| 98 |
default: present |
| 99 |
choices: |
| 100 |
- present |
| 101 |
- absent |
| 102 |
''' |
| 103 |
|
| 104 |
EXAMPLES = ''' |
| 105 |
- name: Configure an extensible attribute |
| 106 |
infoblox.nios_modules.nios_extensible_attribute: |
| 107 |
name: my_string |
| 108 |
type: STRING |
| 109 |
comment: Created by ansible |
| 110 |
state: present |
| 111 |
provider: |
| 112 |
host: "{{ inventory_hostname_short }}" |
| 113 |
username: admin |
| 114 |
password: admin |
| 115 |
connection: local |
| 116 |
|
| 117 |
- name: Update an extensible attribute to accept multiple values |
| 118 |
infoblox.nios_modules.nios_extensible_attribute: |
| 119 |
name: my_string |
| 120 |
type: STRING |
| 121 |
flags: V |
| 122 |
state: present |
| 123 |
provider: |
| 124 |
host: "{{ inventory_hostname_short }}" |
| 125 |
username: admin |
| 126 |
password: admin |
| 127 |
connection: local |
| 128 |
|
| 129 |
- name: Remove a extensible attribute |
| 130 |
infoblox.nios_modules.nios_extensible_attribute: |
| 131 |
name: my_string |
| 132 |
type: INTEGER |
| 133 |
state: absent |
| 134 |
provider: |
| 135 |
host: "{{ inventory_hostname_short }}" |
| 136 |
username: admin |
| 137 |
password: admin |
| 138 |
connection: local |
| 139 |
|
| 140 |
- name: Create INT extensible attribute |
| 141 |
infoblox.nios_modules.nios_extensible_attribute: |
| 142 |
name: my_int |
| 143 |
type: INTEGER |
| 144 |
comment: Created by ansible |
| 145 |
min: 10 |
| 146 |
max: 20 |
| 147 |
state: present |
| 148 |
provider: |
| 149 |
host: "{{ inventory_hostname_short }}" |
| 150 |
username: admin |
| 151 |
password: admin |
| 152 |
connection: local |
| 153 |
|
| 154 |
- name: Update an extensible attribute |
| 155 |
infoblox.nios_modules.nios_extensible_attribute: |
| 156 |
name: my_int |
| 157 |
type: INTEGER |
| 158 |
comment: Updated by ansible |
| 159 |
state: present |
| 160 |
provider: |
| 161 |
host: "{{ inventory_hostname_short }}" |
| 162 |
username: admin |
| 163 |
password: admin |
| 164 |
connection: local |
| 165 |
|
| 166 |
- name: Create an list extensible attribute |
| 167 |
infoblox.nios_modules.nios_extensible_attribute: |
| 168 |
name: my_list |
| 169 |
type: ENUM |
| 170 |
state: present |
| 171 |
list_values: |
| 172 |
- one |
| 173 |
- two |
| 174 |
- three |
| 175 |
provider: |
| 176 |
host: "{{ inventory_hostname_short }}" |
| 177 |
username: admin |
| 178 |
password: admin |
| 179 |
connection: local |
| 180 |
''' |
| 181 |
|
| 182 |
RETURN = ''' # ''' |
| 183 |
|
| 184 |
from ansible.module_utils.basic import AnsibleModule |
| 185 |
from ..module_utils.api import WapiModule |
| 186 |
from ..module_utils.api import normalize_ib_spec |
| 187 |
from ..module_utils.api import NIOS_EXTENSIBLE_ATTRIBUTE |
| 188 |
|
| 189 |
|
| 190 |
def main(): |
| 191 |
''' Main entry point for module execution |
| 192 |
''' |
| 193 |
|
| 194 |
ib_spec = dict( |
| 195 |
comment=dict(type='str'), |
| 196 |
default_value=dict(type='str'), |
| 197 |
list_values=dict(type='list', elements='str'), |
| 198 |
max=dict(type='int'), |
| 199 |
min=dict(type='int'), |
| 200 |
flags=dict(type='str'), |
| 201 |
name=dict(type='str', required=True, ib_req=True), |
| 202 |
type=dict(type='str', default='STRING', |
| 203 |
choices=['DATE', 'EMAIL', 'ENUM', 'INTEGER', 'STRING', 'URL']) |
| 204 |
) |
| 205 |
|
| 206 |
argument_spec = dict( |
| 207 |
provider=dict(required=True), |
| 208 |
state=dict(default='present', choices=['present', 'absent']) |
| 209 |
) |
| 210 |
|
| 211 |
argument_spec.update(normalize_ib_spec(ib_spec)) |
| 212 |
argument_spec.update(WapiModule.provider_spec) |
| 213 |
|
| 214 |
module = AnsibleModule(argument_spec=argument_spec, |
| 215 |
supports_check_mode=True) |
| 216 |
|
| 217 |
wapi = WapiModule(module) |
| 218 |
|
| 219 |
result = wapi.run(NIOS_EXTENSIBLE_ATTRIBUTE, ib_spec) |
| 220 |
|
| 221 |
module.exit_json(**result) |
| 222 |
|
| 223 |
|
| 224 |
if __name__ == '__main__': |
| 225 |
main() |