Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Please see the documentation link for each function for details on how to use
the function in an Ansible playbook.

* get_facts [[source]](https://github.com/ansible-network/cisco_nxos/blob/devel/tasks/get_facts.yaml) [[docs]](https://github.com/ansible-network/cisco_nxos/blob/devel/docs/get_facts.md)
* configure_vlans [[source]](https://github.com/ansible-network/cisco_nxos/blob/devel/tasks/configure_vlans.yaml) [[docs]](https://github.com/ansible-network/cisco_nxos/blob/devel/docs/configure_vlans.md)

### Config Manager

Expand Down
101 changes: 101 additions & 0 deletions docs/configure_vlans.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Configure VLANs on the device

The `configure_vlans` function can be used to set VLANs on Cisco NX-OS devices.
This function is only supported over `network_cli` connection type and
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This function is only supported over `network_cli` connection type and
This function is only supported over the `network_cli` connection type and

requires the `ansible_network_os` value set to `nxos`.

## How to set VLANs on the device
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## How to set VLANs on the device


To set VLANs on the device, simply include this function in the playbook
using either the `roles` directive or the `tasks` directive. If no other
options are provided, then all of the available facts will be collected for
the device.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## How to set VLANs using roles

Below is an example of how to use the `roles` directive to set VLANs on the
Cisco NX-OS device.

```
- hosts: nxos

roles:
- name ansible-network.cisco_nxos
function: configure_vlans
vars:
vlans:
- id: 10
name: vlan-10
status: active
```

The above playbook will set the VLANs with ID, description, and address to particular
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The above playbook will set the VLANs with ID, description, and address to particular
The above playbook will set the VLANs with ID, description, and address to a particular

interface under the `nxos` top level key.

### Implement using tasks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Implement using tasks
### How to set VLANs using tasks


The `configure_vlans` function can also be implemented using the `tasks` directive
instead of the `roles` directive. By using the `tasks` directive, you can
control when the fact collection is run.

Below is an example of how to use the `configure_vlans` function with `tasks`.

```
- hosts: nxos

tasks:
- name: set vlans to nxos devices
import_role:
name: ansible-network.cisco_nxos
tasks_from: configure_vlans
vars:
vlans:
- id: 10
name: vlan-10
status: active
```

## Adding new parsers

Over time new parsers can be added (or updated) to the role to add additional
or enhanced functionality. To add or update parsers perform the following
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
or enhanced functionality. To add or update parsers perform the following
or enhanced functionality. To add or update parsers, perform the following

steps:

* Add (or update) command parser located in `parse_templates/cli`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Add (or update) command parser located in `parse_templates/cli`
* Add (or update) the command parser located in `parse_templates/cli`


## Arguments

### id

VLAN will be configured on the Cisco NX-OS device using respective ID over the interface
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VLAN will be configured on the Cisco NX-OS device using respective ID over the interface
This value sets the VLAN ID that will be configured on the Cisco NX-OS device. This is a mandatory parameter. The valid range is 1 - 4094.

and this is also a mandatory parameter.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and this is also a mandatory parameter.


This being a mandatory parameter which means even if the user doesn't pass the respective
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This being a mandatory parameter which means even if the user doesn't pass the respective

argument the role will fail to run with missing argument error. Also, valid VLANs id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
argument the role will fail to run with missing argument error. Also, valid VLANs id

range is 1-4094, so the role checks if the user value for the argument matches the range
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
range is 1-4094, so the role checks if the user value for the argument matches the range

and if not the execution of the role fails with id range error
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and if not the execution of the role fails with id range error
If you do not set this parameter within this range, the role fails with an id range error.


### name

This sets the name for the VLAN Id for the Cisco NX-OS device.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This sets the name for the VLAN Id for the Cisco NX-OS device.
This sets the name for the VLAN ID for the Cisco NX-OS device.


The default value is `omit` which means even if the user doesn't pass the respective
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default value is `omit` which means even if the user doesn't pass the respective
This is an optional parameter with the default value of `omit` which means the role will continue to run, but will use the Cisco NXOS default value for the VLAN name.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to read the Cisco NXOS docs for vlans and it suggests if you don't set a VLAN name, it will create one for you - VLANxxxx where xxxx represent four numeric digits (including leading zeroes) equal to the VLAN ID number. I don't know that we want to specify Cisco's defaults here, just in case they change it for some reason down the road?

value the role will continue to run without any failure.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value the role will continue to run without any failure.


### status

This sets the status for the VLAN Id for the Cisco NX-OS device.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This sets the status for the VLAN Id for the Cisco NX-OS device.
This is an optional parameter that sets the status for the VLAN ID for the Cisco NX-OS device. The valid values are `active` or `suspend`.


The default value is `omit` which means even if the user doesn't pass the respective
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default value is `omit` which means even if the user doesn't pass the respective
The default value is `omit` which means the role will continue to run, with the default status of `active`.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making another guess here based on reading the nxos_vlan module docs...

value the role will continue to run without any failure.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value the role will continue to run without any failure.


### state

This sets the VLANs value to the Cisco NX-OS device and if the value of the state is changed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This sets the VLANs value to the Cisco NX-OS device and if the value of the state is changed
This is an optional parameter that sets the VLAN state to the Cisco NX-OS device. The options are `present` or `absent`. If the value of the state is changed

to `absent`, the role will go ahead and try to delete the VLANs via the arguments passed.

The default value is `present` which means even if the user doesn't pass the respective
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default value is `present` which means even if the user doesn't pass the respective
The default value is `present` which means even if the user doesn't pass the

argument, the role will go ahead and try to set the VLANs via the arguments passed to the
Cisco NX-OS device.

## Notes

None