Debian Codegraph @

ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_server.py

raw symbols SCIP
1 #!/usr/bin/python
2 # Copyright (c) 2018-2019 Red Hat, Inc.
3 # Copyright (c) 2020 Infoblox, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import absolute_import, division, print_function
7 __metaclass__ = type
8
9 DOCUMENTATION = '''
10 ---
11 module: nios_dtc_server
12 author: "Mauricio Teixeira (@badnetmask)"
13 short_description: Configure Infoblox NIOS DTC Server
14 version_added: "1.1.0"
15 description:
16 - Adds and/or removes instances of DTC Server objects from
17 Infoblox NIOS servers. This module manages NIOS C(dtc:server) objects
18 using the Infoblox WAPI interface over REST.
19 requirements:
20 - infoblox-client
21 extends_documentation_fragment: infoblox.nios_modules.nios
22 notes:
23 - This module supports C(check_mode).
24 options:
25 name:
26 description:
27 - Specifies the DTC Server display name
28 required: true
29 type: str
30 host:
31 description:
32 - Configures the IP address (A response) or FQDN (CNAME response)
33 of the server
34 required: true
35 type: str
36 disable:
37 description:
38 - Determines whether the DTC Server is disabled or not.
39 When this is set to False, the fixed address is enabled.
40 required: false
41 type: bool
42 default: False
43 extattrs:
44 description:
45 - Allows for the configuration of Extensible Attributes on the
46 instance of the object. This argument accepts a set of key / value
47 pairs for configuration.
48 type: dict
49 comment:
50 description:
51 - Configures a text string comment to be associated with the instance
52 of this object. The provided text string will be configured on the
53 object instance.
54 type: str
55 state:
56 description:
57 - Configures the intended state of the instance of the object on
58 the NIOS server. When this value is set to C(present), the object
59 is configured on the device and when this value is set to C(absent)
60 the value is removed (if necessary) from the device.
61 default: present
62 choices:
63 - present
64 - absent
65 type: str
66 '''
67
68 EXAMPLES = '''
69 - name: Configure a DTC Server
70 infoblox.nios_modules.nios_dtc_server:
71 name: a.example.com
72 host: 192.168.10.1
73 state: present
74 provider:
75 host: "{{ inventory_hostname_short }}"
76 username: admin
77 password: admin
78 connection: local
79
80 - name: Add a comment to a DTC server
81 infoblox.nios_modules.nios_dtc_server:
82 name: a.example.com
83 host: 192.168.10.1
84 comment: this is a test comment
85 state: present
86 provider:
87 host: "{{ inventory_hostname_short }}"
88 username: admin
89 password: admin
90 connection: local
91
92 - name: Remove a DTC Server from the system
93 infoblox.nios_modules.nios_dtc_server:
94 name: a.example.com
95 host: 192.168.10.1
96 state: absent
97 provider:
98 host: "{{ inventory_hostname_short }}"
99 username: admin
100 password: admin
101 connection: local
102 '''
103
104 RETURN = ''' # '''
105
106 from ansible.module_utils.basic import AnsibleModule
107 from ..module_utils.api import WapiModule
108 from ..module_utils.api import NIOS_DTC_SERVER
109 from ..module_utils.api import normalize_ib_spec
110
111
112 def main():
113 ''' Main entry point for module execution
114 '''
115
116 ib_spec = dict(
117 name=dict(required=True, ib_req=True),
118 host=dict(required=True, ib_req=True),
119
120 disable=dict(type='bool', default=False),
121 extattrs=dict(type='dict'),
122 comment=dict(),
123 )
124
125 argument_spec = dict(
126 provider=dict(required=True),
127 state=dict(default='present', choices=['present', 'absent'])
128 )
129
130 argument_spec.update(normalize_ib_spec(ib_spec))
131 argument_spec.update(WapiModule.provider_spec)
132
133 module = AnsibleModule(argument_spec=argument_spec,
134 supports_check_mode=True)
135
136 wapi = WapiModule(module)
137 result = wapi.run(NIOS_DTC_SERVER, ib_spec)
138
139 module.exit_json(**result)
140
141
142 if __name__ == '__main__':
143 main()