-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] Resolved issues in vLAN module (#277)
* Fix for vLan modules * Fixed sanity issues related to vlan parent * Removed trailing whitespaces * Fixed vLan parent transform * Fixed vLan transform in network * Added unit tests for vLAN * Updated examples for vLAN * Fix sanity and unit tests * Fix sanity and added vLAN integration tests * corrected file permissions
- Loading branch information
Showing
33 changed files
with
446 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
module: nios_vlan | ||
author: "Christoph Spatt (@edeka-spatt)" | ||
short_description: Configure Infoblox NIOS VLANs | ||
version_added: "1.4.3" | ||
version_added: "1.8.0" | ||
description: | ||
- Adds and/or removes instances of vlan objects from | ||
Infoblox NIOS servers. This module manages NIOS C(vlan) objects | ||
|
@@ -39,11 +39,10 @@ | |
description: | ||
- Specifies the vlan parent to add or remove from | ||
the system. Can be either a C(vlanview) or C(vlanrange) | ||
name. Feteches the required _ref object automatically. | ||
name. Fetches the required _ref object automatically. | ||
If not specified defaults to vlan view C(default). | ||
type: str | ||
default: default | ||
required: true | ||
comment: | ||
description: | ||
- Configures a text string comment to be associated with the instance | ||
|
@@ -92,7 +91,7 @@ | |
infoblox.nios_modules.nios_vlan: | ||
name: ansible | ||
id: 10 | ||
parent: default | ||
parent: my_vlanview | ||
state: present | ||
provider: | ||
host: "{{ inventory_hostname_short }}" | ||
|
@@ -104,6 +103,7 @@ | |
infoblox.nios_modules.nios_vlan: | ||
name: ansible | ||
id: 10 | ||
parent: my_vlanview | ||
comment: this is an example comment | ||
state: present | ||
provider: | ||
|
@@ -116,6 +116,7 @@ | |
infoblox.nios_modules.nios_vlan: | ||
name: ansible | ||
id: 10 | ||
parent: my_vlanview | ||
state: absent | ||
provider: | ||
host: "{{ inventory_hostname_short }}" | ||
|
@@ -126,6 +127,27 @@ | |
- name: Update an existing vlan | ||
infoblox.nios_modules.nios_vlan: | ||
name: {new_name: ansible-new, old_name: ansible} | ||
id: 10 | ||
parent: my_vlanview | ||
state: present | ||
provider: | ||
host: "{{ inventory_hostname_short }}" | ||
username: admin | ||
password: admin | ||
connection: local | ||
- name: Create vlan with extensible attributes | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible | ||
id: 11 | ||
parent: my_vlanview | ||
comment: "this is an example comment" | ||
contact: "[email protected]" | ||
department: "IT" | ||
description: "test" | ||
reserved: True | ||
extattrs: | ||
Site: "HQ" | ||
state: present | ||
provider: | ||
host: "{{ inventory_hostname_short }}" | ||
|
@@ -151,10 +173,10 @@ def parent_transform(module): | |
if module.params['parent']: | ||
parent_obj_vlanview = wapi.get_object('vlanview', {'name': module.params['parent']}) | ||
parent_obj_vlanrange = wapi.get_object('vlanrange', {'name': module.params['parent']}) | ||
if parent_obj_vlanview and not parent_obj_vlanrange: | ||
parent_ref = parent_obj_vlanview[0]['_ref'] | ||
elif not parent_obj_vlanview and parent_obj_vlanrange: | ||
if parent_obj_vlanrange: | ||
parent_ref = parent_obj_vlanrange[0]['_ref'] | ||
elif parent_obj_vlanview: | ||
parent_ref = parent_obj_vlanview[0]['_ref'] | ||
else: | ||
module.fail_json(msg='VLAN View/Range \'%s\' cannot be found.' % module.params['parent']) | ||
return parent_ref | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
shippable/cloud/group1 | ||
cloud/nios | ||
destructive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
testcase: "*" | ||
test_items: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- prepare_nios_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: Include idempotence tasks for vlan | ||
ansible.builtin.include_tasks: nios_vlan_idempotence.yml |
94 changes: 94 additions & 0 deletions
94
tests/integration/targets/nios_vlan/tasks/nios_vlan_idempotence.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
--- | ||
- name: Cleanup VLAN | ||
nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
state: absent | ||
provider: "{{ nios_provider }}" | ||
|
||
- name: Configure a VLAN on the system | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
contact: '[email protected]' | ||
department: 'IT' | ||
description: 'This is an example VLAN' | ||
reserved: true | ||
state: present | ||
provider: "{{ nios_provider }}" | ||
register: vlan_create1 | ||
|
||
- name: Configure another VLAN on the system | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
contact: '[email protected]' | ||
department: 'IT' | ||
description: 'This is an example VLAN' | ||
reserved: true | ||
state: present | ||
provider: "{{ nios_provider }}" | ||
register: vlan_create2 | ||
|
||
- name: Update the comment and ext attributes for an existing VLAN | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
contact: '[email protected]' | ||
department: 'IT' | ||
description: 'This is an example VLAN' | ||
reserved: true | ||
comment: this is an example comment | ||
extattrs: | ||
Site: west-dc | ||
state: present | ||
provider: "{{ nios_provider }}" | ||
register: vlan_update1 | ||
|
||
- name: Update again the comment and ext attributes for an existing VLAN | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
contact: '[email protected]' | ||
department: 'IT' | ||
description: 'This is an example VLAN' | ||
reserved: true | ||
comment: this is an example comment | ||
extattrs: | ||
Site: west-dc | ||
state: present | ||
provider: "{{ nios_provider }}" | ||
register: vlan_update2 | ||
|
||
- name: Remove the VLAN | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
state: absent | ||
provider: "{{ nios_provider }}" | ||
register: vlan_delete1 | ||
|
||
- name: Remove again the VLAN | ||
infoblox.nios_modules.nios_vlan: | ||
name: ansible-vlan | ||
id: 10 | ||
parent: default | ||
state: absent | ||
provider: "{{ nios_provider }}" | ||
register: vlan_delete2 | ||
|
||
- name: Assert changes in VLAN | ||
ansible.builtin.assert: | ||
that: | ||
- vlan_create1.changed | ||
- not vlan_create2.changed | ||
- vlan_update1.changed | ||
- not vlan_update2.changed | ||
- vlan_delete1.changed | ||
- not vlan_delete2.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.