From c4e667851d189c04fd3e4faf33da45b7485f3929 Mon Sep 17 00:00:00 2001 From: prakash_p2 Date: Wed, 29 Apr 2020 23:33:12 -0700 Subject: [PATCH] Added role for IPv6 RA Guard --- docs/os10_raguard.md | 1 + roles/os10_raguard/LICENSE | 201 +++++++++++++++++++ roles/os10_raguard/README.md | 130 ++++++++++++ roles/os10_raguard/defaults/main.yml | 2 + roles/os10_raguard/handlers/main.yml | 2 + roles/os10_raguard/meta/main.yml | 18 ++ roles/os10_raguard/tasks/main.yml | 17 ++ roles/os10_raguard/templates/os10_raguard.j2 | 174 ++++++++++++++++ roles/os10_raguard/tests/inventory.yaml | 2 + roles/os10_raguard/tests/main.os10.yaml | 56 ++++++ roles/os10_raguard/tests/test.yaml | 5 + roles/os10_raguard/vars/main.yml | 2 + 12 files changed, 610 insertions(+) create mode 120000 docs/os10_raguard.md create mode 100644 roles/os10_raguard/LICENSE create mode 100644 roles/os10_raguard/README.md create mode 100644 roles/os10_raguard/defaults/main.yml create mode 100644 roles/os10_raguard/handlers/main.yml create mode 100644 roles/os10_raguard/meta/main.yml create mode 100644 roles/os10_raguard/tasks/main.yml create mode 100644 roles/os10_raguard/templates/os10_raguard.j2 create mode 100644 roles/os10_raguard/tests/inventory.yaml create mode 100644 roles/os10_raguard/tests/main.os10.yaml create mode 100644 roles/os10_raguard/tests/test.yaml create mode 100644 roles/os10_raguard/vars/main.yml diff --git a/docs/os10_raguard.md b/docs/os10_raguard.md new file mode 120000 index 0000000..2b346cc --- /dev/null +++ b/docs/os10_raguard.md @@ -0,0 +1 @@ +../roles/os10_raguard/README.md \ No newline at end of file diff --git a/roles/os10_raguard/LICENSE b/roles/os10_raguard/LICENSE new file mode 100644 index 0000000..230dce4 --- /dev/null +++ b/roles/os10_raguard/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2020, Dell Inc. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/roles/os10_raguard/README.md b/roles/os10_raguard/README.md new file mode 100644 index 0000000..3a94757 --- /dev/null +++ b/roles/os10_raguard/README.md @@ -0,0 +1,130 @@ +IPv6 RA Guard role +=================== + +This role facilitates the configuration of IPv6 RA Guard attributes. This role is abstracted for Dell EMC PowerSwitch platforms running Dell EMC SmartFabric OS10. It specifically enables configuration of IPv6 RA Guard feature enable/disable, IPv6 RA Guard Policy defination and policy parameter configuration, Attachment of IPv6 RA Guard policy to an interface in OS10. + +The IPv6 RA Guard role requires an SSH connection for connectivity to a Dell EMC Networking device. You can use any of the built-in OS connection variables . + +Role variables +-------------- + +- Role is abstracted using the *ansible_network_os* variable that can take dellemc_networking.os10.os10 value +- If *os10_cfg_generate* is set to true, the variable generates the role configuration commands in a file +- Any role variable with a corresponding state variable set to absent negates the configuration of that variable +- Setting an empty value for any variable negates the corresponding configuration +- Variables and values are case-sensitive + +**os10_raguard keys** + + +| Key | Type | Description |Support | +|--------------------------------------|-------------------------|----------------------------------------------------------|---------| +| ``enable`` | boolean | Enable IPv6 RA-Guard feature | os10 | +| ``policy`` | list | Configures the IPv6 RA Guard policy (see ``policy.*``) | os10 | +| ``policy.state`` | string: absent/present\*| (absent/present)Deletes the policy if set to absent | os10 | +| ``policy.name`` | string (required) | Configures the IPv6 RA Guard policy Name | os10 | +| ``policy.device_role.value`` | string (required) | Configures the Device role for a policy | os10 | +| ``policy.device_role.state`` | string: absent,present\*| Deletes the device role if set to absent | os10 | +| ``policy.managed_config_flag.value`` | string | Configures the Managed config flag param for a policy | os10 | +| ``policy.managed_config_flag.state`` | string: absent,present\*| Deletes the Managed config flag if set to absent | os10 | +| ``policy.other_config_flag.value`` | string | Configures the Other config flag param for a policy | os10 | +| ``policy.other_config_flag.state`` | string: absent,present\*| Deletes the Other config flag if set to absent | os10 | +| ``policy.mtu.value`` | integer | Configures the MTU param for a policy | os10 | +| ``policy.mtu.state`` | string: absent,present\*| Deletes the MTU if set to absent | os10 | +| ``policy.reachable_time.value`` | integer | Configures the Reachable time param for a policy | os10 | +| ``policy.reachable_time.state`` | string: absent,present\*| Deletes the Reachable time if set to absent | os10 | +| ``policy.retrans_timer.value`` | integer | Configures the Retransmit timer param for a policy | os10 | +| ``policy.retrans_timer.state`` | string: absent,present\*| Deletes the Retransmit timer if set to absent | os10 | +| ``policy.router_lifetime.value`` | integer | Configures the Router lifetime param for a policy | os10 | +| ``policy.router_lifetime.state`` | string: absent,present\*| Deletes the Router lifetime if set to absent | os10 | +| ``policy.router_preference.value`` | string | Configures the Router Preference param for a policy | os10 | +| ``policy.router_preference.state`` | string: absent,present\*| Deletes the Router Preference if set to absent | os10 | +| ``policy.match`` | list | Configures the prefix/ACL/MAC list param for a policy | os10 | +| ``policy.match.type`` | string | Configures the prefix/ACL/MAC type for a policy | os10 | +| ``policy.match.name`` | string | Configures the prefix/ACL/MAC name for a policy | os10 | +| ``policy.match.state`` | string: absent,present\*| Deletes the prefix/ACL/MAC if set to absent | os10 | +| ``intf`` | dictionary | Configures IPv6 RA Guard on the interface(see``intf.*``) | os10 | +| ``intf.`` | dictionary | Configures RA Guard on the interface(see``.*``)| os10 | +| ``.policy_name`` | String | Configures RA Guard policy name to be attached on an interface | os10 | +| ``.vlan`` | String | Configures VLAN name to which policy to be attached on an interface| os10| +| ``.state`` | String: absent,present\*| Deletes the policy if set to absent an interface | os10| + +> **NOTE**: Asterisk (\*) denotes the default value if none is specified.. + +Connection variables +-------------------- + +Ansible Dell EMC Networking roles require connection information to establish communication with the nodes in your inventory. This information can exist in the Ansible *group_vars* or *host_vars* directories or inventory or in the playbook itself. + +| Key | Required | Choices | Description | +|-------------|----------|------------|-------------------------------------------------------| +| ``ansible_host`` | yes | | Specifies the hostname or address for connecting to the remote device over the specified transport | +| ``ansible_port`` | no | | Specifies the port used to build the connection to the remote device; if value is unspecified, the ANSIBLE_REMOTE_PORT option is used; it defaults to 22 | +| ``ansible_ssh_user`` | no | | Specifies the username that authenticates the CLI login for the connection to the remote device; if value is unspecified, the ANSIBLE_REMOTE_USER environment variable value is used | +| ``ansible_ssh_pass`` | no | | Specifies the password that authenticates the connection to the remote device | +| ``ansible_become`` | no | yes, no\* | Instructs the module to enter privileged mode on the remote device before sending any commands; if value is unspecified, the ANSIBLE_BECOME environment variable value is used, and the device attempts to execute all commands in non-privileged mode | +| ``ansible_become_method`` | no | enable, sudo\* | Instructs the module to allow the become method to be specified for handling privilege escalation; if value is unspecified, the ANSIBLE_BECOME_METHOD environment variable value is used | +| ``ansible_become_pass`` | no | | Specifies the password to use if required to enter privileged mode on the remote device; if ``ansible_become`` is set to no this key is not applicable | +| ``ansible_network_os`` | yes | os10, null\* | Loads the correct terminal and cliconf plugins to communicate with the remote device | + +> **NOTE**: Asterisk (\*) denotes the default value if none is specified. + +Dependencies +------------ + +The *os10_raguard* role is built on modules included in the core Ansible code. These modules were added in Ansible version 2.2.0. + +Example playbook +---------------- + +This example uses the *os10_raguard* role to configure the IPv6 RA Guard feature enable/disable, IPv6 RA Guard Policy defination and policy parameter configuration, Attachment of IPv6 RA Guard policy to an interface. It creates a *hosts* file with the switch details and corresponding variables. The hosts file should define the *ansible_network_os* variable with corresponding Dell EMC Networking OS name. When the *os10_cfg_generate* variable is set to true, it generates the configuration commands as a .part file in *build_dir* path. By default it is set to false. The example writes a simple playbook that only references the *os10_raguard* role. + +By including the role, you automatically get access to all of the tasks to configure IPv6 RA Guard attributes. The sample *host_vars* is for os10. + +**Sample hosts file** + + leaf1 ansible_host= + +**Sample host_vars/leaf1** + + host: leaf1 + ansible_ssh_user: xxxxx + ansible_ssh_pass: xxxxx + ansible_network_os: dellemc_networking.os10.os10 + build_dir: ../temp/os10 + + os10_raguard: + enable: true + policy: + - policy_name: test + device_role: + value: router + state: present + managed_config_flag: + value: "on" + state: present + mtu: + value: 1280 + state: present + match: + - type: prefix_list + name: test_prefix + state: present + state: present + intf: + ethernet 1/1/2: + policy_name: test + vlan: 10 + state: present + +**Simple playbook to setup IPv6 RA Guard - leaf.yaml** + + - hosts: leaf1 + roles: + - dellemc_networking.os10.os10_raguard + +**Run** + + ansible-playbook -i hosts leaf.yaml + +(c) 2020 Dell Inc. or its subsidiaries. All Rights Reserved. diff --git a/roles/os10_raguard/defaults/main.yml b/roles/os10_raguard/defaults/main.yml new file mode 100644 index 0000000..4290a9e --- /dev/null +++ b/roles/os10_raguard/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for dellemc_networking.os10.os10_raguard diff --git a/roles/os10_raguard/handlers/main.yml b/roles/os10_raguard/handlers/main.yml new file mode 100644 index 0000000..8977b65 --- /dev/null +++ b/roles/os10_raguard/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for dellemc_networking.os10.os10_raguard diff --git a/roles/os10_raguard/meta/main.yml b/roles/os10_raguard/meta/main.yml new file mode 100644 index 0000000..9deb15b --- /dev/null +++ b/roles/os10_raguard/meta/main.yml @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Dell Inc. +--- +galaxy_info: + author: Dell EMC Networking Engineering + description: The os10_raguard role facilitates the configuration of IPv6 RA Guard attributes in devices running Dell EMC Networking Operating Systems. + company: Dell Technologies + license: Apache 2.0 + min_ansible_version: 2.2 + + platforms: + - name: os10 + + galaxy_tags: + - networking + - dell + - emc + - dellemc + - os10 diff --git a/roles/os10_raguard/tasks/main.yml b/roles/os10_raguard/tasks/main.yml new file mode 100644 index 0000000..843ceed --- /dev/null +++ b/roles/os10_raguard/tasks/main.yml @@ -0,0 +1,17 @@ +--- +# tasks file for dellemc_networking.os10.os10_raguard +# tasks file for os10 + - name: "Generating IPv6 RA Guard configuration for os10" + template: + src: os10_raguard.j2 + dest: "{{ build_dir }}/raguard10_{{ hostname }}.conf.part" + when: (ansible_network_os is defined and ansible_network_os == "dellemc_networking.os10.os10") and ((os10_cfg_generate | default('False')) | bool) +# notify: save config os10 + register: generate_output + + - name: "Provisioning IPv6 RA Guard configuration for os10" + os10_config: + src: os10_raguard.j2 + when: (ansible_network_os is defined and ansible_network_os == "dellemc_networking.os10.os10") +# notify: save config os10 + register: output diff --git a/roles/os10_raguard/templates/os10_raguard.j2 b/roles/os10_raguard/templates/os10_raguard.j2 new file mode 100644 index 0000000..7abc27d --- /dev/null +++ b/roles/os10_raguard/templates/os10_raguard.j2 @@ -0,0 +1,174 @@ +#jinja2: trim_blocks: True,lstrip_blocks: True +{############################################# +Purpose: +Configure IPv6 RA Guard commands for OS10 Devices +os10_raguard: + enable: true + policy: + - policy_name: test + device_role: + value: router + state: present + managed_config_flag: + value: "on" + state: present + other_config_flag: + value: "on" + state: present + mtu: + value: 1280 + state: present + reachable_time: + value: 100 + state: present + retrans_timer: + value: 100 + state: present + router_lifetime: + value: 10 + state: present + router_preference: + value: high + state: present + match: + - type: prefix_list + name: test_prefix + state: present + - type: access_list + name: test_access + state: present + - type: mac_list + name: test_mac + state: present + state: present + intf: + ethernet 1/1/2: + policy_name: test + vlan: 10 + state: present + ethernet 1/1/3: + policy_name: test + vlan: all + state: present + ethernet 1/1/4: + policy_name: test + vlan: 10,11,12,15 + state: present +###############################################} +{% if os10_raguard is defined and os10_raguard %} + {% if os10_raguard.enable is defined %} + {% if os10_raguard.enable %} +ipv6 nd ra-guard enable + {% else %} +no ipv6 nd ra-guard enable + {% endif %} + {% endif %} + {% if os10_raguard.policy is defined and os10_raguard.policy %} + {% for item in os10_raguard.policy %} + {% if item.policy_name is defined and item.policy_name %} + {% if item.state is defined and item.state == "absent" %} +no ipv6 nd ra-guard policy {{ item.policy_name }} + {% else %} +ipv6 nd ra-guard policy {{ item.policy_name }} + {% if item.device_role is defined and item.device_role %} + {% if item.device_role.state is defined and item.device_role.state == "absent" %} +no device-role {{ item.device_role }} + {% else %} +device-role {{ item.device_role.value }} + {% endif %} + {% endif %} + {% if item.device_role is defined and item.device_role.value == "router" %} + {% if item.managed_config_flag is defined and item.managed_config_flag %} + {% if item.managed_config_flag.state is defined and item.managed_config_flag.state == "absent" %} +no managed-config-flag {{ item.managed_config_flag.value }} + {% else %} +managed-config-flag {{ item.managed_config_flag.value }} + {% endif %} + {% endif %} + {% if item.other_config_flag is defined and item.other_config_flag %} + {% if item.other_config_flag.state is defined and item.other_config_flag.state == "absent" %} +no other-config-flag {{ item.other_config_flag.value }} + {% else %} +other-config-flag {{ item.other_config_flag.value }} + {% endif %} + {% endif %} + {% if item.mtu is defined and item.mtu %} + {% if item.mtu.state is defined and item.mtu.state == "absent" %} +no mtu {{ item.mtu.value }} + {% else %} +mtu {{ item.mtu.value }} + {% endif %} + {% endif %} + {% if item.reachable_time is defined and item.reachable_time %} + {% if item.reachable_time.state is defined and item.reachable_time.state == "absent" %} +no reachable-time {{ item.reachable_time.value }} + {% else %} +reachable-time {{ item.reachable_time.value }} + {% endif %} + {% endif %} + {% if item.retrans_timer is defined and item.retrans_timer %} + {% if item.retrans_timer.state is defined and item.retrans_timer.state == "absent" %} +no retrans-timer {{ item.retrans_timer.value }} + {% else %} +retrans-timer {{ item.retrans_timer.value }} + {% endif %} + {% endif %} + {% if item.router_lifetime is defined and item.router_lifetime %} + {% if item.router_lifetime.state is defined and item.router_lifetime.state == "absent" %} +no router-lifetime {{ item.router_lifetime.value }} + {% else %} +router-lifetime {{ item.router_lifetime.value }} + {% endif %} + {% endif %} + {% if item.router_preference is defined and item.router_preference %} + {% if item.router_preference.state is defined and item.router_preference.state == "absent" %} +no router-preference maximum + {% else %} +router-preference maximum {{ item.router_preference.value }} + {% endif %} + {% endif %} + {% if item.match is defined and item.match %} + {% for item1 in item.match %} + {% if item1.type is defined %} + {% if item1.type == "prefix_list" %} + {% if item1.state is defined and item1.state == "absent" %} +no match ra ipv6-prefix-list {{ item1.name }} + {% else %} +match ra ipv6-prefix-list {{ item1.name }} + {% endif %} + {% endif %} + {% if item1.type == "access_list" %} + {% if item1.state is defined and item1.state == "absent" %} +no match ra ipv6-access-list {{ item1.name }} + {% else %} +match ra ipv6-access-list {{ item1.name }} + {% endif %} + {% endif %} + {% if item1.type == "mac_list" %} + {% if item1.state is defined and item1.state == "absent" %} +no match ra mac-access-list {{ item1.name }} + {% else %} +match ra mac-access-list {{ item1.name }} + {% endif %} + {% endif %} + {% endif %} + {% endfor %} + {% endif %} + {% endif %} + {% endif %} + {% endif %} + {% endfor %} + {% endif %} + {% if os10_raguard.intf is defined and os10_raguard.intf %} + {% for key in os10_raguard.intf.keys() %} +interface {{ key }} + {% if os10_raguard.intf[key].policy_name is defined and os10_raguard.intf[key].policy_name %} + {% if os10_raguard.intf[key].state is defined and os10_raguard.intf[key].state == "absent" %} +no ipv6 nd ra-guard attach-policy {{ os10_raguard.intf[key].policy_name }} vlan {{ os10_raguard.intf[key].vlan }} + {% else %} +ipv6 nd ra-guard attach-policy {{ os10_raguard.intf[key].policy_name }} vlan {{ os10_raguard.intf[key].vlan }} + {% endif %} + {% endif %} + {% endfor %} + {% endif %} +{% endif %} diff --git a/roles/os10_raguard/tests/inventory.yaml b/roles/os10_raguard/tests/inventory.yaml new file mode 100644 index 0000000..85a255f --- /dev/null +++ b/roles/os10_raguard/tests/inventory.yaml @@ -0,0 +1,2 @@ +--- +localhost diff --git a/roles/os10_raguard/tests/main.os10.yaml b/roles/os10_raguard/tests/main.os10.yaml new file mode 100644 index 0000000..0d7baf3 --- /dev/null +++ b/roles/os10_raguard/tests/main.os10.yaml @@ -0,0 +1,56 @@ +--- +# vars file for dellemc_networking.os10.os10_raguard, +# below gives a sample configuration +# Sample variables for OS10 device +os10_raguard: + enable: true + policy: + - policy_name: test + device_role: + value: router + state: present + managed_config_flag: + value: "on" + state: present + other_config_flag: + value: "on" + state: present + mtu: + value: 1280 + state: present + reachable_time: + value: 100 + state: present + retrans_timer: + value: 100 + state: present + router_lifetime: + value: 10 + state: present + router_preference: + value: high + state: present + match: + - type: prefix_list + name: test_prefix + state: present + - type: access_list + name: test_access + state: present + - type: mac_list + name: test_mac + state: present + state: present + intf: + ethernet 1/1/2: + policy_name: test + vlan: 10 + state: present + ethernet 1/1/3: + policy_name: test + vlan: all + state: present + ethernet 1/1/4: + policy_name: test + vlan: 10,11,12,15 + state: present diff --git a/roles/os10_raguard/tests/test.yaml b/roles/os10_raguard/tests/test.yaml new file mode 100644 index 0000000..7620f2d --- /dev/null +++ b/roles/os10_raguard/tests/test.yaml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + connection: network_cli + roles: + - dellemc_networking.os10.os10_raguard diff --git a/roles/os10_raguard/vars/main.yml b/roles/os10_raguard/vars/main.yml new file mode 100644 index 0000000..5bf0fca --- /dev/null +++ b/roles/os10_raguard/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for dellemc_networking.os10.os10_raguard