forked from codeaffen/phpipam-ansible-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddress.py
More file actions
171 lines (157 loc) · 4.75 KB
/
Copy pathaddress.py
File metadata and controls
171 lines (157 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# (c) Christian Meißner 2020
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
module: address
version_added: 0.2.0
short_description: Manage addresses
description:
- create, update and delete addresses
author:
- "Christian Meißner (@cmeissner)"
options:
subnet:
description: subnet address belongs to
type: str
required: true
section:
description: name of the section the given subnet belongs to
version_added: 1.3.1
type: str
required: true
ipaddress:
description: IP address to hanle
type: str
required: true
aliases:
- ip
- address
is_gateway:
description: Defines if address is presented as gateway
type: bool
required: false
default: no
description:
description: Address description
type: str
required: false
hostname:
description: Address hostname
type: str
required: false
mac_address:
description: Mac address
type: str
required: false
aliases:
- mac
owner:
description: Address owner
type: str
required: false
tag:
description: IP tag (online, offline, ...)
type: str
required: false
ignore_ptr:
description: Controls if PTR should not be created
type: bool
required: false
default: no
ptr:
description: DNS PTR record
type: str
required: false
device:
description: Device address belongs to
type: str
required: false
port:
description: Port
type: str
required: false
note:
description: Note
type: str
required: false
exclude_ping:
description: Exclude this address from status update scans
type: bool
required: false
location:
description: Address location
version_added: 1.8.0
type: str
required: false
extends_documentation_fragment:
- codeaffen.phpipam.phpipam
- codeaffen.phpipam.phpipam.entity_state
'''
EXAMPLES = '''
- name: "Reserve an IP address"
codeaffen.phpipam.address:
username: "admin"
password: "s3cr3t"
server_url: "https://ipam.example.com"
address: "192.0.2.1"
section: "Customers"
description: "Default router of sunet"
subnet: "192.0.2.0/24"
is_gateway: yes
state: present
- name: "Remove address reservation"
codeaffen.phpipam.address:
username: "admin"
password: "s3cr3t"
server_url: "https://ipam.example.com"
address: "192.0.2.1"
subnet: "192.0.2.0/24"
section: "Customers"
state: absent
'''
from ansible_collections.codeaffen.phpipam.plugins.module_utils.phpipam_helper import PhpipamEntityAnsibleModule
class PhpipamAddressModule(PhpipamEntityAnsibleModule):
pass
def main():
module = PhpipamAddressModule(
phpipam_spec=dict(
subnet=dict(type='entity', controller='subnets', required=True, phpipam_name='subnetId'),
section=dict(type='str', api_invisible=True, required=True),
ipaddress=dict(type='str', required=True, aliases=['ip', 'address'], phpipam_name='ip'),
is_gateway=dict(type='bool', phpipam_name='is_gateway'),
description=dict(type='str'),
hostname=dict(type='str'),
mac_address=dict(type='str', aliases=['mac'], phpipam_name='mac'),
owner=dict(type='str'),
tag=dict(type='entity', controller='tools/tags'),
ignore_ptr=dict(type='bool'),
ptr=dict(type='str'),
device=dict(type='entity', controller='tools/devices', phpipam_name='deviceId'),
port=dict(type='str'),
note=dict(type='str'),
exclude_ping=dict(type='bool'),
location=dict(type='entity', controller='tools/locations'),
)
)
if not module.desired_absent:
pass
with module.api_connection():
module.run()
if __name__ == "__main__":
main()