-
Notifications
You must be signed in to change notification settings - Fork 20
Configure Cisco NX-OS Vlan doc #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||||
| requires the `ansible_network_os` value set to `nxos`. | ||||||
|
|
||||||
| ## How to set VLANs on the device | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| interface under the `nxos` top level key. | ||||||
|
|
||||||
| ### Implement using tasks | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| steps: | ||||||
|
|
||||||
| * Add (or update) command parser located in `parse_templates/cli` | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ## Arguments | ||||||
|
|
||||||
| ### id | ||||||
|
|
||||||
| VLAN will be configured on the Cisco NX-OS device using respective ID over the interface | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| and this is also a mandatory parameter. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### name | ||||||
|
|
||||||
| This sets the name for the VLAN Id for the Cisco NX-OS device. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### status | ||||||
|
|
||||||
| This sets the status for the VLAN Id for the Cisco NX-OS device. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### state | ||||||
|
|
||||||
| This sets the VLANs value to the Cisco NX-OS device and if the value of the state is changed | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| argument, the role will go ahead and try to set the VLANs via the arguments passed to the | ||||||
| Cisco NX-OS device. | ||||||
|
|
||||||
| ## Notes | ||||||
|
|
||||||
| None | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.