Debian Codegraph @

ansible_collections/infoblox/nios_modules/plugins/modules/nios_network_view.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_network_view
12 author: "Peter Sprygada (@privateip)"
13 short_description: Configure Infoblox NIOS network views
14 version_added: "1.0.0"
15 description:
16 - Adds and/or removes instances of network view objects from
17 Infoblox NIOS servers. This module manages NIOS C(networkview) objects
18 using the Infoblox WAPI interface over REST.
19 - Updates instances of network 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 type: str
32 required: true
33 aliases:
34 - network_view
35 extattrs:
36 description:
37 - Allows for the configuration of Extensible Attributes on the
38 instance of the object. This argument accepts a set of key / value
39 pairs for configuration.
40 type: dict
41 comment:
42 description:
43 - Configures a text string comment to be associated with the instance
44 of this object. The provided text string will be configured on the
45 object instance.
46 type: str
47 state:
48 description:
49 - Configures the intended state of the instance of the object on
50 the NIOS server. When this value is set to C(present), the object
51 is configured on the device and when this value is set to C(absent)
52 the value is removed (if necessary) from the device.
53 type: str
54 default: present
55 choices:
56 - present
57 - absent
58 '''
59
60 EXAMPLES = '''
61 - name: Configure a new network view
62 infoblox.nios_modules.nios_network_view:
63 name: ansible
64 state: present
65 provider:
66 host: "{{ inventory_hostname_short }}"
67 username: admin
68 password: admin
69 connection: local
70
71 - name: Update the comment for network view
72 infoblox.nios_modules.nios_network_view:
73 name: ansible
74 comment: this is an example comment
75 state: present
76 provider:
77 host: "{{ inventory_hostname_short }}"
78 username: admin
79 password: admin
80 connection: local
81
82 - name: Remove the network view
83 infoblox.nios_modules.nios_network_view:
84 name: ansible
85 state: absent
86 provider:
87 host: "{{ inventory_hostname_short }}"
88 username: admin
89 password: admin
90 connection: local
91
92 - name: Update an existing network view
93 infoblox.nios_modules.nios_network_view:
94 name: {new_name: ansible-new, old_name: ansible}
95 state: present
96 provider:
97 host: "{{ inventory_hostname_short }}"
98 username: admin
99 password: admin
100 connection: local
101 '''
102
103 RETURN = ''' # '''
104
105 from ansible.module_utils.basic import AnsibleModule
106 from ..module_utils.api import WapiModule
107 from ..module_utils.api import NIOS_NETWORK_VIEW
108 from ..module_utils.api import normalize_ib_spec
109
110
111 def main():
112 ''' Main entry point for module execution
113 '''
114 ib_spec = dict(
115 name=dict(required=True, aliases=['network_view'], ib_req=True),
116 extattrs=dict(type='dict'),
117 comment=dict(),
118 )
119
120 argument_spec = dict(
121 provider=dict(required=True),
122 state=dict(default='present', choices=['present', 'absent'])
123 )
124
125 argument_spec.update(normalize_ib_spec(ib_spec))
126 argument_spec.update(WapiModule.provider_spec)
127
128 module = AnsibleModule(argument_spec=argument_spec,
129 supports_check_mode=True)
130
131 wapi = WapiModule(module)
132 result = wapi.run(NIOS_NETWORK_VIEW, ib_spec)
133
134 module.exit_json(**result)
135
136
137 if __name__ == '__main__':
138 main()