Skip to content

Commit da90154

Browse files
authored
feature vrf (#15)
* Develop vrf controller module ** add vrf module ** add vrf test files ** add vrf documentation * prepare release
1 parent 7697959 commit da90154

File tree

11 files changed

+449
-8
lines changed

11 files changed

+449
-8
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ codeaffen.phpipam Release Notes
55
.. contents:: Topics
66

77

8+
v0.4.0
9+
======
10+
11+
New Modules
12+
-----------
13+
14+
- codeaffen.phpipam.vrf - Manage virtual routers and forwarders
15+
816
v0.3.0
917
======
1018

changelogs/changelog.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ releases:
2020
name: vlan
2121
namespace: ''
2222
release_date: '2020-10-28'
23+
0.4.0:
24+
modules:
25+
- description: Manage virtual routers and forwarders
26+
name: vrf
27+
namespace: ''
28+
release_date: '2020-10-28'

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
# The theme to use for HTML and HTML Help pages. See the documentation for
7777
# a list of builtin themes.
7878
#
79-
html_theme = 'sphinx_rtd_theme'
79+
html_theme = 'sphinx_ansible_theme'
8080

8181
# Theme options are theme-specific and customize the look and feel of a theme
8282
# further. For a list of options available for each theme, see the
@@ -87,7 +87,7 @@
8787
# Add any paths that contain custom static files (such as style sheets) here,
8888
# relative to this directory. They are copied after the builtin static files,
8989
# so a file named "default.css" will overwrite the builtin "default.css".
90-
html_static_path = ['_static']
90+
# html_static_path = ['_static']
9191

9292
# Custom sidebar templates, must be a dictionary that maps document names
9393
# to template names.

docs/plugins/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Module Plugins
2020
* :ref:`section <ansible_collections.codeaffen.phpipam.section_module>` -- Manage sections
2121
* :ref:`subnet <ansible_collections.codeaffen.phpipam.subnet_module>` -- Manage subnets
2222
* :ref:`vlan <ansible_collections.codeaffen.phpipam.vlan_module>` -- Manage vlans
23+
* :ref:`vrf <ansible_collections.codeaffen.phpipam.vrf_module>` -- Manage virtual routers and forwarders
2324

2425

2526
.. seealso::

docs/plugins/vrf_module.rst

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
.. Document meta
2+
3+
:orphan:
4+
5+
.. Anchors
6+
7+
.. _ansible_collections.codeaffen.phpipam.vrf_module:
8+
9+
.. Anchors: short name for ansible.builtin
10+
11+
.. Anchors: aliases
12+
13+
14+
15+
.. Title
16+
17+
codeaffen.phpipam.vrf -- Manage virtual routers and forwarders
18+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
19+
20+
.. Collection note
21+
22+
.. note::
23+
This plugin is part of the `codeaffen.phpipam collection <https://galaxy.ansible.com/codeaffen/phpipam>`_.
24+
25+
To install it use: :code:`ansible-galaxy collection install codeaffen.phpipam`.
26+
27+
To use it in a playbook, specify: :code:`codeaffen.phpipam.vrf`.
28+
29+
.. version_added
30+
31+
.. versionadded:: 0.4.0 of codeaffen.phpipam
32+
33+
.. contents::
34+
:local:
35+
:depth: 1
36+
37+
.. Deprecated
38+
39+
40+
Synopsis
41+
--------
42+
43+
.. Description
44+
45+
- create, update and delete L2 routing vrfs
46+
47+
.. Aliases
48+
49+
50+
.. Requirements
51+
52+
Requirements
53+
------------
54+
The below requirements are needed on the host that executes this module.
55+
56+
- inflection
57+
- ipaddress
58+
- phpypam
59+
60+
61+
.. Options
62+
63+
Parameters
64+
----------
65+
66+
.. raw:: html
67+
68+
<table border=0 cellpadding=0 class="documentation-table">
69+
<tr>
70+
<th colspan="1">Parameter</th>
71+
<th>Choices/<font color="blue">Defaults</font></th>
72+
<th width="100%">Comments</th>
73+
</tr>
74+
<tr>
75+
<td colspan="1">
76+
<div class="ansibleOptionAnchor" id="parameter-app_id"></div>
77+
<b>app_id</b>
78+
<a class="ansibleOptionLink" href="#parameter-app_id" title="Permalink to this option"></a>
79+
<div style="font-size: small">
80+
<span style="color: purple">string</span>
81+
</div>
82+
</td>
83+
<td>
84+
<b>Default:</b><br/><div style="color: blue">"ansible"</div>
85+
</td>
86+
<td>
87+
<div>API app name</div>
88+
</td>
89+
</tr>
90+
<tr>
91+
<td colspan="1">
92+
<div class="ansibleOptionAnchor" id="parameter-description"></div>
93+
<b>description</b>
94+
<a class="ansibleOptionLink" href="#parameter-description" title="Permalink to this option"></a>
95+
<div style="font-size: small">
96+
<span style="color: purple">string</span>
97+
</div>
98+
</td>
99+
<td>
100+
</td>
101+
<td>
102+
<div>A descriptive text for that entity</div>
103+
</td>
104+
</tr>
105+
<tr>
106+
<td colspan="1">
107+
<div class="ansibleOptionAnchor" id="parameter-distinguisher"></div>
108+
<b>distinguisher</b>
109+
<a class="ansibleOptionLink" href="#parameter-distinguisher" title="Permalink to this option"></a>
110+
<div style="font-size: small">
111+
<span style="color: purple">string</span>
112+
</div>
113+
</td>
114+
<td>
115+
</td>
116+
<td>
117+
<div>VRF route distinguisher</div>
118+
</td>
119+
</tr>
120+
<tr>
121+
<td colspan="1">
122+
<div class="ansibleOptionAnchor" id="parameter-name"></div>
123+
<b>name</b>
124+
<a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a>
125+
<div style="font-size: small">
126+
<span style="color: purple">string</span>
127+
/ <span style="color: red">required</span> </div>
128+
</td>
129+
<td>
130+
</td>
131+
<td>
132+
<div>Name of the given vrf</div>
133+
</td>
134+
</tr>
135+
<tr>
136+
<td colspan="1">
137+
<div class="ansibleOptionAnchor" id="parameter-password"></div>
138+
<b>password</b>
139+
<a class="ansibleOptionLink" href="#parameter-password" title="Permalink to this option"></a>
140+
<div style="font-size: small">
141+
<span style="color: purple">string</span>
142+
/ <span style="color: red">required</span> </div>
143+
</td>
144+
<td>
145+
</td>
146+
<td>
147+
<div>Password of the user to access phpIPAM server</div>
148+
</td>
149+
</tr>
150+
<tr>
151+
<td colspan="1">
152+
<div class="ansibleOptionAnchor" id="parameter-sections"></div>
153+
<b>sections</b>
154+
<a class="ansibleOptionLink" href="#parameter-sections" title="Permalink to this option"></a>
155+
<div style="font-size: small">
156+
<span style="color: purple">list</span>
157+
/ <span style="color: purple">elements=string</span> </div>
158+
</td>
159+
<td>
160+
</td>
161+
<td>
162+
<div>List of sections where the nameserver appears</div>
163+
</td>
164+
</tr>
165+
<tr>
166+
<td colspan="1">
167+
<div class="ansibleOptionAnchor" id="parameter-server_url"></div>
168+
<b>server_url</b>
169+
<a class="ansibleOptionLink" href="#parameter-server_url" title="Permalink to this option"></a>
170+
<div style="font-size: small">
171+
<span style="color: purple">string</span>
172+
/ <span style="color: red">required</span> </div>
173+
</td>
174+
<td>
175+
</td>
176+
<td>
177+
<div>URL of the phpIPAM server</div>
178+
</td>
179+
</tr>
180+
<tr>
181+
<td colspan="1">
182+
<div class="ansibleOptionAnchor" id="parameter-state"></div>
183+
<b>state</b>
184+
<a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a>
185+
<div style="font-size: small">
186+
<span style="color: purple">string</span>
187+
</div>
188+
</td>
189+
<td>
190+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
191+
<li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
192+
<li>absent</li>
193+
</ul>
194+
</td>
195+
<td>
196+
<div>State of the entity</div>
197+
</td>
198+
</tr>
199+
<tr>
200+
<td colspan="1">
201+
<div class="ansibleOptionAnchor" id="parameter-username"></div>
202+
<b>username</b>
203+
<a class="ansibleOptionLink" href="#parameter-username" title="Permalink to this option"></a>
204+
<div style="font-size: small">
205+
<span style="color: purple">string</span>
206+
/ <span style="color: red">required</span> </div>
207+
</td>
208+
<td>
209+
</td>
210+
<td>
211+
<div>Username to access phpIPAM server</div>
212+
</td>
213+
</tr>
214+
</table>
215+
<br/>
216+
217+
.. Notes
218+
219+
220+
.. Seealso
221+
222+
223+
.. Examples
224+
225+
Examples
226+
--------
227+
228+
.. code-block:: yaml+jinja
229+
230+
231+
- name: "Create vrf"
232+
codeaffen.phpipam.vrf:
233+
username: "admin"
234+
password: "s3cr3t"
235+
server_url: "https://ipam.example.com"
236+
name: "my vrf"
237+
sections:
238+
- Example Inc.
239+
- DEVOPS department
240+
state: present
241+
242+
- name: "Remove vrf"
243+
codeaffen.phpipam.vrf:
244+
username: "admin"
245+
password: "s3cr3t"
246+
server_url: "https://ipam.example.com"
247+
name: "my vrf"
248+
state: absent
249+
250+
251+
252+
253+
.. Facts
254+
255+
256+
.. Return values
257+
258+
259+
.. Status (Presently only deprecated)
260+
261+
262+
.. Authors
263+
264+
Authors
265+
~~~~~~~
266+
267+
- Christian Meißner (@cmeissner)
268+
269+
270+
271+
.. Parsing errors
272+

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: "phpipam"
33
description: Ansible Modules to manage phpIPAM installations
44
authors:
55
- "Christian Meißner <[email protected]>"
6-
version: "0.3.0"
6+
version: "0.4.0"
77
license:
88
- "GPL-3.0-or-later"
99
tags:

plugins/module_utils/phpipam_helper.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _resolve_entity(self, key):
182182
if controller == 'subnets':
183183
subnet, mask = self.phpipam_params[key].split('/')
184184
result = self.find_subnet(subnet, mask)
185-
elif 'tools' in controller or controller in ['vlan', 'l2domains']:
185+
elif 'tools' in controller or controller in ['vlan', 'l2domains', 'vrf']:
186186
result = self.find_by_key(controller=controller, value=self.phpipam_params[key])
187187
else:
188188
if entity_spec.get('type') == 'entity':
@@ -293,7 +293,7 @@ def _create_entity(self, desired_entity):
293293
entity = self.find_subnet(self.phpipam_params['subnet'], self.phpipam_params['mask'])
294294
elif self.controller_name == 'address':
295295
entity = self.find_address(self.phpipam_params['ipaddress'])
296-
elif 'tools' in self.controller_name or self.controller_name in ['vlan', 'l2domain']:
296+
elif 'tools' in self.controller_name or self.controller_name in ['vlan', 'l2domain', 'vrf']:
297297
entity = self.find_by_key(self.controller_uri, self.phpipam_params['name'])
298298
else:
299299
entity = self.find_entity(self.controller_uri, '/' + desired_entity['name'])
@@ -325,7 +325,7 @@ def _update_entity(self, desired_entity, current_entity):
325325
else:
326326
return current_entity
327327

328-
if 'tools' in self.controller_uri or self.controller_uri == 'vlan':
328+
if 'tools' in self.controller_uri or self.controller_uri in ['vlan', 'vrf']:
329329
update_path = current_entity[entity_id]
330330
else:
331331
update_path = '/'
@@ -337,7 +337,7 @@ def _update_entity(self, desired_entity, current_entity):
337337
entity = self.find_subnet(self.phpipam_params['subnet'], self.phpipam_params['mask'])
338338
elif self.controller_name == 'address':
339339
entity = self.find_address(self.phpipam_params['ipaddress'])
340-
elif 'tools' in self.controller_uri or self.controller_name in ['vlan', 'l2domain']:
340+
elif 'tools' in self.controller_uri or self.controller_name in ['vlan', 'l2domain', 'vrf']:
341341
entity = self.find_by_key(self.controller_uri, self.phpipam_params['name'])
342342
else:
343343
entity = self.find_entity(self.controller_uri, '/' + current_entity['name'])
@@ -421,6 +421,7 @@ def controller_pluralize(self, controller):
421421
'nat',
422422
'prefix',
423423
'vlan',
424+
'vrf',
424425
)
425426

426427
if controller not in _PLURAL_EXCEPTIONS:
@@ -458,7 +459,7 @@ def ensure_entity(self, desired_entity):
458459
current_entity = self.find_subnet(self.phpipam_params['subnet'], self.phpipam_params['mask'])
459460
elif self.controller_name == 'address':
460461
current_entity = self.find_address(self.phpipam_params['ipaddress'])
461-
elif 'tools' in self.controller_name or self.controller_name in ['vlan', 'l2domain']:
462+
elif 'tools' in self.controller_name or self.controller_name in ['vlan', 'l2domain', 'vrf']:
462463
current_entity = self.find_by_key(self.controller_uri, self.phpipam_params['name'])
463464
else:
464465
current_entity = self.find_entity(self.controller_uri, '/' + self.phpipam_params['name'])

0 commit comments

Comments
 (0)