diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/dellemc/enterprise_sonic/plugins/modules | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/dellemc/enterprise_sonic/plugins/modules')
29 files changed, 8925 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/__init__.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/__init__.py diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_aaa.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_aaa.py new file mode 100644 index 000000000..ddc71331f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_aaa.py @@ -0,0 +1,215 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_aaa +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = """ +--- +module: sonic_aaa +version_added: 1.1.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Abirami N (@abirami-n) +short_description: Manage AAA and its parameters +description: + - This module is used for configuration management of aaa parameters on devices running Enterprise SONiC. +options: + config: + description: + - Specifies the aaa related configurations + type: dict + suboptions: + authentication: + description: + - Specifies the configurations required for aaa authentication + type: dict + suboptions: + data: + description: + - Specifies the data required for aaa authentication + type: dict + suboptions: + fail_through: + description: + - Specifies the state of failthrough + type: bool + local: + description: + - Enable or Disable local authentication + type: bool + group: + description: + - Specifies the method of aaa authentication + type: str + choices: + - ldap + - radius + - tacacs+ + + state: + description: + - Specifies the operation to be performed on the aaa parameters configured on the device. + - In case of merged, the input configuration will be merged with the existing aaa configuration on the device. + - In case of deleted the existing aaa configuration will be removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +# do show aaa +# AAA Authentication Information +# --------------------------------------------------------- +# failthrough : True +# login-method : local + +- name: Delete aaa configurations + dellemc.enterprise_sonic.sonic_aaa: + config: + authentication: + data: + local: True + state: deleted + +# After state: +# ------------ +# +# do show aaa +# AAA Authentication Information +# --------------------------------------------------------- +# failthrough : True +# login-method : + + +# Using deleted +# +# Before state: +# ------------- +# +# do show aaa +# AAA Authentication Information +# --------------------------------------------------------- +# failthrough : True +# login-method : local + +- name: Delete aaa configurations + dellemc.enterprise_sonic.sonic_aaa: + config: + state: deleted + +# After state: +# ------------ +# +# do show aaa +# AAA Authentication Information +# --------------------------------------------------------- +# failthrough : +# login-method : + + +# Using merged +# +# Before state: +# ------------- +# +# do show aaa +# AAA Authentication Information +# --------------------------------------------------------- +# failthrough : False +# login-method : + +- name: Merge aaa configurations + dellemc.enterprise_sonic.sonic_aaa: + config: + authentication: + data: + local: true + fail_through: true + state: merged + +# After state: +# ------------ +# +# do show aaa +# AAA Authentication Information +# --------------------------------------------------------- +# failthrough : True +# login-method : local + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.aaa.aaa import AaaArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.aaa.aaa import Aaa + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=AaaArgs.argument_spec, + supports_check_mode=True) + + result = Aaa(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_api.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_api.py new file mode 100644 index 000000000..234603a0a --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_api.py @@ -0,0 +1,158 @@ +#!/usr/bin/python +# +# (c) 2015 Peter Sprygada, <psprygada@ansible.com> +# Copyright (c) 2020 Dell Inc. +# +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" +The module file for sonic_vlans +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_api +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Abirami N (@abirami-n) +short_description: Manages REST operations on devices running Enterprise SONiC +description: + - Manages REST operations on devices running Enterprise SONiC Distribution + by Dell Technologies. This module provides an implementation for working + with SONiC REST operations in a deterministic way. +options: + url: + description: + - The HTTP path of the request after 'restconf/'. + type: path + required: true + body: + description: + - The body of the HTTP request/response to the web service which contains the payload. + type: raw + method: + description: + - The HTTP method of the request or response. Must be a valid method + accepted by the service that handles the request. + type: str + required: true + choices: ['GET', 'PUT', 'POST', 'PATCH', 'DELETE'] + status_code: + description: + - A list of valid, numeric, HTTP status codes that signifies the success of a request. + type: list + elements: int + required: true +""" +EXAMPLES = """ +- name: Checks that you can connect (GET) to a page and it returns a status 200 + dellemc.enterprise_sonic.sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet60 + method: "GET" + status_code: 200 + +- name: Appends data to an existing interface using PATCH and verifies if it returns status 204 + dellemc.enterprise_sonic.sonic_api: + url: data/openconfig-interfaces:interfaces/interface=Ethernet60/config/description + method: "PATCH" + body: {"openconfig-interfaces:description": "Eth-60"} + status_code: 204 + +- name: Deletes an associated IP address using DELETE and verifies if it returns status 204 + dellemc.enterprise_sonic.sonic_api: + url: > + data/openconfig-interfaces:interfaces/interface=Ethernet64/subinterfaces/subinterface=0/ + openconfig-if-ip:ipv4/addresses/address=1.1.1.1/config/prefix-length + method: "DELETE" + status_code: 204 + +- name: Adds a VLAN network instance using PUT and verifies if it returns status 204 + dellemc.enterprise_sonic.sonic_api: + url: data/openconfig-network-instance:network-instances/network-instance=Vlan100/ + method: "PUT" + body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100","config": {"name": "Vlan100"}}]} + status_code: 204 + +- name: Adds a prefix-set to a routing policy using POST and verifies if it returns 201 + dellemc.enterprise_sonic.sonic_api: + url: data/openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set=p1 + method: "POST" + body: {"openconfig-routing-policy:config": {"name": "p1","mode": "IPV4" }} + status_code: 201 + +""" +RETURN = """ +response: + description: The response at the network device end for the REST call which contains the status code. + returned: always + type: list + sample: {"response": [ 204,{""}]} +msg: + description: The HTTP error message from the request. + returned: HTTP Error + type: str +""" + +from ansible.module_utils.connection import ConnectionError + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic import edit_config, to_request + + +def initiate_request(module): + """Get all the data available in chassis""" + url = module.params['url'] + body = module.params['body'] + method = module.params['method'] + if method == "GET" or method == "DELETE": + request = to_request(module, [{"path": url, "method": method}]) + elif method == "PATCH" or method == "PUT" or method == "POST": + request = to_request(module, [{"path": url, "method": method, "data": body}]) + + try: + response = edit_config(module, request) + except ConnectionError as exc: + module.fail_json(msg=to_text(exc)) + return response + + +def main(): + + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + argument_spec = dict( + url=dict(type='path', required=True), + body=dict(type='raw', required=False), + method=dict(type='str', choices=['GET', 'PUT', 'PATCH', 'DELETE', 'POST'], required=True), + status_code=dict(type='list', elements='int', required=True), + ) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + result = dict( + changed=False, + ) + response = initiate_request(module) + response_code = response[0][0] + status_code = module.params['status_code'] + if response_code == int(status_code[0]) and response_code in (201, 204): + result.update({'changed': True}) + + result.update({ + 'response': response, + }) + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp.py new file mode 100644 index 000000000..bc53ca40c --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp.py @@ -0,0 +1,390 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_bgp +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Dhivya P (@dhivayp) +short_description: Manage global BGP and its parameters +description: + - This module provides configuration management of global BGP parameters on devices running Enterprise SONiC Distribution by Dell Technologies. +options: + config: + description: + - Specifies the BGP-related configuration. + type: list + elements: dict + suboptions: + bgp_as: + description: + - Specifies the BGP autonomous system (AS) number to configure on the device. + type: str + required: true + vrf_name: + description: + - Specifies the VRF name. + type: str + default: 'default' + router_id: + description: + - Configures the BGP routing process router-id value. + type: str + log_neighbor_changes: + description: + - Enables/disables logging neighbor up/down and reset reason. + type: bool + max_med: + description: + - Configure max med and its parameters + type: dict + suboptions: + on_startup: + description: + - On startup time and max-med value + type: dict + suboptions: + timer: + description: + - Configures on startup time + type: int + med_val: + description: + - on startup med value + type: int + timers: + description: + - Adjust routing timers + type: dict + suboptions: + holdtime: + description: + - Configures hold-time + type: int + keepalive_interval: + description: + - Configures keepalive-interval + type: int + bestpath: + description: + - Configures the BGP best-path. + type: dict + suboptions: + as_path: + description: + - Configures the as-path values. + type: dict + suboptions: + confed: + description: + - Configures the confed values of as-path. + type: bool + ignore: + description: + - Configures the ignore values of as-path. + type: bool + multipath_relax: + description: + - Configures the multipath_relax values of as-path. + type: bool + multipath_relax_as_set: + description: + - Configures the multipath_relax_as_set values of as-path. + type: bool + compare_routerid: + description: + - Configures the compare_routerid. + type: bool + med: + description: + - Configures the med values. + type: dict + suboptions: + confed: + description: + - Configures the confed values of med. + type: bool + missing_as_worst: + description: + - Configures the missing_as_worst values of as-path. + type: bool + always_compare_med: + description: + - Allows comparing meds from different neighbors if set to true + type: bool + state: + description: + - Specifies the operation to be performed on the BGP process that is configured on the device. + - In case of merged, the input configuration is merged with the existing BGP configuration on the device. + - In case of deleted, the existing BGP configuration is removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#! +#router bgp 10 vrf VrfCheck1 +# router-id 10.2.2.32 +# log-neighbor-changes +#! +#router bgp 11 vrf VrfCheck2 +# log-neighbor-changes +# bestpath as-path ignore +# bestpath med missing-as-worst confed +# bestpath compare-routerid +#! +#router bgp 4 +# router-id 10.2.2.4 +# bestpath as-path ignore +# bestpath as-path confed +# bestpath med missing-as-worst confed +# bestpath compare-routerid +#! +# +- name: Delete BGP Global attributes + dellemc.enterprise_sonic.sonic_bgp: + config: + - bgp_as: 4 + router_id: 10.2.2.4 + log_neighbor_changes: False + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: False + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + - bgp_as: 10 + router_id: 10.2.2.32 + log_neighbor_changes: True + vrf_name: 'VrfCheck1' + - bgp_as: 11 + log_neighbor_changes: True + vrf_name: 'VrfCheck2' + bestpath: + as_path: + confed: False + ignore: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + state: deleted + + +# After state: +# ------------ +# +#! +#router bgp 10 vrf VrfCheck1 +# log-neighbor-changes +#! +#router bgp 11 vrf VrfCheck2 +# log-neighbor-changes +# bestpath compare-routerid +#! +#router bgp 4 +# log-neighbor-changes +# bestpath compare-routerid +#! + + +# Using deleted +# +# Before state: +# ------------- +# +#! +#router bgp 10 vrf VrfCheck1 +# router-id 10.2.2.32 +# log-neighbor-changes +#! +#router bgp 11 vrf VrfCheck2 +# log-neighbor-changes +# bestpath as-path ignore +# bestpath med missing-as-worst confed +# bestpath compare-routerid +#! +#router bgp 4 +# router-id 10.2.2.4 +# bestpath as-path ignore +# bestpath as-path confed +# bestpath med missing-as-worst confed +# bestpath compare-routerid +#! + +- name: Deletes all the bgp global configurations + dellemc.enterprise_sonic.sonic_bgp: + config: + state: deleted + +# After state: +# ------------ +# +#! +#! + + +# Using merged +# +# Before state: +# ------------- +# +#! +#router bgp 4 +# router-id 10.1.1.4 +#! +# +- name: Merges provided configuration with device configuration + dellemc.enterprise_sonic.sonic_bgp: + config: + - bgp_as: 4 + router_id: 10.2.2.4 + log_neighbor_changes: False + timers: + holdtime: 20 + keepalive_interval: 30 + bestpath: + as_path: + confed: True + ignore: True + multipath_relax: False + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + always_compare_med: True + max_med: + on_startup: + timer: 667 + med_val: 7878 + - bgp_as: 10 + router_id: 10.2.2.32 + log_neighbor_changes: True + vrf_name: 'VrfCheck1' + - bgp_as: 11 + log_neighbor_changes: True + vrf_name: 'VrfCheck2' + bestpath: + as_path: + confed: False + ignore: True + multipath_relax_as_set: True + compare_routerid: True + med: + confed: True + missing_as_worst: True + state: merged +# +# After state: +# ------------ +# +#! +#router bgp 10 vrf VrfCheck1 +# router-id 10.2.2.32 +# log-neighbor-changes +#! +#router bgp 11 vrf VrfCheck2 +# log-neighbor-changes +# bestpath as-path ignore +# bestpath med missing-as-worst confed +# bestpath compare-routerid +#! +#router bgp 4 +# router-id 10.2.2.4 +# bestpath as-path ignore +# bestpath as-path confed +# bestpath med missing-as-worst confed +# bestpath compare-routerid +# always-compare-med +# max-med on-startup 667 7878 +# timers 20 30 +# +#! + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp.bgp import BgpArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp.bgp import Bgp + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=BgpArgs.argument_spec, + supports_check_mode=True) + + result = Bgp(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_af.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_af.py new file mode 100644 index 000000000..6d55355c9 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_af.py @@ -0,0 +1,414 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp_af +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = """ +--- +module: sonic_bgp_af +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Niraimadaiselvam M (@niraimadaiselvamm) +short_description: Manage global BGP address-family and its parameters +description: + - This module provides configuration management of global BGP_AF parameters on devices running Enterprise SONiC. + - bgp_as and vrf_name must be created in advance on the device. +options: + config: + description: + - Specifies the BGP_AF related configuration. + type: list + elements: dict + suboptions: + bgp_as: + description: + - Specifies the BGP autonomous system (AS) number which is already configured on the device. + type: str + required: true + vrf_name: + description: + - Specifies the VRF name which is already configured on the device. + type: str + default: 'default' + address_family: + description: + - Specifies BGP address family related configurations. + type: dict + suboptions: + afis: + description: + - List of address families, such as ipv4, ipv6, and l2vpn. + - afi and safi are required together. + type: list + elements: dict + suboptions: + afi: + description: + - Type of address family to configure. + type: str + choices: + - ipv4 + - ipv6 + - l2vpn + required: True + safi: + description: + - Specifies the type of communication for the address family. + type: str + choices: + - unicast + - evpn + default: unicast + dampening: + description: + - Enable route flap dampening if set to true + type: bool + network: + description: + - Enable routing on an IP network for each prefix provided in the network + type: list + elements: str + redistribute: + description: + - Specifies the redistribute information from another routing protocol. + type: list + elements: dict + suboptions: + protocol: + description: + - Specifies the protocol for configuring redistribute information. + type: str + choices: ['ospf', 'static', 'connected'] + required: True + metric: + description: + - Specifies the metric for redistributed routes. + type: str + route_map: + description: + - Specifies the route map reference. + type: str + advertise_pip: + description: + - Enables advertise PIP + type: bool + advertise_pip_ip: + description: + - PIP IPv4 address + type: str + advertise_pip_peer_ip: + description: + - PIP peer IPv4 address + type: str + advertise_svi_ip: + description: + - Enables advertise SVI MACIP routes + type: bool + route_advertise_list: + description: + - List of advertise routes + type: list + elements: dict + suboptions: + advertise_afi: + required: True + type: str + choices: + - ipv4 + - ipv6 + description: + - Specifies the address family + route_map: + type: str + description: + - Specifies the route-map reference + advertise_default_gw: + description: + - Specifies the advertise default gateway flag. + type: bool + advertise_all_vni: + description: + - Specifies the advertise all vni flag. + type: bool + max_path: + description: + - Specifies the maximum paths of ibgp and ebgp count. + type: dict + suboptions: + ibgp: + description: + - Specifies the count of the ibgp multipaths count. + type: int + ebgp: + description: + - Specifies the count of the ebgp multipaths count. + type: int + state: + description: + - Specifies the operation to be performed on the BGP_AF process configured on the device. + - In case of merged, the input configuration is merged with the existing BGP_AF configuration on the device. + - In case of deleted, the existing BGP_AF configuration is removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#do show running-configuration bgp +#! +#router bgp 51 +# router-id 111.2.2.41 +# timers 60 180 +# ! +# address-family ipv4 unicast +# maximum-paths 1 +# maximum-paths ibgp 1 +# dampening +# ! +# address-family ipv6 unicast +# redistribute connected route-map bb metric 21 +# redistribute ospf route-map aa metric 27 +# redistribute static route-map bb metric 26 +# maximum-paths 4 +# maximum-paths ibgp 5 +# ! +# address-family l2vpn evpn +# advertise-svi-ip +# advertise ipv6 unicast route-map aa +# advertise-pip ip 1.1.1.1 peer-ip 2.2.2.2 +#! +# +- name: Delete BGP Address family configuration from the device + dellemc.enterprise_sonic.sonic_bgp_af: + config: + - bgp_as: 51 + address_family: + afis: + - afi: l2vpn + safi: evpn + advertise_pip: True + advertise_pip_ip: "1.1.1.1" + advertise_pip_peer_ip: "2.2.2.2" + advertise_svi_ip: True + advertise_all_vni: False + advertise_default_gw: False + route_advertise_list: + - advertise_afi: ipv6 + route_map: aa + - afi: ipv4 + safi: unicast + - afi: ipv6 + safi: unicast + max_path: + ebgp: 2 + ibgp: 5 + redistribute: + - metric: "21" + protocol: connected + route_map: bb + - metric: "27" + protocol: ospf + route_map: aa + - metric: "26" + protocol: static + route_map: bb + state: deleted + +# After state: +# ------------ +# +#do show running-configuration bgp +#! +#router bgp 51 +# router-id 111.2.2.41 +# timers 60 180 +# ! +# address-family ipv6 unicast +# ! +# address-family l2vpn evpn +# +# Using deleted +# +# Before state: +# ------------- +# +#do show running-configuration bgp +#! +#router bgp 51 +# router-id 111.2.2.41 +# timers 60 180 +# ! +# address-family ipv6 unicast +# ! +# address-family l2vpn evpn +# +- name: Delete All BGP address family configurations + dellemc.enterprise_sonic.sonic_bgp_af: + config: + state: deleted + + +# After state: +# ------------ +# +#do show running-configuration bgp +#! +#router bgp 51 +# router-id 111.2.2.41 +# timers 60 180 +# +# Using merged +# +# Before state: +# ------------- +# +#do show running-configuration bgp +#! +#router bgp 51 +# router-id 111.2.2.41 +# timers 60 180 +# ! +# address-family l2vpn evpn +# +- name: Merge provided BGP address family configuration on the device. + dellemc.enterprise_sonic.sonic_bgp_af: + config: + - bgp_as: 51 + address_family: + afis: + - afi: l2vpn + safi: evpn + advertise_pip: True + advertise_pip_ip: "3.3.3.3" + advertise_pip_peer_ip: "4.4.4.4" + advertise_svi_ip: True + advertise_all_vni: False + advertise_default_gw: False + route_advertise_list: + - advertise_afi: ipv4 + route_map: bb + - afi: ipv4 + safi: unicast + network: + - 2.2.2.2/16 + - 192.168.10.1/32 + dampening: True + - afi: ipv6 + safi: unicast + max_path: + ebgp: 4 + ibgp: 5 + redistribute: + - metric: "21" + protocol: connected + route_map: bb + - metric: "27" + protocol: ospf + route_map: aa + - metric: "26" + protocol: static + route_map: bb + state: merged +# After state: +# ------------ +# +#do show running-configuration bgp +#! +#router bgp 51 +# router-id 111.2.2.41 +# timers 60 180 +# ! +# address-family ipv4 unicast +# network 2.2.2.2/16 +# network 192.168.10.1/32 +# dampening +# ! +# address-family ipv6 unicast +# redistribute connected route-map bb metric 21 +# redistribute ospf route-map aa metric 27 +# redistribute static route-map bb metric 26 +# maximum-paths 4 +# maximum-paths ibgp 5 +# ! +# address-family l2vpn evpn +# advertise-svi-ip +# advertise ipv4 unicast route-map bb +# advertise-pip ip 3.3.3.3 peer-ip 4.4.4.4 +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_af.bgp_af import Bgp_afArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_af.bgp_af import Bgp_af + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Bgp_afArgs.argument_spec, + supports_check_mode=True) + + result = Bgp_af(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_as_paths.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_as_paths.py new file mode 100644 index 000000000..bd2ff74a1 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_as_paths.py @@ -0,0 +1,224 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp_as_paths +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_bgp_as_paths +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage BGP autonomous system path (or as-path-list) and its parameters +description: + - This module provides configuration management of BGP bgp_as_paths for devices + running Enterprise SONiC Distribution by Dell Technologies. +author: Kumaraguru Narayanan (@nkumaraguru) +options: + config: + description: A list of 'bgp_as_paths' configurations. + type: list + elements: dict + suboptions: + name: + required: True + type: str + description: + - Name of as-path-list. + members: + required: False + type: list + elements: str + description: + - Members of this BGP as-path; regular expression string can be provided. + permit: + required: False + type: bool + description: + - Permits or denies this as path. + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted + +# Before state: +# ------------- +# +# show bgp as-path-access-list +# AS path list test: +# action: permit +# members: 808.*,909.* + +- name: Delete BGP as path list + dellemc.enterprise_sonic.sonic_bgp_as_paths: + config: + - name: test + members: + - 909.* + permit: true + state: deleted + +# After state: +# ------------ +# +# show bgp as-path-access-list +# AS path list test: +# action: +# members: 808.* + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp as-path-access-list +# AS path list test: +# action: permit +# members: 808.*,909.* +# AS path list test1: +# action: deny +# members: 608.*,709.* + +- name: Deletes BGP as-path list + dellemc.enterprise_sonic.sonic_bgp_as_paths: + config: + - name: test + members: + state: deleted + +# After state: +# ------------ +# +# show bgp as-path-access-list +# AS path list test1: +# action: deny +# members: 608.*,709.* + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp as-path-access-list +# AS path list test: +# action: permit +# members: 808.*,909.* + +- name: Deletes BGP as-path list + dellemc.enterprise_sonic.sonic_bgp_as_paths: + config: + state: deleted + +# After state: +# ------------ +# +# show bgp as-path-access-list +# (No bgp as-path-access-list configuration present) + + +# Using merged + +# Before state: +# ------------- +# +# show bgp as-path-access-list +# AS path list test: + +- name: Adds 909.* to test as-path list + dellemc.enterprise_sonic.sonic_bgp_as_paths: + config: + - name: test + members: + - 909.* + permit: true + state: merged + +# After state: +# ------------ +# +# show bgp as-path-access-list +# AS path list test: +# action: permit +# members: 909.* + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_as_paths.bgp_as_paths import Bgp_as_pathsArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_as_paths.bgp_as_paths import Bgp_as_paths + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Bgp_as_pathsArgs.argument_spec, + supports_check_mode=True) + + result = Bgp_as_paths(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_communities.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_communities.py new file mode 100644 index 000000000..08c8dcc7f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_communities.py @@ -0,0 +1,301 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp_communities +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = """ +--- +module: sonic_bgp_communities +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage BGP community and its parameters +description: + - This module provides configuration management of BGP bgp_communities for device + running Enterprise SONiC Distribution by Dell Technologies. +author: Kumaraguru Narayanan (@nkumaraguru) +options: + config: + description: A list of 'bgp_communities' configurations. + type: list + elements: dict + suboptions: + name: + required: True + type: str + description: + - Name of the BGP communitylist. + type: + type: str + description: + - Whether it is a standard or expanded community-list entry. + required: False + choices: + - standard + - expanded + default: standard + permit: + required: False + type: bool + description: + - Permits or denies this community. + aann: + required: False + type: str + description: + - Community number aa:nn format 0..65535:0..65535; applicable for standard BGP community type. + local_as: + required: False + type: bool + description: + - Do not send outside local AS (well-known community); applicable for standard BGP community type. + no_advertise: + required: False + type: bool + description: + - Do not advertise to any peer (well-known community); applicable for standard BGP community type. + no_export: + required: False + type: bool + description: + - Do not export to next AS (well-known community); applicable for standard BGP community type. + no_peer: + required: False + type: bool + description: + - Do not export to next AS (well-known community); applicable for standard BGP community type. + members: + required: False + type: dict + suboptions: + regex: + type: list + elements: str + required: False + description: + - Members of this BGP community list. Regular expression string can be given here. Applicable for expanded BGP community type. + description: + - Members of this BGP community list. + match: + required: False + type: str + description: + - Matches any/all of the members. + choices: + - ALL + - ANY + default: ANY + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted + +# Before state: +# ------------- +# +# show bgp community-list +# Standard community list test: match: ANY +# 101 +# 201 +# Standard community list test1: match: ANY +# 301 + +- name: Deletes BGP community member + dellemc.enterprise_sonic.sonic_bgp_communities: + config: + - name: test + members: + regex: + - 201 + state: deleted + +# After state: +# ------------ +# +# show bgp community-list +# Standard community list test: match: ANY +# 101 +# Standard community list test1: match: ANY +# 301 + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp community-list +# Standard community list test: match: ANY +# 101 +# Expanded community list test1: match: ANY +# 201 + +- name: Deletes a single BGP community + dellemc.enterprise_sonic.sonic_bgp_communities: + config: + - name: test + members: + state: deleted + +# After state: +# ------------ +# +# show bgp community-list +# Expanded community list test1: match: ANY +# 201 + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp community-list +# Standard community list test: match: ANY +# 101 +# Expanded community list test1: match: ANY +# 201 + +- name: Delete All BGP communities + dellemc.enterprise_sonic.sonic_bgp_communities: + config: + state: deleted + +# After state: +# ------------ +# +# show bgp community-list +# + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp community-list +# Standard community list test: match: ANY +# 101 +# Expanded community list test1: match: ANY +# 201 + +- name: Deletes all members in a single BGP community + dellemc.enterprise_sonic.sonic_bgp_communities: + config: + - name: test + members: + regex: + state: deleted + +# After state: +# ------------ +# +# show bgp community-list +# Expanded community list test: match: ANY +# Expanded community list test1: match: ANY +# 201 + + +# Using merged + +# Before state: +# ------------- +# +# show bgp as-path-access-list +# AS path list test: + +- name: Adds 909.* to test as-path list + dellemc.enterprise_sonic.sonic_bgp_as_paths: + config: + - name: test + members: + - 909.* + state: merged + +# After state: +# ------------ +# +# show bgp as-path-access-list +# AS path list test: +# members: 909.* + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration that is returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration that is returned is always in the same format + of the parameters above. +commands: + description: The set of commands that are pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_communities.bgp_communities import Bgp_communitiesArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_communities.bgp_communities import Bgp_communities + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Bgp_communitiesArgs.argument_spec, + supports_check_mode=True) + + result = Bgp_communities(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_ext_communities.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_ext_communities.py new file mode 100644 index 000000000..c2af0c488 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_ext_communities.py @@ -0,0 +1,288 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp_ext_communities +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_bgp_ext_communities +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage BGP extended community-list and its parameters +description: + - This module provides configuration management of BGP extcommunity-list for devices running + Enterprise SONiC Distribution by Dell Technologies. +author: Kumaraguru Narayanan (@nkumaraguru) +options: + config: + description: A list of 'bgp_extcommunity_list' configurations. + type: list + elements: dict + suboptions: + name: + required: True + type: str + description: + - Name of the BGP ext communitylist. + type: + type: str + description: + - Whether it is a standard or expanded ext community_list entry. + required: False + choices: + - standard + - expanded + default: standard + permit: + required: False + type: bool + description: + - Permits or denies this community. + members: + required: False + type: dict + suboptions: + regex: + type: list + elements: str + required: False + description: + - Members of this BGP ext community list. Regular expression string can be given here. Applicable for expanded ext BGP community type. + route_target: + type: list + elements: str + required: False + description: + - Members of this BGP ext community list. The format of route_target is in either 0..65535:0..65535 or A.B.C.D:[1..65535] format. + route_origin: + type: list + elements: str + required: False + description: + - Members of this BGP ext community list. The format of route_origin is in either 0..65535:0..65535 or A.B.C.D:[1..65535] format. + description: + - Members of this BGP ext community list. + match: + required: False + type: str + description: + - Matches any/all of the the members. + choices: + - all + - any + default: any + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted + +# Before state: +# ------------- +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# rt:101:101 +# rt:201:201 + +- name: Deletes a BGP ext community member + dellemc.enterprise_sonic.sonic_bgp_ext_communities: + config: + - name: test + members: + regex: + - 201:201 + state: deleted + +# After state: +# ------------ +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# rt:101:101 +# + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# 101 +# Expanded extended community list test1: match: ANY +# 201 + +- name: Deletes a single BGP extended community + dellemc.enterprise_sonic.sonic_bgp_ext_communities: + config: + - name: test1 + members: + state: deleted + +# After state: +# ------------ +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# 101 +# + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# 101 +# Expanded extended community list test1: match: ANY +# 201 + +- name: Deletes all BGP extended communities + dellemc.enterprise_sonic.sonic_bgp_ext_communities: + config: + state: deleted + +# After state: +# ------------ +# +# show bgp ext-community-list +# + + +# Using deleted + +# Before state: +# ------------- +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# 101 +# Expanded extended community list test1: match: ANY +# 201 + +- name: Deletes all members in a single BGP extended community + dellemc.enterprise_sonic.sonic_bgp_ext_communities: + config: + - name: test1 + members: + regex: + state: deleted + +# After state: +# ------------ +# +# show bgp ext-community-list +# Standard extended community list test: match: ANY +# 101 +# Expanded extended community list test1: match: ANY +# + + +# Using merged + +# Before state: +# ------------- +# +# show bgp as-path-access-list +# AS path list test: + +- name: Adds 909.* to test as-path list + dellemc.enterprise_sonic.sonic_bgp_as_paths: + config: + - name: test + members: + - 909.* + state: merged + +# After state: +# ------------ +# +# show bgp as-path-access-list +# AS path list test: +# members: 909.* + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_ext_communities.bgp_ext_communities import ( + Bgp_ext_communitiesArgs, +) +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_ext_communities.bgp_ext_communities import Bgp_ext_communities + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Bgp_ext_communitiesArgs.argument_spec, + supports_check_mode=True) + + result = Bgp_ext_communities(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_neighbors.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_neighbors.py new file mode 100644 index 000000000..19aeb6fc9 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_neighbors.py @@ -0,0 +1,1112 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp_neighbors +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_bgp_neighbors +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage a BGP neighbor and its parameters +description: + - This module provides configuration management of global BGP_NEIGHBORS parameters on devices running Enterprise SONiC. + - bgp_as and vrf_name must be created on the device in advance. +author: Abirami N (@abirami-n) +options: + config: + description: Specifies the BGP neighbors related configuration. + type: list + elements: dict + suboptions: + bgp_as: + description: + - Specifies the BGP autonomous system (AS) number which is already configured on the device. + type: str + required: True + vrf_name: + description: + - Specifies the VRF name which is already configured on the device. + default: default + type: str + peer_group: + description: Specifies the list of peer groups. + type: list + elements: dict + suboptions: + name: + description: Name of the peer group. + type: str + required: True + remote_as: + description: + - Remote AS of the BGP peer group to configure. + - peer_as and peer_type are mutually exclusive. + type: dict + suboptions: + peer_as: + description: + - Specifies remote AS number. + - The range is from 1 to 4294967295. + type: int + peer_type: + description: + - Specifies the type of BGP peer. + type: str + choices: + - internal + - external + bfd: + description: + - Enables or disables BFD. + type: dict + suboptions: + enabled: + description: + - Enables BFD liveliness check for a BGP peer. + type: bool + check_failure: + description: + - Link dataplane status with control plane. + type: bool + profile: + description: + - BFD Profile name. + type: str + advertisement_interval: + description: + - Specifies the minimum interval between sending BGP routing updates. + - The range is from 0 to 600. + type: int + timers: + description: + - Specifies BGP peer group timer related configurations. + type: dict + suboptions: + keepalive: + description: + - Frequency with which the device sends keepalive messages to its peer, in seconds. + - The range is from 0 to 65535. + type: int + holdtime: + description: + - Interval after not receiving a keepalive message that Enterprise SONiC declares a peer dead, in seconds. + - The range is from 0 to 65535. + type: int + connect_retry: + description: + - Time interval in seconds between attempts to establish a session with the peer. + - The range is from 1 to 65535. + type: int + capability: + description: + - Specifies capability attributes to this peer group. + type: dict + suboptions: + dynamic: + description: + - Enables or disables dynamic capability to this peer group. + type: bool + extended_nexthop: + description: + - Enables or disables advertise extended next-hop capability to the peer. + type: bool + auth_pwd: + description: + - Configuration for peer group authentication password. + type: dict + suboptions: + pwd: + description: + - Authentication password for the peer group. + type: str + required: True + encrypted: + description: + - Indicates whether the password is encrypted text. + type: bool + default: False + pg_description: + description: + - A textual description of the peer group. + type: str + disable_connected_check: + description: + - Disables EBGP conntected route check. + type: bool + dont_negotiate_capability: + description: + - Disables capability negotiation. + type: bool + ebgp_multihop: + description: + - Allow EBGP peers not on directly connected networks. + type: dict + suboptions: + enabled: + description: + - Enables the referenced group or peers to be indirectly connected. + type: bool + default: False + multihop_ttl: + description: + - Time-to-live value to use when packets are sent to the referenced group or peers and ebgp-multihop is enabled. + type: int + enforce_first_as: + description: + - Enforces the first AS for EBGP routes. + type: bool + enforce_multihop: + description: + - Enforces EBGP multihop performance for peer. + type: bool + local_address: + description: + - Set the local IP address to use for the session when sending BGP update messages. + type: str + local_as: + description: + - Specifies local autonomous system number. + type: dict + suboptions: + as: + description: + - Local autonomous system number. + type: int + required: True + no_prepend: + description: + - Do not prepend the local-as number in AS-Path advertisements. + type: bool + replace_as: + description: + - Replace the configured AS Number with the local-as number in AS-Path advertisements. + type: bool + override_capability: + description: + - Override capability negotiation result. + type: bool + passive: + description: + - Do not send open messages to this peer. + type: bool + default: False + shutdown_msg: + description: + - Add a shutdown message. + type: str + solo: + description: + - Indicates that routes advertised by the peer should not be reflected back to the peer. + type: bool + strict_capability_match: + description: + - Enables strict capability negotiation match. + type: bool + ttl_security: + description: + - Enforces only the peers that are specified number of hops away will be allowed to become peers. + type: int + address_family: + description: + - Holds of list of address families associated to the peergroup. + type: dict + suboptions: + afis: + description: + - List of address families with afi, safi, activate and allowas-in parameters. + - afi and safi are required together. + type: list + elements: dict + suboptions: + afi: + description: + - Holds afi mode. + type: str + choices: + - ipv4 + - ipv6 + - l2vpn + safi: + description: + - Holds safi mode. + type: str + choices: + - unicast + - evpn + activate: + description: + - Enable or disable activate. + type: bool + allowas_in: + description: + - Holds AS value. + - The origin and value are mutually exclusive. + type: dict + suboptions: + origin: + description: + - Set AS as the origin. + type: bool + value: + description: + - Holds AS number in the range 1-10. + type: int + ip_afi: + description: + - Common configuration attributes for IPv4 and IPv6 unicast address families. + type: dict + suboptions: + default_policy_name: + description: + - Specifies routing policy definition. + type: str + send_default_route: + description: + - Enable or disable sending of default-route to the peer. + type: bool + default: False + prefix_limit: + description: + - Specifies prefix limit attributes. + type: dict + suboptions: + max_prefixes: + description: + - Maximum number of prefixes that will be accepted from the peer. + type: int + prevent_teardown: + description: + - Enable or disable teardown of BGP session when maximum prefix limit is exceeded. + type: bool + default: False + warning_threshold: + description: + - Threshold on number of prefixes that can be received from a peer before generation of warning messages. + - Expressed as a percentage of max-prefixes. + type: int + restart_timer: + description: + - Time interval in seconds after which the BGP session is re-established after being torn down. + type: int + prefix_list_in: + description: + - Inbound route filtering policy for a peer. + type: str + prefix_list_out: + description: + - Outbound route filtering policy for a peer. + type: str + neighbors: + description: Specifies BGP neighbor-related configurations. + type: list + elements: dict + suboptions: + neighbor: + description: + - Neighbor router address. + type: str + required: True + remote_as: + description: + - Remote AS of the BGP neighbor to configure. + - peer_as and peer_type are mutually exclusive. + type: dict + suboptions: + peer_as: + description: + - Specifies remote AS number. + - The range is from 1 to 4294967295. + type: int + peer_type: + description: + - Specifies the type of BGP peer. + type: str + choices: + - internal + - external + bfd: + description: + - Enables or disables BFD. + type: dict + suboptions: + enabled: + description: + - Enables BFD liveliness check for a BGP neighbor. + type: bool + check_failure: + description: + - Link dataplane status with control plane. + type: bool + profile: + description: + - BFD Profile name. + type: str + advertisement_interval: + description: + - Specifies the minimum interval between sending BGP routing updates. + - The range is from 0 to 600. + type: int + peer_group: + description: + - The name of the peer group that the neighbor is a member of. + type: str + timers: + description: + - Specifies BGP neighbor timer-related configurations. + type: dict + suboptions: + keepalive: + description: + - Frequency with which the device sends keepalive messages to its peer, in seconds. + - The range is from 0 to 65535. + type: int + holdtime: + description: + - Interval after not receiving a keepalive message that SONiC declares a peer dead, in seconds. + - The range is from 0 to 65535. + type: int + connect_retry: + description: + - Time interval in seconds between attempts to establish a session with the peer. + - The range is from 1 to 65535. + type: int + capability: + description: + - Specifies capability attributes to this neighbor. + type: dict + suboptions: + dynamic: + description: + - Enables or disables dynamic capability to this neighbor. + type: bool + extended_nexthop: + description: + - Enables or disables advertise extended next-hop capability to the peer. + type: bool + auth_pwd: + description: + - Configuration for neighbor group authentication password. + type: dict + suboptions: + pwd: + description: + - Authentication password for the neighbor group. + type: str + required: True + encrypted: + description: + - Indicates whether the password is encrypted text. + type: bool + default: False + nbr_description: + description: + - A textual description of the neighbor. + type: str + disable_connected_check: + description: + - Disables EBGP conntected route check. + type: bool + dont_negotiate_capability: + description: + - Disables capability negotiation. + type: bool + ebgp_multihop: + description: + - Allow EBGP neighbors not on directly connected networks. + type: dict + suboptions: + enabled: + description: + - Enables the referenced group or neighbors to be indirectly connected. + type: bool + default: False + multihop_ttl: + description: + - Time-to-live value to use when packets are sent to the referenced group or neighbors and ebgp-multihop is enabled. + type: int + enforce_first_as: + description: + - Enforces the first AS for EBGP routes. + type: bool + enforce_multihop: + description: + - Enforces EBGP multihop performance for neighbor. + type: bool + local_address: + description: + - Set the local IP address to use for the session when sending BGP update messages. + type: str + local_as: + description: + - Specifies local autonomous system number. + type: dict + suboptions: + as: + description: + - Local autonomous system number. + type: int + required: True + no_prepend: + description: + - Do not prepend the local-as number in AS-Path advertisements. + type: bool + replace_as: + description: + - Replace the configured AS Number with the local-as number in AS-Path advertisements. + type: bool + override_capability: + description: + - Override capability negotiation result. + type: bool + passive: + description: + - Do not send open messages to this neighbor. + type: bool + default: False + port: + description: + - Neighbor's BGP port. + type: int + shutdown_msg: + description: + - Add a shutdown message. + type: str + solo: + description: + - Indicates that routes advertised by the peer should not be reflected back to the peer. + type: bool + strict_capability_match: + description: + - Enables strict capability negotiation match. + type: bool + ttl_security: + description: + - Enforces only the neighbors that are specified number of hops away will be allowed to become neighbors. + type: int + v6only: + description: + - Enables BGP with v6 link-local only. + type: bool + + state: + description: + - Specifies the operation to be performed on the BGP process that is configured on the device. + - In case of merged, the input configuration is merged with the existing BGP configuration on the device. + - In case of deleted, the existing BGP configuration is removed from the device. + default: merged + type: str + choices: + - merged + - deleted +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +#router bgp 11 vrf VrfCheck2 +# network import-check +# timers 60 180 +#! +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +# ! +# neighbor interface Eth1/3 +#! +#router bgp 11 +# network import-check +# timers 60 180 +# ! +# neighbor 192.168.1.4 +# ! +# peer-group SP1 +# bfd +# capability dynamic +# ! +# peer-group SP2 +# ! +# +- name: Deletes all BGP neighbors + dellemc.enterprise_sonic.sonic_bgp_neighbors: + config: + state: deleted + +# +# After state: +# ------------- +#router bgp 11 vrf VrfCheck2 +# network import-check +# timers 60 180 +#! +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +#! +#router bgp 11 +# network import-check +# timers 60 180 +# ! +# +# Using merged +# +# Before state: +# ------------ +#router bgp 11 vrf VrfCheck2 +# network import-check +# timers 60 180 +#! +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +#! +#router bgp 11 +# network import-check +# timers 60 180 +# ! + +- name: "Adds sonic_bgp_neighbors" + dellemc.enterprise_sonic.sonic_bgp_neighbors: + config: + - bgp_as: 51 + neighbors: + - neighbor: Eth1/2 + auth_pwd: + pwd: 'pw123' + encrypted: false + dont_negotiate_capability: true + ebgp_multihop: + enabled: true + multihop_ttl: 1 + enforce_first_as: true + enforce_multihop: true + local_address: 'Ethernet4' + local_as: + as: 2 + no_prepend: true + replace_as: true + nbr_description: "description 1" + override_capability: true + passive: true + port: 3 + shutdown_msg: 'msg1' + solo: true + - neighbor: 1.1.1.1 + disable_connected_check: true + ttl_security: 5 + - bgp_as: 51 + vrf_name: VrfReg1 + peer_group: + - name: SPINE + bfd: + check_failure: true + enabled: true + profile: 'profile 1' + capability: + dynamic: true + extended_nexthop: true + auth_pwd: + pwd: 'U2FsdGVkX1/4sRsZ624wbAJfDmagPLq2LsGDOcW/47M=' + encrypted: true + dont_negotiate_capability: true + ebgp_multihop: + enabled: true + multihop_ttl: 1 + enforce_first_as: true + enforce_multihop: true + local_address: 'Ethernet4' + local_as: + as: 2 + no_prepend: true + replace_as: true + pg_description: 'description 1' + override_capability: true + passive: true + solo: true + remote_as: + peer_as: 4 + - name: SPINE1 + disable_connected_check: true + shutdown_msg: "msg1" + strict_capability_match: true + timers: + keepalive: 30 + holdtime: 15 + connect_retry: 25 + ttl_security: 5 + address_family: + afis: + - afi: ipv4 + safi: unicast + activate: true + allowas_in: + origin: true + - afi: ipv6 + safi: unicast + activate: true + allowas_in: + value: 5 + neighbors: + - neighbor: Eth1/3 + remote_as: + peer_as: 10 + peer_group: SPINE + advertisement_interval: 15 + timers: + keepalive: 30 + holdtime: 15 + connect_retry: 25 + bfd: + check_failure: true + enabled: true + profile: 'profile 1' + capability: + dynamic: true + extended_nexthop: true + auth_pwd: + pwd: 'U2FsdGVkX199MZ7YOPkOR9O6wEZmtGSgiDfnlcN9hBg=' + encrypted: true + nbr_description: 'description 2' + strict_capability_match: true + v6only: true + - neighbor: 192.168.1.4 + state: merged +# +# After state: +# ------------ +#! +#router bgp 11 vrf VrfCheck2 +# network import-check +# timers 60 180 +#! +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +# ! +# peer-group SPINE1 +# timers 15 30 +# timers connect 25 +# shutdown message msg1 +# disable-connected-check +# strict-capability-match +# ttl-security hops 5 +# ! +# peer-group SPINE +# description "description 1" +# ebgp-multihop 1 +# remote-as 4 +# bfd check-control-plane-failure profile "profile 1" +# update-source interface Ethernet4 +# capability dynamic +# capability extended-nexthop +# dont-capability-negotiate +# enforce-first-as +# enforce-multihop +# local-as 2 no-prepend replace-as +# override-capability +# passive +# password U2FsdGVkX1/4sRsZ624wbAJfDmagPLq2LsGDOcW/47M= encrypted +# solo +# address-family ipv4 unicast +# activate +# allowas-in origin +# send-community both +# ! +# address-family ipv6 unicast +# activate +# allowas-in 5 +# send-community both +# ! +# neighbor interface Eth1/3 +# description "description 2" +# peer-group SPINE +# remote-as 10 +# timers 15 30 +# timers connect 25 +# bfd check-control-plane-failure profile "profile 1" +# advertisement-interval 15 +# capability extended-nexthop +# capability dynamic +# v6only +# password U2FsdGVkX199MZ7YOPkOR9O6wEZmtGSgiDfnlcN9hBg= encrypted +# strict-capability-match +# ! +# neighbor 192.168.1.4 +#! +# router bgp 51 +# timers 60 180 +# neighbor interface Eth1/2 +# description "description 1" +# shutdown message msg1 +# ebgp-multihop 1 +# remote-as external +# update-source interface Ethernet4 +# dont-capability-negotiate +# enforce-first-as +# enforce-multihop +# local-as 2 no-prepend replace-as +# override-capability +# passive +# password U2FsdGVkX1+bxMf9TKOhaXRNNaHmywiEVDF2lJ2c000= encrypted +# port 3 +# solo +# neighbor 1.1.1.1 +# disable-connected-check +# ttl-security hops 5 +#router bgp 11 +# network import-check +# timers 60 180 +# +# Using deleted +# +# Before state: +# ------------ +#! +#router bgp 11 vrf VrfCheck2 +# network import-check +# timers 60 180 +#! +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +# ! +# peer-group SPINE +# bfd +# remote-as 4 +# ! +# neighbor interface Eth1/3 +# peer-group SPINE +# remote-as 10 +# timers 15 30 +# advertisement-interval 15 +# bfd +# capability extended-nexthop +# capability dynamic +# ! +# neighbor 192.168.1.4 +#! +#router bgp 11 +# network import-check +# timers 60 18 +# ! +# peer-group SP +# ! +# neighbor interface Eth1/3 +# +- name: "Deletes sonic_bgp_neighbors and peer-groups specific to vrfname" + dellemc.enterprise_sonic.sonic_bgp_neighbors: + config: + - bgp_as: 51 + vrf_name: VrfReg1 + state: deleted + +# After state: +# ------------ +#! +#router bgp 11 vrf VrfCheck2 +# network import-check +# timers 60 180 +#! +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +# ! +#router bgp 11 +# network import-check +# timers 60 18 +# ! +# peer-group SP +# ! +# neighbor interface Eth1/3 +# +# Using deleted +# +# Before state: +# ------------- +# +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +# ! +# peer-group SPINE +# bfd +# remote-as 4 +# ! +# neighbor interface Eth1/3 +# peer-group SPINE +# remote-as 10 +# timers 15 30 +# advertisement-interval 15 +# bfd +# capability extended-nexthop +# capability dynamic +# ! +# neighbor 192.168.1.4 +# ! + +- name: "Deletes specific sonic_bgp_neighbors" + dellemc.enterprise_sonic.sonic_bgp_neighbors: + config: + - bgp_as: 51 + neighbors: + - neighbor: Eth1/2 + auth_pwd: + pwd: 'pw123' + encrypted: false + dont_negotiate_capability: true + ebgp_multihop: + enabled: true + multihop_ttl: 1 + enforce_first_as: true + enforce_multihop: true + local_address: 'Ethernet4' + local_as: + as: 2 + no_prepend: true + replace_as: true + nbr_description: 'description 1' + override_capability: true + passive: true + port: 3 + shutdown_msg: 'msg1' + solo: true + - neighbor: 1.1.1.1 + disable_connected_check: true + ttl_security: 5 + - bgp_as: 51 + vrf_name: VrfReg1 + peer_group: + - name: SPINE + bfd: + check_failure: true + enabled: true + profile: 'profile 1' + capability: + dynamic: true + extended_nexthop: true + auth_pwd: + pwd: 'U2FsdGVkX1/4sRsZ624wbAJfDmagPLq2LsGDOcW/47M=' + encrypted: true + dont_negotiate_capability: true + ebgp_multihop: + enabled: true + multihop_ttl: 1 + enforce_first_as: true + enforce_multihop: true + local_address: 'Ethernet4' + local_as: + as: 2 + no_prepend: true + replace_as: true + pg_description: 'description 1' + override_capability: true + passive: true + solo: true + remote_as: + peer_as: 4 + - name: SPINE1 + disable_connected_check: true + shutdown_msg: "msg1" + strict_capability_match: true + timers: + keepalive: 30 + holdtime: 15 + connect_retry: 25 + ttl_security: 5 + neighbors: + - neighbor: Eth1/3 + remote_as: + peer_as: 10 + peer_group: SPINE + advertisement_interval: 15 + timers: + keepalive: 30 + holdtime: 15 + connect_retry: 25 + bfd: + check_failure: true + enabled: true + profile: 'profile 1' + capability: + dynamic: true + extended_nexthop: true + auth_pwd: + pwd: 'U2FsdGVkX199MZ7YOPkOR9O6wEZmtGSgiDfnlcN9hBg=' + encrypted: true + nbr_description: 'description 2' + strict_capability_match: true + v6only: true + - neighbor: 192.168.1.4 + state: deleted +# +# After state: +# ------------- +# +#router bgp 51 vrf VrfReg1 +# network import-check +# timers 60 180 +# ! +# peer-group SPINE1 +# ! +# peer-group SPINE +# ! +# neighbor interface Eth1/3 +# ! +# neighbor interface Eth1/2 +# neighbor 1.1.1.1 +# +# Using merged +# +# Before state: +# ------------- +# +# sonic# show running-configuration bgp peer-group vrf default +# (No bgp peer-group configuration present) + +- name: "Configure BGP peer-group prefix-list attributes" + dellemc.enterprise_sonic.sonic_bgp_neighbors: + config: + - bgp_as: 51 + peer_group: + - name: SPINE + address_family: + afis: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: true + prefix_limit: + max_prefixes: 1 + prevent_teardown: true + warning_threshold: 80 + prefix_list_in: p1 + prefix_list_out: p2 + state: merged + +# After state: +# ------------ +# +# sonic# show running-configuration bgp peer-group vrf default +# ! +# peer-group SPINE +# ! +# address-family ipv4 unicast +# default-originate route-map rmap_reg1 +# prefix-list p1 in +# prefix-list p2 out +# send-community both +# maximum-prefix 1 80 warning-only +# +# Using deleted +# +# Before state: +# ------------- +# +# sonic# show running-configuration bgp peer-group vrf default +# ! +# peer-group SPINE +# ! +# address-family ipv6 unicast +# default-originate route-map rmap_reg2 +# prefix-list p1 in +# prefix-list p2 out +# send-community both +# maximum-prefix 5 90 restart 2 + +- name: "Delete BGP peer-group prefix-list attributes" + dellemc.enterprise_sonic.sonic_bgp_neighbors: + config: + - bgp_as: 51 + peer_group: + - name: SPINE + address_family: + afis: + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: true + prefix_limit: + max_prefixes: 5 + warning_threshold: 90 + restart-timer: 2 + prefix_list_in: p1 + prefix_list_out: p2 + state: deleted + +# sonic# show running-configuration bgp peer-group vrf default +# (No bgp peer-group configuration present) +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_neighbors.bgp_neighbors import Bgp_neighborsArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_neighbors.bgp_neighbors import Bgp_neighbors + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Bgp_neighborsArgs.argument_spec, + supports_check_mode=True) + + result = Bgp_neighbors(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_neighbors_af.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_neighbors_af.py new file mode 100644 index 000000000..10400cfe2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_bgp_neighbors_af.py @@ -0,0 +1,451 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_bgp_neighbors_af +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = """ +--- +module: sonic_bgp_neighbors_af +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Niraimadaiselvam M (@niraimadaiselvamm) +short_description: Manage the BGP neighbor address-family and its parameters +description: + - This module provides configuration management of BGP neighbors address-family parameters on devices running Enterprise SONiC. + - bgp_as, vrf_name and neighbors need be created in advance on the device. +options: + config: + description: + - Specifies the BGP neighbors address-family related configuration. + type: list + elements: dict + suboptions: + bgp_as: + description: + - Specifies the BGP autonomous system (AS) number which is already configured on the device. + type: str + required: true + vrf_name: + description: + - Specifies the VRF name which is already configured on the device. + type: str + default: 'default' + neighbors: + description: + - Specifies BGP neighbor related configurations in address-family configuration mode. + type: list + elements: dict + suboptions: + neighbor: + description: + - Neighbor router address which is already configured on the device. + type: str + required: True + address_family: + description: + - Specifies BGP address-family related configurations. + - afi and safi are required together. + type: list + elements: dict + suboptions: + afi: + description: + - Type of address-family to configure. + type: str + choices: + - ipv4 + - ipv6 + - l2vpn + required: True + safi: + description: + - Specifies the type of cast for the address-family. + type: str + choices: + - unicast + - evpn + default: unicast + activate: + description: + - Enables the address-family for this neighbor. + type: bool + allowas_in: + description: + - Specifies the allowas in values. + type: dict + suboptions: + value: + description: + - Specifies the value of the allowas in. + type: int + origin: + description: + - Specifies the origin value. + type: bool + ip_afi: + description: + - Common configuration attributes for IPv4 and IPv6 unicast address families. + type: dict + suboptions: + default_policy_name: + description: + - Specifies routing policy definition. + type: str + send_default_route: + description: + - Enable or disable sending of default-route to the neighbor. + type: bool + default: False + prefix_limit: + description: + - Specifies prefix limit attributes. + type: dict + suboptions: + max_prefixes: + description: + - Maximum number of prefixes that will be accepted from the neighbor. + type: int + prevent_teardown: + description: + - Enable or disable teardown of BGP session when maximum prefix limit is exceeded. + type: bool + default: False + warning_threshold: + description: + - Threshold on number of prefixes that can be received from a neighbor before generation of warning messages. + - Expressed as a percentage of max-prefixes. + type: int + restart_timer: + description: + - Time interval in seconds after which the BGP session is re-established after being torn down. + type: int + prefix_list_in: + description: + - Inbound route filtering policy for a neighbor. + type: str + prefix_list_out: + description: + - Outbound route filtering policy for a neighbor. + type: str + route_map: + description: + - Specifies the route-map. + type: list + elements: dict + suboptions: + name: + description: + - Specifies the name of the route-map. + type: str + direction: + description: + - Specifies the direction of the route-map. + type: str + route_reflector_client: + description: + - Specifies a neighbor as a route-reflector client. + type: bool + route_server_client: + description: + - Specifies a neighbor as a route-server client. + type: bool + state: + description: + - Specifies the operation to be performed on the BGP process that is configured on the device. + - In case of merged, the input configuration is merged with the existing BGP configuration on the device. + - In case of deleted, the existing BGP configuration is removed from the device. + default: merged + type: str + choices: ['merged', 'deleted'] +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#! +#router bgp 4 +# ! +# neighbor interface Eth1/3 +# ! +# address-family ipv4 unicast +# activate +# allowas-in 4 +# route-map aa in +# route-map aa out +# route-reflector-client +# route-server-client +# send-community both +#! +# +- name: Deletes neighbors address-family with specific values + dellemc.enterprise_sonic.sonic_bgp_neighbors_af: + config: + - bgp_as: 4 + neighbors: + - neighbor: Eth1/3 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 4 + route_map: + - name: aa + direction: in + - name: aa + direction: out + route_reflector_client: true + route_server_client: true + state: deleted + +# After state: +# ------------ +#! +#router bgp 4 +# ! +# neighbor interface Eth1/3 +# ! +# address-family ipv4 unicast +# send-community both +#! + + +# Using deleted +# +# Before state: +# ------------- +# +#! +#router bgp 4 +# ! +# neighbor interface Eth1/3 +# ! +# address-family ipv4 unicast +# activate +# allowas-in 4 +# route-map aa in +# route-map aa out +# route-reflector-client +# route-server-client +# send-community both +#! +# neighbor interface Eth1/5 +# ! +# address-family ipv4 unicast +# activate +# allowas-in origin +# send-community both +#! +# +- name: Deletes neighbors address-family with specific values + dellemc.enterprise_sonic.sonic_bgp_neighbors_af: + config: + state: deleted + +# After state: +# ------------ +#! +#router bgp 4 +#! + + +# Using deleted +# +# Before state: +# ------------- +# +#! +#router bgp 4 +# ! +# neighbor interface Eth1/3 +#! +# +- name: Merges neighbors address-family with specific values + dellemc.enterprise_sonic.sonic_bgp_neighbors_af: + config: + - bgp_as: 4 + neighbors: + - neighbor: Eth1/3 + address_family: + - afi: ipv4 + safi: unicast + allowas_in: + value: 4 + route_map: + - name: aa + direction: in + - name: aa + direction: out + route_reflector_client: true + route_server_client: true + state: merged + +# After state: +# ------------ +#! +#router bgp 4 +# ! +# neighbor interface Eth1/3 +# ! +# address-family ipv4 unicast +# activate +# allowas-in 4 +# route-map aa in +# route-map aa out +# route-reflector-client +# route-server-client +# send-community both +#! + + +# Using merged +# +# Before state: +# ------------- +# +# sonic# show running-configuration bgp neighbor vrf default 1.1.1.1 +# (No bgp neighbor configuration present) +- name: "Configure BGP neighbor prefix-list attributes" + dellemc.enterprise_sonic.sonic_bgp_neighbors_af: + config: + - bgp_as: 51 + neighbors: + - neighbor: 1.1.1.1 + address_family: + - afi: ipv4 + safi: unicast + ip_afi: + default_policy_name: rmap_reg1 + send_default_route: true + prefix_limit: + max_prefixes: 1 + prevent_teardown: true + warning_threshold: 80 + prefix_list_in: p1 + prefix_list_out: p2 + state: merged +# After state: +# ------------ +# +# sonic# show running-configuration bgp neighbor vrf default 1.1.1.1 +# ! +# neighbor 1.1.1.1 +# ! +# address-family ipv4 unicast +# default-originate route-map rmap_reg1 +# prefix-list p1 in +# prefix-list p2 out +# send-community both +# maximum-prefix 1 80 warning-only + + +# Using deleted +# +# Before state: +# ------------- +# +# sonic# show running-configuration bgp neighbor vrf default 1.1.1.1 +# ! +# neighbor 1.1.1.1 +# ! +# address-family ipv6 unicast +# default-originate route-map rmap_reg2 +# prefix-list p1 in +# prefix-list p2 out +# send-community both +# maximum-prefix 5 90 restart 2 +- name: "Delete BGP neighbor prefix-list attributes" + dellemc.enterprise_sonic.sonic_bgp_neighbors_af: + config: + - bgp_as: 51 + neighbors: + - neighbor: 1.1.1.1 + address_family: + - afi: ipv6 + safi: unicast + ip_afi: + default_policy_name: rmap_reg2 + send_default_route: true + prefix_limit: + max_prefixes: 5 + warning_threshold: 90 + restart-timer: 2 + prefix_list_in: p1 + prefix_list_out: p2 + state: deleted +# sonic# show running-configuration bgp neighbor vrf default 1.1.1.1 +# (No bgp neighbor configuration present) +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.bgp_neighbors_af.bgp_neighbors_af import Bgp_neighbors_afArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.bgp_neighbors_af.bgp_neighbors_af import Bgp_neighbors_af + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Bgp_neighbors_afArgs.argument_spec, + supports_check_mode=True) + + result = Bgp_neighbors_af(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_command.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_command.py new file mode 100644 index 000000000..b0ce87811 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_command.py @@ -0,0 +1,235 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Peter Sprygada <psprygada@ansible.com> +# Copyright: (c) 2020, Dell Inc. +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_command +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Dhivya P (@dhivayp) +short_description: Runs commands on devices running Enterprise SONiC +description: + - Runs commands on remote devices running Enterprise SONiC Distribution + by Dell Technologies. Sends arbitrary commands to an Enterprise SONiC node and + returns the results that are read from the device. This module includes an + argument that causes the module to wait for a specific condition + before returning or time out if the condition is not met. + - This module does not support running commands in configuration mode. + To configure SONiC devices, use M(dellemc.enterprise_sonic.sonic_config). +options: + commands: + description: + - List of commands to send to the remote Enterprise SONiC devices over the + configured provider. The resulting output from the command + is returned. If the I(wait_for) argument is provided, the + module is not returned until the condition is satisfied or + the number of retries has expired. If a command sent to the + device requires answering a prompt, it is possible to pass + a dict containing I(command), I(answer) and I(prompt). + Common answers are 'yes' or "\\r" (carriage return, must be + double quotes). See examples. + type: list + elements: str + required: true + wait_for: + description: + - List of conditions to evaluate against the output of the + command. The task waits for each condition to be true + before moving forward. If the conditional is not true + within the configured number of retries, the task fails. + See examples. + type: list + elements: str + match: + description: + - The I(match) argument is used in conjunction with the + I(wait_for) argument to specify the match policy. Valid + values are C(all) or C(any). If the value is set to C(all) + then all conditionals in the wait_for must be satisfied. If + the value is set to C(any) then only one of the values must be + satisfied. + type: str + default: all + choices: [ 'all', 'any' ] + retries: + description: + - Specifies the number of retries a command should be run + before it is considered failed. The command is run on the + target device every retry and evaluated against the + I(wait_for) conditions. + type: int + default: 10 + interval: + description: + - Configures the interval in seconds to wait between retries + of the command. If the command does not pass the specified + conditions, the interval indicates how long to wait before + trying the command again. + type: int + default: 1 +""" + +EXAMPLES = """ + - name: Runs show version on remote devices + dellemc.enterprise_sonic.sonic_command: + commands: show version + + - name: Runs show version and checks to see if output contains 'Dell' + dellemc.enterprise_sonic.sonic_command: + commands: show version + wait_for: result[0] contains Dell + + - name: Runs multiple commands on remote nodes + dellemc.enterprise_sonic.sonic_command: + commands: + - show version + - show interface + + - name: Runs multiple commands and evaluate the output + dellemc.enterprise_sonic.sonic_command: + commands: + - 'show version' + - 'show system' + wait_for: + - result[0] contains Dell + - result[1] contains Hostname + + - name: Runs commands that require answering a prompt + dellemc.enterprise_sonic.sonic_command: + commands: + - command: 'reload' + prompt: '[confirm yes/no]: ?$' + answer: 'no' +""" + +RETURN = """ +stdout: + description: The set of responses from the commands. + returned: always apart from low level errors (such as action plugin) + type: list + sample: ['...', '...'] +stdout_lines: + description: The value of stdout split into a list. + returned: always apart from low level errors (such as action plugin) + type: list + sample: [['...', '...'], ['...'], ['...']] +failed_conditions: + description: The list of conditionals that have failed. + returned: failed + type: list + sample: ['...', '...'] +warnings: + description: The list of warnings (if any) generated by module based on arguments. + returned: always + type: list + sample: ['...', '...'] +""" +import time + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.parsing import ( + Conditional, +) +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( + EntityCollection, + to_lines, +) +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic import run_commands +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import command_list_str_to_dict + + +def transform_commands_dict(module, commands_dict): + transform = EntityCollection( + module, + dict( + command=dict(key=True), + output=dict(), + prompt=dict(type="list"), + answer=dict(type="list"), + newline=dict(type="bool", default=True), + sendonly=dict(type="bool", default=False), + check_all=dict(type="bool", default=False), + ), + ) + + return transform(commands_dict) + + +def parse_commands(module, warnings): + commands_dict = command_list_str_to_dict(module, warnings, module.params["commands"]) + commands = transform_commands_dict(module, commands_dict) + return commands + + +def main(): + """main entry point for module execution + """ + argument_spec = dict( + # { command: <str>, prompt: <str>, response: <str> } + commands=dict(type='list', required=True, elements="str"), + + wait_for=dict(type='list', elements="str"), + match=dict(default='all', choices=['all', 'any']), + + retries=dict(default=10, type='int'), + interval=dict(default=1, type='int') + ) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + result = {'changed': False} + + warnings = list() +# check_args(module, warnings) + commands = parse_commands(module, warnings) + result['warnings'] = warnings + + wait_for = module.params['wait_for'] or list() + try: + conditionals = [Conditional(c) for c in wait_for] + except AttributeError as exc: + module.fail_json(msg=to_text(exc)) + retries = module.params['retries'] + interval = module.params['interval'] + match = module.params['match'] + + while retries > 0: + responses = run_commands(module, commands) + for item in list(conditionals): + if item(responses): + if match == 'any': + conditionals = list() + break + conditionals.remove(item) + + if not conditionals: + break + + time.sleep(interval) + retries -= 1 + + if conditionals: + failed_conditions = [item.raw for item in conditionals] + msg = 'One or more conditional statements have not been satisfied.' + module.fail_json(msg=msg, failed_conditions=failed_conditions) + + result.update({ + 'stdout': responses, + 'stdout_lines': list(to_lines(responses)) + }) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_config.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_config.py new file mode 100644 index 000000000..dd054419f --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_config.py @@ -0,0 +1,329 @@ +#!/usr/bin/python +# +# (c) 2015 Peter Sprygada, <psprygada@ansible.com> +# Copyright (c) 2020 Dell Inc. +# +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_config +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Abirami N (@abirami-n) +short_description: Manages configuration sections on devices running Enterprise SONiC +description: + - Manages configuration sections of Enterprise SONiC Distribution + by Dell Technologies. SONiC configurations use a simple block indent + file syntax for segmenting configuration into sections. This module + provides an implementation for working with SONiC configuration + sections in a deterministic way. +options: + lines: + description: + - The ordered set of commands that should be configured in the + section. The commands must be the exact same commands as found + in the device running-configuration. Be sure to note the configuration + command syntax as some commands are automatically modified by the + device configuration parser. This argument is mutually exclusive + with I(src). + type: list + elements: str + aliases: ['commands'] + parents: + description: + - The ordered set of parents that uniquely identify the section or hierarchy + the commands should be checked against. If the parents argument + is omitted, the commands are checked against the set of top + level or global commands. + type: list + elements: str + src: + description: + - Specifies the source path to the file that contains the configuration + or configuration template to load. The path to the source file can + either be the full path on the Ansible control host, or a relative + path from the playbook or role root directory. This argument is + mutually exclusive with I(lines). + type: path + before: + description: + - The ordered set of commands to push on to the command stack if + a change needs to be made. This allows the playbook designer + the opportunity to perform configuration commands prior to pushing + any changes without affecting how the set of commands are matched + against the system. + type: list + elements: str + after: + description: + - The ordered set of commands to append to the end of the command + stack if a change needs to be made. Just like with I(before), this + allows the playbook designer to append a set of commands to be + executed after the command set. + type: list + elements: str + save: + description: + - The C(save) argument instructs the module to save the running- + configuration to the startup-configuration at the conclusion of + the module running. If check mode is specified, this argument + is ignored. + type: bool + default: 'no' + match: + description: + - Instructs the module on the way to perform the matching of + the set of commands against the current device configuration. + If match is set to I(line), commands are matched line by line. + If match is set to I(strict), command lines are matched with respect + to position. If match is set to I(exact), command lines + must be an equal match. If match is set to I(none), the + module does not attempt to compare the source configuration with + the running-configuration on the remote device. + type: str + default: line + choices: ['line', 'strict', 'exact', 'none'] + replace: + description: + - Instructs the module how to perform a configuration + on the device. If the replace argument is set to I(line), then + the modified lines are pushed to the device in configuration + mode. If the replace argument is set to I(block), then the entire + command block is pushed to the device in configuration mode if any + line is not correct. + type: str + default: line + choices: ['line', 'block'] + update: + description: + - The I(update) argument controls how the configuration statements + are processed on the remote device. Valid choices for the I(update) + argument are I(merge) and I(check). When you set this argument to + I(merge), the configuration changes merge with the current + device running-configuration. When you set this argument to I(check), + the configuration updates are determined but not configured + on the remote device. + type: str + default: merge + choices: ['merge', 'check'] + config: + description: + - The module, by default, connects to the remote device and + retrieves the current running-configuration to use as a base for + comparing against the contents of source. There are times when + it is not desirable to have the task get the current + running-configuration for every task in a playbook. The I(config) + argument allows the implementer to pass in the configuration to + use as the base configuration for comparison. + type: str + backup: + description: + - This argument causes the module to create a full backup of + the current C(running-configuration) from the remote device before any + changes are made. If the C(backup_options) value is not given, + the backup file is written to the C(backup) folder in the playbook + root directory. If the directory does not exist, it is created. + type: bool + default: 'no' + backup_options: + description: + - This is a dictionary object containing configurable options related to backup file path. + The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set + to I(no) this option is ignored. + suboptions: + filename: + description: + - The filename to be used to store the backup configuration. If the filename + is not given, it is generated based on the hostname, current time, and date + in the format defined by <hostname>_config.<current-date>@<current-time>. + type: str + dir_path: + description: + - This option provides the path ending with directory name in which the backup + configuration file is stored. If the directory does not exist it is first + created, and the filename is either the value of C(filename) or default filename + as described in C(filename) options description. If the path value is not given, + an I(backup) directory is created in the current working directory + and backup configuration is copied in C(filename) within the I(backup) directory. + type: path + type: dict +""" + +EXAMPLES = """ +- dellemc.enterprise_sonic.sonic_config: + lines: ['username {{ user_name }} password {{ user_password }} role {{ user_role }}'] + +- dellemc.enterprise_sonic.sonic_config: + lines: + - description 'SONiC' + parents: ['interface Eth1/10'] + +- dellemc.enterprise_sonic.sonic_config: + lines: + - seq 2 permit udp any any + - seq 3 deny icmp any any + parents: ['ip access-list test'] + before: ['no ip access-list test'] + +""" + +RETURN = """ +updates: + description: The set of commands that is pushed to the remote device. + returned: always + type: list + sample: ['username foo password foo role admin', 'router bgp 1', 'router-id 1.1.1.1'] +commands: + description: The set of commands that is pushed to the remote device. + returned: always + type: list + sample: ['username foo password foo role admin', 'router bgp 1', 'router-id 1.1.1.1'] +saved: + description: Returns whether the configuration is saved to the startup + configuration or not. + returned: When not check_mode. + type: bool + sample: True +""" + +from ansible.module_utils.connection import ConnectionError + +from ansible.module_utils._text import to_text +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic import get_config, get_sublevel_config +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic import edit_config, run_commands +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import command_list_str_to_dict +from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.config import NetworkConfig, dumps + + +def get_candidate(module): + candidate = NetworkConfig(indent=1) + if module.params['src']: + candidate.load(module.params['src']) + elif module.params['lines']: + parents = module.params['parents'] or list() + commands = module.params['lines'][0] + if (isinstance(commands, dict)) and (isinstance((commands['command']), list)): + candidate.add(commands['command'], parents=parents) + elif (isinstance(commands, dict)) and (isinstance((commands['command']), str)): + candidate.add([commands['command']], parents=parents) + else: + candidate.add(module.params['lines'], parents=parents) + return candidate + + +def get_running_config(module): + contents = module.params['config'] + if not contents: + contents = get_config(module) + return contents + + +def main(): + + backup_spec = dict( + filename=dict(), + dir_path=dict(type='path') + ) + + argument_spec = dict( + lines=dict(aliases=['commands'], type='list', elements="str"), + parents=dict(type='list', elements="str"), + + src=dict(type='path'), + + before=dict(type='list', elements="str"), + after=dict(type='list', elements="str"), + save=dict(type='bool', default=False), + match=dict(default='line', + choices=['line', 'strict', 'exact', 'none']), + replace=dict(default='line', choices=['line', 'block']), + + update=dict(choices=['merge', 'check'], default='merge'), + config=dict(), + backup=dict(type='bool', default=False), + backup_options=dict(type='dict', options=backup_spec) + + ) + + mutually_exclusive = [('lines', 'src')] + + module = AnsibleModule(argument_spec=argument_spec, + mutually_exclusive=mutually_exclusive, + supports_check_mode=True) + parents = module.params['parents'] or list() + match = module.params['match'] + replace = module.params['replace'] + + warnings = list() +# check_args(module, warnings) + + result = dict(changed=False, saved=False, warnings=warnings) + if module.params['backup']: + if not module.check_mode: + result['__backup__'] = get_config(module) + + commands = list() + candidate = get_candidate(module) + if any((module.params['lines'], module.params['src'])): + if match != 'none': + config = get_running_config(module) + if parents: + contents = get_sublevel_config(config, module) + config = NetworkConfig(contents=contents, indent=1) + else: + config = NetworkConfig(contents=config, indent=1) + configobjs = candidate.difference(config, match=match, replace=replace) + else: + + configobjs = candidate.items + if configobjs: + commands = dumps(configobjs, 'commands') + if ((isinstance((module.params['lines']), list)) and + (isinstance((module.params['lines'][0]), dict)) and + (set(['prompt', 'answer']).issubset(module.params['lines'][0]))): + + cmd = {'command': commands, + 'prompt': module.params['lines'][0]['prompt'], + 'answer': module.params['lines'][0]['answer']} + commands = [cmd] + else: + commands = commands.split('\n') + cmd_list_out = command_list_str_to_dict(module, warnings, commands) + if cmd_list_out and cmd_list_out != []: + commands = cmd_list_out + + if module.params['before']: + commands[:0] = module.params['before'] + + if module.params['after']: + commands.extend(module.params['after']) + + if not module.check_mode and module.params['update'] == 'merge': + try: + edit_config(module, commands) + except ConnectionError as exc: + module.fail_json(msg=to_text(exc)) + + result['changed'] = True + result['commands'] = commands + result['updates'] = commands + + if module.params['save']: + result['changed'] = True + if not module.check_mode: + cmd = {r'command': ' write memory'} + run_commands(module, [cmd]) + result['saved'] = True + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_facts.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_facts.py new file mode 100644 index 000000000..f13e9defd --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_facts.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +""" +The module file for sonic_facts +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_facts +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Collects facts on devices running Enterprise SONiC +description: + - Collects facts from devices running Enterprise SONiC Distribution by + Dell Technologies. This module places the facts gathered in the fact tree + keyed by the respective resource name. The facts module always collects + a base set of facts from the device and can enable or disable collection + of additional facts. +author: +- Mohamed Javeed (@javeedf) +- Abirami N (@abirami-n) +options: + gather_subset: + description: + - When supplied, this argument restricts the facts collected + to a given subset. Possible values for this argument include + all, min, hardware, config, legacy, and interfaces. Can specify a + list of values to include a larger subset. Values can also be used + with an initial '!' to specify that a specific subset should + not be collected. + required: false + type: list + elements: str + default: '!config' + gather_network_resources: + description: + - When supplied, this argument restricts the facts collected + to a given subset. Possible values for this argument include + all and the resources like 'all', 'interfaces', 'vlans', 'lag_interfaces', 'l2_interfaces', 'l3_interfaces'. + Can specify a list of values to include a larger subset. Values + can also be used with an initial '!' to specify that a + specific subset should not be collected. + required: false + type: list + elements: str + choices: + - all + - vlans + - interfaces + - l2_interfaces + - l3_interfaces + - lag_interfaces + - bgp + - bgp_af + - bgp_neighbors + - bgp_neighbors_af + - bgp_as_paths + - bgp_communities + - bgp_ext_communities + - mclag + - prefix_lists + - vrfs + - vxlans + - users + - system + - port_breakout + - aaa + - tacacs_server + - radius_server + - static_routes + - ntp +""" + +EXAMPLES = """ +- name: Gather all facts + dellemc.enterprise_sonic.sonic_facts: + gather_subset: all + gather_network_resources: all +- name: Collects VLAN and interfaces facts + dellemc.enterprise_sonic.sonic_facts: + gather_subset: + - min + gather_network_resources: + - vlans + - interfaces +- name: Do not collects VLAN and interfaces facts + dellemc.enterprise_sonic.sonic_facts: + gather_network_resources: + - "!vlans" + - "!interfaces" +- name: Collects VLAN and minimal default facts + dellemc.enterprise_sonic.sonic_facts: + gather_subset: min + gather_network_resources: vlans +- name: Collect lag_interfaces and minimal default facts + dellemc.enterprise_sonic.sonic_facts: + gather_subset: min + gather_network_resources: lag_interfaces +""" + +RETURN = """ +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.facts.facts import FactsArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.facts.facts import Facts + + +def main(): + """ + Main entry point for module execution + :returns: ansible_facts + """ + module = AnsibleModule(argument_spec=FactsArgs.argument_spec, + supports_check_mode=True) + warnings = ['default value for `gather_subset` ' + 'will be changed to `min` from `!config` v2.11 onwards'] + + result = Facts(module).get_facts() + + ansible_facts, additional_warnings = result + warnings.extend(additional_warnings) + + module.exit_json(ansible_facts=ansible_facts, warnings=warnings) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_interfaces.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_interfaces.py new file mode 100644 index 000000000..0cd6a1896 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_interfaces.py @@ -0,0 +1,230 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_interfaces +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_interfaces +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Configure Interface attributes on interfaces such as, Eth, LAG, VLAN, and loopback. + (create a loopback interface if it does not exist.) +description: Configure Interface attributes such as, MTU, admin statu, and so on, on interfaces + such as, Eth, LAG, VLAN, and loopback. (create a loopback interface if it does not exist.) +author: Niraimadaiselvam M(@niraimadaiselvamm) +options: + config: + description: A list of interface configurations. + type: list + elements: dict + suboptions: + name: + type: str + description: The name of the interface, for example, 'Eth1/15'. + required: true + description: + type: str + description: + - Description about the interface. + enabled: + description: + - Administrative state of the interface. + type: bool + mtu: + description: + - MTU of the interface. + type: int + state: + description: + - The state the configuration should be left in. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +# show interface status | no-more +#------------------------------------------------------------------------------------------ +#Name Description Admin Oper Speed MTU +#------------------------------------------------------------------------------------------ +#Eth1/1 - up 100000 9100 +#Eth1/2 - up 100000 9100 +#Eth1/3 - down 100000 9100 +#Eth1/3 - down 1000 5000 +#Eth1/5 - down 100000 9100 +# +- name: Configures interfaces + dellemc.enterprise_sonic.sonic_interfaces: + config: + name: Eth1/3 + state: deleted +# +# After state: +# ------------- +# +# show interface status | no-more +#------------------------------------------------------------------------------------------ +#Name Description Admin Oper Speed MTU +#------------------------------------------------------------------------------------------ +#Eth1/1 - up 100000 9100 +#Eth1/2 - up 100000 9100 +#Eth1/3 - down 100000 9100 +#Eth1/3 - up 100000 9100 +#Eth1/5 - down 100000 9100 +# +# +# Using deleted +# +# Before state: +# ------------- +# +# show interface status | no-more +#------------------------------------------------------------------------------------------ +#Name Description Admin Oper Speed MTU +#------------------------------------------------------------------------------------------ +#Eth1/1 - up 100000 9100 +#Eth1/2 - up 100000 9100 +#Eth1/3 - down 100000 9100 +#Eth1/3 - down 1000 9100 +#Eth1/5 - down 100000 9100 +# + +- name: Configures interfaces + dellemc.enterprise_sonic.sonic_interfaces: + config: + state: deleted + +# +# After state: +# ------------- +# +# show interface status | no-more +#------------------------------------------------------------------------------------------ +#Name Description Admin Oper Speed MTU +#------------------------------------------------------------------------------------------ +#Eth1/1 - up 100000 9100 +#Eth1/2 - up 100000 9100 +#Eth1/3 - up 100000 9100 +#Eth1/3 - up 100000 9100 +#Eth1/5 - up 100000 9100 +# +# +# Using merged +# +# Before state: +# ------------- +# +# show interface status | no-more +#------------------------------------------------------------------------------------------ +#Name Description Admin Oper Speed MTU +#------------------------------------------------------------------------------------------ +#Eth1/1 - up 100000 9100 +#Eth1/2 - up 100000 9100 +#Eth1/3 - down 100000 9100 +#Eth1/3 - down 1000 9100 +# +- name: Configures interfaces + dellemc.enterprise_sonic.sonic_interfaces: + config: + - name: Eth1/3 + description: 'Ethernet Twelve' + - name: Eth1/5 + description: 'Ethernet Sixteen' + enable: True + mtu: 3500 + state: merged +# +# +# After state: +# ------------ +# +# show interface status | no-more +#------------------------------------------------------------------------------------------ +#Name Description Admin Oper Speed MTU +#------------------------------------------------------------------------------------------ +#Eth1/1 - up 100000 9100 +#Eth1/2 - up 100000 9100 +#Eth1/3 - down 100000 9100 +#Eth1/4 - down 1000 9100 +#Eth1/5 - down 100000 3500 +# +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.interfaces.interfaces import InterfacesArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.interfaces.interfaces import Interfaces + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=InterfacesArgs.argument_spec, + supports_check_mode=True) + + result = Interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l2_interfaces.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l2_interfaces.py new file mode 100644 index 000000000..34a8ff720 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l2_interfaces.py @@ -0,0 +1,296 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_l2_interfaces +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_l2_interfaces +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Configure interface-to-VLAN association that is based on access or trunk mode +description: Manages Layer 2 interface attributes of Enterprise SONiC Distribution by Dell Technologies. +author: Niraimadaiselvam M(@niraimadaiselvamm) +options: + config: + description: A list of Layer 2 interface configurations. + type: list + elements: dict + suboptions: + name: + type: str + description: Full name of the interface, for example, 'Eth1/26'. + required: true + trunk: + type: dict + description: Configures trunking parameters on an interface. + suboptions: + allowed_vlans: + description: Specifies list of allowed VLANs of trunk mode on the interface. + type: list + elements: dict + suboptions: + vlan: + type: int + description: Configures the specified VLAN in trunk mode. + access: + type: dict + description: Configures access mode characteristics of the interface. + suboptions: + vlan: + type: int + description: Configures the specified VLAN in access mode. + state: + type: str + description: The state that the configuration should be left in. + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive A Eth1/3 +#11 Inactive T Eth1/3 +#12 Inactive A Eth1/4 +#13 Inactive T Eth1/4 +#14 Inactive A Eth1/5 +#15 Inactive T Eth1/5 +# +- name: Configures switch port of interfaces + dellemc.enterprise_sonic.sonic_l2_interfaces: + config: + - name: Eth1/3 + - name: Eth1/4 + state: deleted +# +# After state: +# ------------ +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#11 Inactive +#12 Inactive +#13 Inactive +#14 Inactive A Eth1/5 +#15 Inactive T Eth1/5 +# +# +# Using deleted +# +# Before state: +# ------------- +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive A Eth1/3 +#11 Inactive T Eth1/3 +#12 Inactive A Eth1/4 +#13 Inactive T Eth1/4 +#14 Inactive A Eth1/5 +#15 Inactive T Eth1/5 +# +- name: Configures switch port of interfaces + dellemc.enterprise_sonic.sonic_l2_interfaces: + config: + state: deleted +# +# After state: +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#11 Inactive +#12 Inactive +#13 Inactive +#14 Inactive +#15 Inactive +# +# +# Using merged +# +# Before state: +# ------------- +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#11 Inactive T Eth1/7 +#12 Inactive T Eth1/7 +# +- name: Configures switch port of interfaces + dellemc.enterprise_sonic.sonic_l2_interfaces: + config: + - name: Eth1/3 + access: + vlan: 10 + state: merged +# +# After state: +# ------------ +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive A Eth1/3 +#11 Inactive T Eth1/7 +#12 Inactive T Eth1/7 +# +# +# Using merged +# +# Before state: +# ------------- +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive A Eth1/3 +# +- name: Configures switch port of interfaces + dellemc.enterprise_sonic.sonic_l2_interfaces: + config: + - name: Eth1/3 + trunk: + allowed_vlans: + - vlan: 11 + - vlan: 12 + state: merged +# +# After state: +# ------------ +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive A Eth1/3 +#11 Inactive T Eth1/7 +#12 Inactive T Eth1/7 +# +# +# Using merged +# +# Before state: +# ------------- +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#11 Inactive +#12 Inactive A Eth1/4 +#13 Inactive T Eth1/4 +#14 Inactive A Eth1/5 +#15 Inactive T Eth1/5 +# +- name: Configures switch port of interfaces + dellemc.enterprise_sonic.sonic_l2_interfaces: + config: + - name: Eth1/3 + access: + vlan: 12 + trunk: + allowed_vlans: + - vlan: 13 + - vlan: 14 + state: merged +# +# After state: +# ------------ +# +#do show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#11 Inactive +#12 Inactive A Eth1/3 +# A Eth1/4 +#13 Inactive T Eth1/3 +# T Eth1/4 +#14 Inactive A Eth1/3 +# A Eth1/5 +#15 Inactive T Eth1/5 +# +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.l2_interfaces.l2_interfaces import L2_interfacesArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.l2_interfaces.l2_interfaces import L2_interfaces + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=L2_interfacesArgs.argument_spec, + supports_check_mode=True) + + result = L2_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l3_interfaces.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l3_interfaces.py new file mode 100644 index 000000000..e796897a5 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_l3_interfaces.py @@ -0,0 +1,375 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_l3_interfaces +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_l3_interfaces +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Configure the IPv4 and IPv6 parameters on Interfaces such as, Eth, LAG, VLAN, and loopback +description: + - Configures Layer 3 interface settings on devices running Enterprise SONiC + Distribution by Dell Technologies. This module provides configuration management + of IPv4 and IPv6 parameters on Ethernet interfaces of devices running Enterprise SONiC. +author: Kumaraguru Narayanan (@nkumaraguru) +options: + config: + description: A list of l3_interfaces configurations. + type: list + elements: dict + suboptions: + name: + required: True + type: str + description: + - Full name of the interface, for example, Eth1/3. + ipv4: + description: + - ipv4 configurations to be set for the Layer 3 interface mentioned in name option. + type: dict + suboptions: + addresses: + description: + - List of IPv4 addresses to be set. + type: list + elements: dict + suboptions: + address: + description: + - IPv4 address to be set in the format <ipv4 address>/<mask> + for example, 192.0.2.1/24. + type: str + secondary: + description: + - secondary flag of the ip address. + type: bool + default: 'False' + anycast_addresses: + description: + - List of IPv4 addresses to be set for anycast. + type: list + elements: str + ipv6: + description: + - ipv6 configurations to be set for the Layer 3 interface mentioned in name option. + type: dict + suboptions: + addresses: + description: + - List of IPv6 addresses to be set. + type: list + elements: dict + suboptions: + address: + description: + - IPv6 address to be set in the address format is <ipv6 address>/<mask> + for example, 2001:db8:2201:1::1/64. + type: str + enabled: + description: + - enabled flag of the ipv6. + type: bool + state: + description: + - The state that the configuration should be left in. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ + +# Using deleted +# +# Before state: +# ------------- +# +#rno-dctor-1ar01c01sw02# show running-configuration interface +#! +#interface Ethernet20 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 83.1.1.1/16 +# ip address 84.1.1.1/16 secondary +# ipv6 address 83::1/16 +# ipv6 address 84::1/16 +# ipv6 enable +#! +#interface Ethernet24 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 91.1.1.1/16 +# ip address 92.1.1.1/16 secondary +# ipv6 address 90::1/16 +# ipv6 address 91::1/16 +# ipv6 address 92::1/16 +# ipv6 address 93::1/16 +#! +#interface Vlan501 +# ip anycast-address 11.12.13.14/12 +# ip anycast-address 1.2.3.4/22 +#! +# +# +- name: delete one l3 interface. + dellemc.enterprise_sonic.sonic_l3_interfaces: + config: + - name: Ethernet20 + ipv4: + addresses: + - address: 83.1.1.1/16 + - address: 84.1.1.1/16 + - name: Ethernet24 + ipv6: + enabled: true + addresses: + - address: 91::1/16 + - name: Vlan501 + ipv4: + anycast_addresses: + - 11.12.13.14/12 + state: deleted + +# After state: +# ------------ +# +#rno-dctor-1ar01c01sw02# show running-configuration interface +#! +#interface Ethernet20 +# mtu 9100 +# speed 100000 +# shutdown +# ipv6 address 83::1/16 +# ipv6 address 84::1/16 +# ipv6 enable +#! +#interface Ethernet24 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 91.1.1.1/16 +# ip address 92.1.1.1/16 secondary +# ipv6 address 90::1/16 +# ipv6 address 92::1/16 +# ipv6 address 93::1/16 +#! +#interface Vlan501 +# ip anycast-address 1.2.3.4/22 +#! +# +# Using deleted +# +# Before state: +# ------------- +# +#rno-dctor-1ar01c01sw02# show running-configuration interface +#! +#interface Ethernet20 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 83.1.1.1/16 +# ip address 84.1.1.1/16 secondary +# ipv6 address 83::1/16 +# ipv6 address 84::1/16 +# ipv6 enable +#! +#interface Ethernet24 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 91.1.1.1/16 +# ipv6 address 90::1/16 +# ipv6 address 91::1/16 +# ipv6 address 92::1/16 +# ipv6 address 93::1/16 +#! +#interface Vlan501 +# ip anycast-address 11.12.13.14/12 +# ip anycast-address 1.2.3.4/22 +#! +# +# +- name: delete all l3 interface + dellemc.enterprise_sonic.sonic_l3_interfaces: + config: + state: deleted +# +# After state: +# ------------ +# +#rno-dctor-1ar01c01sw02# show running-configuration interface +#! +#interface Ethernet20 +# mtu 9100 +# speed 100000 +# shutdown +#! +#interface Ethernet24 +# mtu 9100 +# speed 100000 +# shutdown +#! +#interface Vlan501 +#! +# +# Using merged +# +# Before state: +# ------------- +# +#rno-dctor-1ar01c01sw02# show running-configuration interface +#! +#interface Ethernet20 +# mtu 9100 +# speed 100000 +# shutdown +#! +#interface Ethernet24 +# mtu 9100 +# speed 100000 +# shutdown +#! +#interface Vlan501 +# ip anycast-address 1.2.3.4/22 +#! +# +- name: Add l3 interface configurations + dellemc.enterprise_sonic.sonic_l3_interfaces: + config: + - name: Ethernet20 + ipv4: + addresses: + - address: 83.1.1.1/16 + - address: 84.1.1.1/16 + secondary: True + ipv6: + enabled: true + addresses: + - address: 83::1/16 + - address: 84::1/16 + secondary: True + - name: Ethernet24 + ipv4: + addresses: + - address: 91.1.1.1/16 + ipv6: + addresses: + - address: 90::1/16 + - address: 91::1/16 + - address: 92::1/16 + - address: 93::1/16 + - name: Vlan501 + ipv4: + anycast_addresses: + - 11.12.13.14/12 + state: merged +# +# After state: +# ------------ +# +#rno-dctor-1ar01c01sw02# show running-configuration interface +#! +#interface Ethernet20 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 83.1.1.1/16 +# ip address 84.1.1.1/16 secondary +# ipv6 address 83::1/16 +# ipv6 address 84::1/16 +# ipv6 enable +#! +#interface Ethernet24 +# mtu 9100 +# speed 100000 +# shutdown +# ip address 91.1.1.1/16 +# ipv6 address 90::1/16 +# ipv6 address 91::1/16 +# ipv6 address 92::1/16 +# ipv6 address 93::1/16 +#! +#interface Vlan501 +# ip anycast-address 1.2.3.4/22 +# ip anycast-address 11.12.13.14/12 +#! +# +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.l3_interfaces.l3_interfaces import L3_interfacesArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.l3_interfaces.l3_interfaces import L3_interfaces + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=L3_interfacesArgs.argument_spec, + supports_check_mode=True) + + result = L3_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_lag_interfaces.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_lag_interfaces.py new file mode 100644 index 000000000..630db7985 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_lag_interfaces.py @@ -0,0 +1,238 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_lag_interfaces +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_lag_interfaces +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage link aggregation group (LAG) interface parameters +description: + - This module manages attributes of link aggregation group (LAG) interfaces of + devices running Enterprise SONiC Distribution by Dell Technologies. +author: Abirami N (@abirami-n) + +options: + config: + description: A list of LAG configurations. + type: list + elements: dict + suboptions: + name: + description: + - ID of the LAG. + type: str + required: True + members: + description: + - The list of interfaces that are part of the group. + type: dict + suboptions: + interfaces: + description: The list of interfaces that are part of the group. + type: list + elements: dict + suboptions: + member: + description: + - The interface name. + type: str + mode: + description: + - Specifies mode of the port-channel while creation. + type: str + choices: + - static + - lacp + state: + description: + - The state that the configuration should be left in. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# interface Eth1/10 +# mtu 9100 +# speed 100000 +# no shutdown +# ! +# interface Eth1/15 +# channel-group 12 +# mtu 9100 +# speed 100000 +# no shutdown +# +- name: Merges provided configuration with device configuration + dellemc.enterprise_sonic.sonic_lag_interfaces: + config: + - name: PortChannel10 + members: + interfaces: + - member: Eth1/10 + state: merged +# +# After state: +# ------------ +# +# interface Eth1/10 +# channel-group 10 +# mtu 9100 +# speed 100000 +# no shutdown +# ! +# interface Eth1/15 +# channel-group 12 +# mtu 9100 +# speed 100000 +# no shutdown +# +# Using deleted +# +# Before state: +# ------------- +# interface PortChannel10 +# ! +# interface Eth1/10 +# channel-group 10 +# mtu 9100 +# speed 100000 +# no shutdown +# +- name: Deletes LAG attributes of a given interface, This does not delete the port-channel itself + dellemc.enterprise_sonic.sonic_lag_interfaces: + config: + - name: PortChannel10 + members: + interfaces: + state: deleted +# +# After state: +# ------------ +# interface PortChannel10 +# ! +# interface Eth1/10 +# mtu 9100 +# speed 100000 +# no shutdown +# +# Using deleted +# +# Before state: +# ------------- +# interface PortChannel 10 +# ! +# interface PortChannel 12 +# ! +# interface Eth1/10 +# channel-group 10 +# mtu 9100 +# speed 100000 +# no shutdown +# ! +# interface Eth1/15 +# channel-group 12 +# mtu 9100 +# speed 100000 +# no shutdown +# +- name: Deletes all LAGs and LAG attributes of all interfaces + dellemc.enterprise_sonic.sonic_lag_interfaces: + config: + state: deleted +# +# After state: +# ------------- +# +# interface Eth1/10 +# mtu 9100 +# speed 100000 +# no shutdown +# ! +# interface Eth1/15 +# mtu 9100 +# speed 100000 +# no shutdown +# +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration that is returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.lag_interfaces.lag_interfaces import Lag_interfacesArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.lag_interfaces.lag_interfaces import Lag_interfaces + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Lag_interfacesArgs.argument_spec, + supports_check_mode=True) + + result = Lag_interfaces(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_mclag.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_mclag.py new file mode 100644 index 000000000..28d3dbb5b --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_mclag.py @@ -0,0 +1,516 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_mclag +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_mclag +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage multi chassis link aggregation groups domain (MCLAG) and its parameters +description: + - Manage multi chassis link aggregation groups domain (MCLAG) and its parameters +author: Abirami N (@abirami-n) + +options: + config: + description: Dict of mclag domain configurations. + type: dict + suboptions: + domain_id: + description: + - ID of the mclag domain (MCLAG domain). + type: int + required: True + peer_address: + description: + - The IPV4 peer-ip for corresponding MCLAG. + type: str + source_address: + description: + - The IPV4 source-ip for corresponding MCLAG. + type: str + peer_link: + description: + - Peer-link for corresponding MCLAG. + type: str + system_mac: + description: + - Mac address of MCLAG. + type: str + keepalive: + description: + - MCLAG session keepalive-interval in secs. + type: int + session_timeout: + description: + - MCLAG session timeout value in secs. + type: int + unique_ip: + description: Holds Vlan dictionary for mclag unique ip. + suboptions: + vlans: + description: + - Holds list of VLANs for which a separate IP addresses is enabled for Layer 3 protocol support over MCLAG. + type: list + elements: dict + suboptions: + vlan: + description: Holds a VLAN ID. + type: str + type: dict + members: + description: Holds portchannels dictionary for an MCLAG domain. + suboptions: + portchannels: + description: + - Holds a list of portchannels for configuring as an MCLAG interface. + type: list + elements: dict + suboptions: + lag: + description: Holds a PortChannel ID. + type: str + type: dict + state: + description: + - The state that the configuration should be left in. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using merged +# +# Before state: +# ------------- +# +# sonic# show mclag brief +# MCLAG Not Configured +# +- name: Merge provided configuration with device configuration + dellemc.enterprise_sonic.sonic_mclag: + config: + domain_id: 1 + peer_address: 1.1.1.1 + source_address: 2.2.2.2 + peer_link: 'Portchannel1' + keepalive: 1 + session_timeout: 3 + unique_ip: + vlans: + - vlan: Vlan4 + members: + portchannles: + - lag: PortChannel10 + state: merged +# +# After state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : 2.2.2.2 +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 1 secs +# Session Timeout : 3 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:1 +#----------------------------------------------------------- +# MLAG Interface Local/Remote Status +#----------------------------------------------------------- +# PortChannel10 down/down +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +# +# Using merged +# +# Before state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : 2.2.2.2 +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 1 secs +# Session Timeout : 3 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:1 +#----------------------------------------------------------- +# MLAG Interface Local/Remote Status +#----------------------------------------------------------- +# PortChannel10 down/down +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +# +- name: Merge device configuration with the provided configuration + dellemc.enterprise_sonic.sonic_mclag: + config: + domain_id: 1 + source_address: 3.3.3.3 + keepalive: 10 + session_timeout: 30 + unique_ip: + vlans: + - vlan: Vlan5 + members: + portchannels: + - lag: PortChannel12 + state: merged +# +# After state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : 3.3.3.3 +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 10 secs +# Session Timeout : 30 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:2 +#----------------------------------------------------------- +# MLAG Interface Local/Remote Status +#----------------------------------------------------------- +# PortChannel10 down/down +# PortChannel12 down/down +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# }, +# "Vlan5": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +# +# Using deleted +# +# Before state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : 3.3.3.3 +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 10 secs +# Session Timeout : 30 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:1 +#----------------------------------------------------------- +# MLAG Interface Local/Remote Status +#----------------------------------------------------------- +# PortChannel10 down/down +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +- name: Delete device configuration based on the provided configuration + dellemc.enterprise_sonic.sonic_mclag: + config: + domain_id: 1 + source_address: 3.3.3.3 + keepalive: 10 + members: + portchannels: + - lag: PortChannel10 + state: deleted +# +# After state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 1 secs +# Session Timeout : 15 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:0 +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +# +# +# Using deleted +# +# Before state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : 3.3.3.3 +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 10 secs +# Session Timeout : 30 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:1 +#----------------------------------------------------------- +# MLAG Interface Local/Remote Status +#----------------------------------------------------------- +# PortChannel10 down/down +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +- name: Delete all device configuration + dellemc.enterprise_sonic.sonic_mclag: + config: + state: deleted +# +# After state: +# ------------ +# +# sonic# show mclag brief +# MCLAG Not Configured +# +# admin@sonic:~$ show runningconfiguration all | grep MCLAG_UNIQUE_IP +# admin@sonic:~$ +# +# +# Using deleted +# +# Before state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : 3.3.3.3 +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 10 secs +# Session Timeout : 30 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:2 +#----------------------------------------------------------- +# MLAG Interface Local/Remote Status +#----------------------------------------------------------- +# PortChannel10 down/down +# PortChannel12 down/sown +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +- name: Delete device configuration based on the provided configuration + dellemc.enterprise_sonic.sonic_mclag: + config: + domain_id: 1 + source_address: 3.3.3.3 + keepalive: 10 + members: + portchannels: + - lag: PortChannel10 + state: deleted +# +# After state: +# ------------ +# +# sonic# show mclag brief +# +# Domain ID : 1 +# Role : standby +# Session Status : down +# Peer Link Status : down +# Source Address : +# Peer Address : 1.1.1.1 +# Peer Link : PortChannel1 +# Keepalive Interval : 1 secs +# Session Timeout : 15 secs +# System Mac : 20:04:0f:37:bd:c9 +# +# +# Number of MLAG Interfaces:0 +# +# admin@sonic:~$ show runningconfiguration all +# { +# ... +# "MCLAG_UNIQUE_IP": { +# "Vlan4": { +# "unique_ip": "enable" +# } +# }, +# ... +# } +# +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.mclag.mclag import MclagArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.mclag.mclag import Mclag + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=MclagArgs.argument_spec, + supports_check_mode=True) + + result = Mclag(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py new file mode 100644 index 000000000..87db8bb06 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_ntp.py @@ -0,0 +1,360 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_ntp +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +DOCUMENTATION = """ +--- +module: sonic_ntp +version_added: 2.0.0 +short_description: Manage NTP configuration on SONiC. +description: + - This module provides configuration management of NTP for devices running SONiC. +author: "M. Zhang (@mingjunzhang2019)" +options: + config: + description: + - Specifies NTP related configurations. + type: dict + suboptions: + source_interfaces: + type: list + elements: str + description: + - List of names of NTP source interfaces. + enable_ntp_auth: + type: bool + description: + - Enable or disable NTP authentication. + trusted_keys: + type: list + elements: int + description: + - List of trusted NTP authentication keys. + vrf: + type: str + description: + - VRF name on which NTP is enabled. + servers: + type: list + elements: dict + description: + - List of NTP servers. + suboptions: + address: + type: str + description: + - IPv4/IPv6 address or host name of NTP server. + required: true + key_id: + type: int + description: + - NTP authentication key used by server. + - Key_id can not be deleted. + minpoll: + type: int + description: + - Minimum poll interval to poll NTP server. + - minpoll can not be deleted. + maxpoll: + type: int + description: + - Maximum poll interval to poll NTP server. + - maxpoll can not be deleted. + ntp_keys: + type: list + elements: dict + description: + - List of NTP authentication keys. + suboptions: + key_id: + type: int + description: + - NTP authentication key identifier. + required: true + key_type: + type: str + description: + - NTP authentication key type. + - key_type can not be deleted. + - When "state" is "merged", "key_type" is required. + choices: + - NTP_AUTH_SHA1 + - NTP_AUTH_MD5 + - NTP_AUTH_SHA2_256 + key_value: + type: str + description: + - NTP authentication key value. + - key_value can not be deleted. + - When "state" is "merged", "key_value" is required. + encrypted: + type: bool + description: + - NTP authentication key_value is encrypted. + - encrypted can not be deleted. + - When "state" is "merged", "encrypted" is required. + + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#sonic# show ntp server +#---------------------------------------------------------------------- +#NTP Servers minpoll maxpoll Authentication key ID +#---------------------------------------------------------------------- +#10.11.0.1 6 10 +#10.11.0.2 5 9 +#dell.com 6 9 +#dell.org 7 10 +# +- name: Delete NTP server configuration + ntp: + config: + servers: + - address: 10.11.0.2 + - address: dell.org + state: deleted + +# After state: +# ------------ +# +#sonic# show ntp server +#---------------------------------------------------------------------- +#NTP Servers minpoll maxpoll Authentication key ID +#---------------------------------------------------------------------- +#10.11.0.1 6 10 +#dell.com 6 9 +# +# +# Using deleted +# +# Before state: +# ------------- +# +#sonic# show ntp global +#---------------------------------------------- +#NTP Global Configuration +#---------------------------------------------- +#NTP source-interfaces: Ethernet0, Ethernet4, Ethernet8, Ethernet16 +# +- name: Delete NTP source-interface configuration + ntp: + config: + source_interfaces: + - Ethernet8 + - Ethernet16 + state: deleted + +# After state: +# ------------ +# +#sonic# show ntp global +#---------------------------------------------- +#NTP Global Configuration +#---------------------------------------------- +#NTP source-interfaces: Ethernet0, Ethernet4 +# +# +# Using deleted +# +# Before state: +# ------------- +# +#sonic# show running-configuration | grep ntp +#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted +#ntp authentication-key 10 md5 U2FsdGVkX1/Gxds/5pscCvIKbVngGaKka4SQineS51Y= encrypted +#ntp authentication-key 20 sha2-256 U2FsdGVkX1/eAzKj1teKhYWD7tnzOsYOijGeFAT0rKM= encrypted +# +- name: Delete NTP key configuration + ntp: + config: + ntp_keys: + - key_id: 10 + - key_id: 20 + state: deleted +# +# After state: +# ------------ +# +#sonic# show running-configuration | grep ntp +#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted +# +# +# Using merged +# +# Before state: +# ------------- +# +#sonic# show ntp server +#---------------------------------------------------------------------- +#NTP Servers minpoll maxpoll Authentication key ID +#---------------------------------------------------------------------- +#10.11.0.1 6 10 +#dell.com 6 9 +# +- name: Merge NTP server configuration + ntp: + config: + servers: + - address: 10.11.0.2 + minpoll: 5 + - address: dell.org + minpoll: 7 + maxpoll: 10 + state: merged + +# After state: +# ------------ +# +#sonic# show ntp server +#---------------------------------------------------------------------- +#NTP Servers minpoll maxpoll Authentication key ID +#---------------------------------------------------------------------- +#10.11.0.1 6 10 +#10.11.0.2 5 9 +#dell.com 6 9 +#dell.org 7 10 +# +# +# Using merged +# +# Before state: +# ------------- +# +#sonic# show ntp global +#---------------------------------------------- +#NTP Global Configuration +#---------------------------------------------- +#NTP source-interfaces: Ethernet0, Ethernet4 +# +- name: Merge NTP source-interface configuration + ntp: + config: + source_interfaces: + - Ethernet8 + - Ethernet16 + state: merged + +# After state: +# ------------ +# +#sonic# show ntp global +#---------------------------------------------- +#NTP Global Configuration +#---------------------------------------------- +#NTP source-interfaces: Ethernet0, Ethernet4, Ethernet8, Ethernet16 +# +# +# Using merged +# +# Before state: +# ------------- +# +#sonic# show running-configuration | grep ntp +#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted +# +- name: Merge NTP key configuration + ntp: + config: + ntp_keys: + - key_id: 10 + key_type: NTP_AUTH_MD5 + key_value: dellemc10 + encrypted: false + - key_id: 20 + key_type: NTP_AUTH_SHA2_256 + key_value: dellemc20 + encrypted: false + state: merged +# +# After state: +# ------------ +# +#sonic# show running-configuration | grep ntp +#ntp authentication-key 8 sha1 U2FsdGVkX1/NpJrdOeyMeUHEkSohY6azY9VwbAqXRTY= encrypted +#ntp authentication-key 10 md5 U2FsdGVkX1/Gxds/5pscCvIKbVngGaKka4SQineS51Y= encrypted +#ntp authentication-key 20 sha2-256 U2FsdGVkX1/eAzKj1teKhYWD7tnzOsYOijGeFAT0rKM= encrypted +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.ntp.ntp import NtpArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.ntp.ntp import Ntp + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=NtpArgs.argument_spec, + supports_check_mode=True) + + result = Ntp(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_port_breakout.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_port_breakout.py new file mode 100644 index 000000000..66ea00476 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_port_breakout.py @@ -0,0 +1,228 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_port_breakout +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_port_breakout +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Niraimadaiselvam M (@niraimadaiselvamm) +short_description: Configure port breakout settings on physical interfaces +description: + - This module provides configuration management of port breakout parameters on devices running Enterprise SONiC. +options: + config: + description: + - Specifies the port breakout related configuration. + type: list + elements: dict + suboptions: + name: + description: + - Specifies the name of the port breakout. + type: str + required: true + mode: + description: + - Specifies the mode of the port breakout. + type: str + choices: + - 1x100G + - 1x400G + - 1x40G + - 2x100G + - 2x200G + - 2x50G + - 4x100G + - 4x10G + - 4x25G + - 4x50G + state: + description: + - Specifies the operation to be performed on the port breakout configured on the device. + - In case of merged, the input mode configuration will be merged with the existing port breakout configuration on the device. + - In case of deleted the existing port breakout mode configuration will be removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#do show interface breakout +#----------------------------------------------- +#Port Breakout Mode Status Interfaces +#----------------------------------------------- +#1/1 4x10G Completed Eth1/1/1 +# Eth1/1/2 +# Eth1/1/3 +# Eth1/1/4 +#1/11 1x100G Completed Eth1/11 +# + +- name: Merge users configurations + dellemc.enterprise_sonic.sonic_port_breakout: + config: + - name: 1/11 + mode: 1x100G + state: deleted + +# After state: +# ------------ +# +#do show interface breakout +#----------------------------------------------- +#Port Breakout Mode Status Interfaces +#----------------------------------------------- +#1/1 4x10G Completed Eth1/1/1 +# Eth1/1/2 +# Eth1/1/3 +# Eth1/1/4 +#1/11 Default Completed Ethernet40 + + +# Using deleted +# +# Before state: +# ------------- +# +#do show interface breakout +#----------------------------------------------- +#Port Breakout Mode Status Interfaces +#----------------------------------------------- +#1/1 4x10G Completed Eth1/1/1 +# Eth1/1/2 +# Eth1/1/3 +# Eth1/1/4 +#1/11 1x100G Completed Eth1/11 +# +- name: Merge users configurations + dellemc.enterprise_sonic.sonic_port_breakout: + config: + state: deleted + + +# After state: +# ------------ +# +#do show interface breakout +#----------------------------------------------- +#Port Breakout Mode Status Interfaces +#----------------------------------------------- +#1/1 Default Completed Ethernet0 +#1/11 Default Completed Ethernet40 + + +# Using merged +# +# Before state: +# ------------- +# +#do show interface breakout +#----------------------------------------------- +#Port Breakout Mode Status Interfaces +#----------------------------------------------- +#1/1 4x10G Completed Eth1/1/1 +# Eth1/1/2 +# Eth1/1/3 +# Eth1/1/4 +# +- name: Merge users configurations + dellemc.enterprise_sonic.sonic_port_breakout: + config: + - name: 1/11 + mode: 1x100G + state: merged + + +# After state: +# ------------ +# +#do show interface breakout +#----------------------------------------------- +#Port Breakout Mode Status Interfaces +#----------------------------------------------- +#1/1 4x10G Completed Eth1/1/1 +# Eth1/1/2 +# Eth1/1/3 +# Eth1/1/4 +#1/11 1x100G Completed Eth1/11 + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.port_breakout.port_breakout import Port_breakoutArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.port_breakout.port_breakout import Port_breakout + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Port_breakoutArgs.argument_spec, + supports_check_mode=True) + + result = Port_breakout(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_prefix_lists.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_prefix_lists.py new file mode 100644 index 000000000..5a734e8b2 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_prefix_lists.py @@ -0,0 +1,423 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_prefix_lists +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_prefix_lists +version_added: "2.0.0" +author: Kerry Meyer (@kerry-meyer) +short_description: prefix list configuration handling for SONiC +description: + - This module provides configuration management for prefix list parameters on devices running SONiC. +options: + config: + description: + - Specifies a list of prefix set configuration dictionaries + type: list + elements: dict + suboptions: + name: + description: + - Name of a prefix set (a list of prefix entries) + type: str + required: true + afi: + description: + - Specifies the Address Family for addresses in the prefix list entries + type: str + choices: ["ipv4", "ipv6"] + default: "ipv4" + prefixes: + description: + - A list of prefix entries + type: list + elements: dict + suboptions: + sequence: + description: + - Precedence for this prefix entry (unique within the prefix list) + type: int + required: true + action: + description: + - Action to be taken for addresses matching this prefix entry + type: str + required: true + choices: ["permit", "deny"] + prefix: + description: + - IPv4 or IPv6 prefix in A.B.C.D/LEN or A:B::C:D/LEN format + type: str + required: true + ge: + description: Minimum prefix length to be matched + type: int + le: + description: Maximum prefix length to be matched + type: int + state: + description: + - Specifies the type of configuration update to be performed on the device. + - For "merged", merge specified attributes with existing configured attributes. + - For "deleted", delete the specified attributes from exiting configuration. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using "merged" state to create initial configuration +# +# Before state: +# ------------- +# +# sonic# show running-configuration ip prefix-list +# sonic# +# (No configuration present) +# +# ------------- +# +- name: Merge initial prefix-list configuration + dellemc.enterprise_sonic.sonic_prefix_lists: + config: + - name: pfx1 + afi: "ipv4" + prefixes: + - sequence: 10 + prefix: "1.2.3.4/24" + action: "permit" + ge: 26 + le: 30 + state: merged + +# After state: +# ------------ +# +# sonic# show running-configuration ip prefix-list +# ! +# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30 +# ------------ +# +# *************************************************************** +# Using "merged" state to update and add configuration +# +# Before state: +# ------------ +# +# sonic# show running-configuration ip prefix-list +# ! +# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30 +# +# sonic# show running-configuration ipv6 prefix-list +# sonic# +# (no IPv6 prefix-list configuration present) +# +# ------------ +# +- name: Merge additional prefix-list configuration + dellemc.enterprise_sonic.sonic_prefix_lists: + config: + - name: pfx1 + afi: "ipv4" + prefixes: + - sequence: 20 + action: "deny" + prefix: "1.2.3.12/26" + - sequence: 30 + action: "permit" + prefix: "7.8.9.0/24" + - name: pfx6 + afi: "ipv6" + prefixes: + - sequence: 25 + action: "permit" + prefix: "40::300/124" + state: merged + +# After state: +# ------------ +# +# sonic# show running-configuration ip prefix-list +# ! +# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30 +# ip prefix-list pfx1 seq 20 deny 1.2.3.12/26 +# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24 +# +# sonic# show running-configuration ipv6 prefix-list +# ! +# ipv6 prefix-list pfx6 seq 25 permit 40::300/124 +# +# *************************************************************** +# Using "deleted" state to remove configuration +# +# Before state: +# ------------ +# +# sonic# show running-configuration ip prefix-list +# ! +# ip prefix-list pfx1 seq 10 permit 1.2.3.4/24 ge 26 le 30 +# ip prefix-list pfx1 seq 20 deny 1.2.3.12/26 +# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24 +# +# sonic# show running-configuration ipv6 prefix-list +# ! +# ipv6 prefix-list pfx6 seq 25 permit 40::300/124 +# +# ------------ +# +- name: Delete selected prefix-list configuration + dellemc.enterprise_sonic.sonic_prefix_lists: + config: + - name: pfx1 + afi: "ipv4" + prefixes: + - sequence: 10 + prefix: "1.2.3.4/24" + action: "permit" + ge: 26 + le: 30 + - sequence: 20 + action: "deny" + prefix: "1.2.3.12/26" + - name: pfx6 + afi: "ipv6" + prefixes: + - sequence: 25 + action: "permit" + prefix: "40::300/124" + state: deleted + +# After state: +# ------------ +# +# sonic# show running-configuration ip prefix-list +# ! +# ip prefix-list pfx1 seq 30 permit 7.8.9.0/24 +# +# sonic# show running-configuration ipv6 prefix-list +# sonic# +# (no IPv6 prefix-list configuration present) +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + +# "before": [ +# { +# "afi": "ipv6", +# "name": "pf4", +# "prefixes": [ +# { +# "action": "permit", +# "ge": null, +# "le": null, +# "prefix": "50:60::/64", +# "sequence": 40 +# } +# ] +# }, +# { +# "afi": "ipv4", +# "name": "pf3", +# "prefixes": [ +# { +# "action": "deny", +# "ge": null, +# "le": 27, +# "prefix": "1.2.3.128/25", +# "sequence": 30 +# } +# ] +# }, +# { +# "afi": "ipv4", +# "name": "pf2", +# "prefixes": [ +# { +# "action": "permit", +# "ge": 27, +# "le": 29, +# "prefix": "10.20.30.128/25", +# "sequence": 50 +# }, +# { +# "action": "deny", +# "ge": 26, +# "le": null, +# "prefix": "10.20.30.0/24", +# "sequence": 20 +# } +# ] +# }, +# { +# "afi": "ipv4", +# "name": "pf1", +# "prefixes": [ +# { +# "action": "deny", +# "ge": 25, +# "le": 27, +# "prefix": "1.2.3.0/24", +# "sequence": 10 +# } +# ] +# } +# ] + +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + +# "after": [ +# { +# "afi": "ipv4", +# "name": "pf5", +# "prefixes": [ +# { +# "action": "permit", +# "ge": null, +# "le": null, +# "prefix": "15.25.35.0/24", +# "sequence": 15 +# } +# ] +# }, +# { +# "afi": "ipv4", +# "name": "pf1", +# "prefixes": [ +# { +# "action": "deny", +# "ge": 25, +# "le": 27, +# "prefix": "1.2.3.0/24", +# "sequence": 10 +# } +# ] +# }, +# { +# "afi": "ipv6", +# "name": "pf4", +# "prefixes": [ +# { +# "action": "permit", +# "ge": null, +# "le": null, +# "prefix": "50:60::/64", +# "sequence": 40 +# } +# ] +# }, +# { +# "afi": "ipv4", +# "name": "pf3", +# "prefixes": [ +# { +# "action": "deny", +# "ge": null, +# "le": 27, +# "prefix": "1.2.3.128/25", +# "sequence": 30 +# } +# ] +# }, +# { +# "afi": "ipv4", +# "name": "pf2", +# "prefixes": [ +# { +# "action": "permit", +# "ge": 27, +# "le": 29, +# "prefix": "10.20.30.128/25", +# "sequence": 50 +# }, +# { +# "action": "deny", +# "ge": 26, +# "le": null, +# "prefix": "10.20.30.0/24", +# "sequence": 20 +# } +# ] +# } +# ] + +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: + +# "commands": [ +# { +# "afi": "ipv4", +# "name": "pf5", +# "prefixes": [ +# { +# "action": "permit", +# "prefix": "15.25.35.0/24", +# "sequence": 15 +# } +# ], +# "state": "merged" +# } +# ], +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.prefix_lists.prefix_lists import Prefix_listsArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.prefix_lists.prefix_lists import Prefix_lists + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Prefix_listsArgs.argument_spec, + supports_check_mode=True) + + result = Prefix_lists(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_radius_server.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_radius_server.py new file mode 100644 index 000000000..1df4aff61 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_radius_server.py @@ -0,0 +1,328 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_radius_server +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_radius_server +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Niraimadaiselvam M (@niraimadaiselvamm) +short_description: Manage RADIUS server and its parameters +description: + - This module provides configuration management of radius server parameters on devices running Enterprise SONiC. +options: + config: + description: + - Specifies the radius server related configuration. + type: dict + suboptions: + auth_type: + description: + - Specifies the authentication type of the radius server. + type: str + choices: + - pap + - chap + - mschapv2 + default: pap + key: + description: + - Specifies the key of the radius server. + type: str + nas_ip: + description: + - Specifies the network access server of the radius server. + type: str + statistics: + description: + - Specifies the statistics flag of the radius server. + type: bool + timeout: + description: + - Specifies the timeout of the radius server. + type: int + retransmit: + description: + - Specifies the re-transmit value of the radius server. + type: int + servers: + description: + - Specifies the servers list of the radius server. + type: dict + suboptions: + host: + description: + - Specifies the host details of the radius servers list. + type: list + elements: dict + suboptions: + name: + description: + - Specifies the name of the radius server host. + type: str + auth_type: + description: + - Specifies the authentication type of the radius server host. + type: str + choices: + - pap + - chap + - mschapv2 + key: + description: + - Specifies the key of the radius server host. + type: str + priority: + description: + - Specifies the priority of the radius server host. + type: int + port: + description: + - Specifies the port of the radius server host. + type: int + timeout: + description: + - Specifies the timeout of the radius server host. + type: int + retransmit: + description: + - Specifies the retransmit of the radius server host. + type: int + source_interface: + description: + - Specifies the source interface of the radius server host. + type: str + vrf: + description: + - Specifies the vrf of the radius server host. + type: str + state: + description: + - Specifies the operation to be performed on the radius server configured on the device. + - In case of merged, the input mode configuration will be merged with the existing radius server configuration on the device. + - In case of deleted the existing radius server mode configuration will be removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#sonic(config)# do show radius-server +#--------------------------------------------------------- +#RADIUS Global Configuration +#--------------------------------------------------------- +#nas-ip-addr: 1.2.3.4 +#statistics : True +#timeout : 10 +#auth-type : chap +#key : chap +#retransmit : 3 +#-------------------------------------------------------------------------------- +#HOST AUTH-TYPE KEY AUTH-PORT PRIORITY TIMEOUT RTSMT VRF SI +#-------------------------------------------------------------------------------- +#localhost mschapv2 local 52 2 20 2 mgmt Ethernet12 +#myhost chap local 53 3 23 3 mgmt Ethernet24 +#--------------------------------------------------------- +#RADIUS Statistics +#--------------------------------------------------------- +# + +- name: Merge radius configurations + dellemc.enterprise_sonic.sonic_radius_server: + config: + auth_type: chap + nas_ip: 1.2.3.4 + statistics: true + timeout: 10 + servers: + host: + - name: localhost + state: deleted + +# After state: +# ------------ +#sonic(config)# do show radius-server +#--------------------------------------------------------- +#RADIUS Global Configuration +#--------------------------------------------------------- +#timeout : 5 +#auth-type : pap +#key : chap +#retransmit : 3 +#-------------------------------------------------------------------------------- +#HOST AUTH-TYPE KEY AUTH-PORT PRIORITY TIMEOUT RTSMT VRF SI +#-------------------------------------------------------------------------------- +#myhost chap local 53 3 23 3 mgmt Ethernet24 + + +# Using deleted +# +# Before state: +# ------------- +# +#sonic(config)# do show radius-server +#--------------------------------------------------------- +#RADIUS Global Configuration +#--------------------------------------------------------- +#nas-ip-addr: 1.2.3.4 +#statistics : True +#timeout : 10 +#auth-type : chap +#key : chap +#retransmit : 3 +#-------------------------------------------------------------------------------- +#HOST AUTH-TYPE KEY AUTH-PORT PRIORITY TIMEOUT RTSMT VRF SI +#-------------------------------------------------------------------------------- +#localhost mschapv2 local 52 2 20 2 mgmt Ethernet12 +#myhost chap local 53 3 23 3 mgmt Ethernet24 +#--------------------------------------------------------- +#RADIUS Statistics +#--------------------------------------------------------- +# +- name: Merge radius configurations + dellemc.enterprise_sonic.sonic_radius_server: + config: + state: deleted + +# After state: +# ------------ +#sonic(config)# do show radius-server +#--------------------------------------------------------- +#RADIUS Global Configuration +#--------------------------------------------------------- +#timeout : 5 +#auth-type : pap + + +# Using merged +# +# Before state: +# ------------- +# +#sonic(config)# do show radius-server +#--------------------------------------------------------- +#RADIUS Global Configuration +#--------------------------------------------------------- +# +- name: Merge radius configurations + dellemc.enterprise_sonic.sonic_radius_server: + config: + auth_type: chap + key: chap + nas_ip: 1.2.3.4 + statistics: true + timeout: 10 + retransmit: 3 + servers: + host: + - name: localhost + auth_type: mschapv2 + key: local + priority: 2 + port: 52 + retransmit: 2 + timeout: 20 + source_interface: Eth 12 + vrf: mgmt + state: merged + +# After state: +# ------------ +# +#sonic(config)# do show radius-server +#--------------------------------------------------------- +#RADIUS Global Configuration +#--------------------------------------------------------- +#nas-ip-addr: 1.2.3.4 +#statistics : True +#timeout : 10 +#auth-type : chap +#key : chap +#retransmit : 3 +#-------------------------------------------------------------------------------- +#HOST AUTH-TYPE KEY AUTH-PORT PRIORITY TIMEOUT RTSMT VRF SI +#-------------------------------------------------------------------------------- +#localhost mschapv2 local 52 2 20 2 mgmt Ethernet12 +#--------------------------------------------------------- +#RADIUS Statistics +#--------------------------------------------------------- + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.radius_server.radius_server import Radius_serverArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.radius_server.radius_server import Radius_server + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Radius_serverArgs.argument_spec, + supports_check_mode=True) + + result = Radius_server(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_static_routes.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_static_routes.py new file mode 100644 index 000000000..7a528cdf0 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_static_routes.py @@ -0,0 +1,267 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_static_routes +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_static_routes +version_added: 2.0.0 +short_description: Manage static routes configuration on SONiC +description: + - This module provides configuration management of static routes for devices running SONiC +author: "Shade Talabi (@stalabi1)" +options: + config: + type: list + elements: dict + description: + - Manages 'static_routes' configurations + suboptions: + vrf_name: + required: True + type: str + description: + - Name of the configured VRF on the device. + static_list: + type: list + elements: dict + description: + - A list of 'static_routes' configurations. + suboptions: + prefix: + required: True + type: str + description: + - Destination prefix for the static route, either IPv4 or IPv6. + next_hops: + type: list + elements: dict + description: + - A list of next-hops to be utilised for the static route being specified. + suboptions: + index: + required: True + type: dict + description: + - An identifier utilised to uniquely reference the next-hop. + suboptions: + blackhole: + type: bool + default: False + description: + - Indicates that packets matching this route should be discarded. + interface: + type: str + description: + - The reference to a base interface. + nexthop_vrf: + type: str + description: + - Name of the next-hop network instance for leaked routes. + next_hop: + type: str + description: + - The next-hop that is to be used for the static route. + metric: + type: int + description: + - Specifies the preference of the next-hop entry when it is injected into the RIB. + track: + type: int + description: + - The IP SLA track ID for static route. + tag: + type: int + description: + - The tag value for the static route. + state: + description: + - The state of the configuration after module completion. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ + +# Using merged +# +# Before State: +# ------------- +# +# sonic# show running-configuration | grep "ip route" +# (No "ip route" configuration present) + + - name: Merge static routes configurations + dellemc.enterprise_sonic.sonic_static_routes: + config: + - vrf_name: 'default' + static_list: + - prefix: '2.0.0.0/8' + next_hops: + - index: + interface: 'Ethernet4' + metric: 1 + tag: 2 + track: 3 + - index: + next_hop: '3.0.0.0' + metric: 2 + tag: 4 + track: 8 + - vrf_name: '{{vrf_1}}' + static_list: + - prefix: '3.0.0.0/8' + next_hops: + - index: + interface: 'eth0' + nexthop_vrf: '{{vrf_2}}' + next_hop: '4.0.0.0' + metric: 4 + tag: 5 + track: 6 + - index: + blackhole: True + metric: 10 + tag: 20 + track: 30 + state: merged + +# After State: +# ------------ +# +# sonic# show running-configuration | grep "ip route" +# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2 +# ip route 2.0.0.0/8 interface Ethernet4 tag 2 track 3 1 +# ip route vrf VrfReg1 3.0.0.0/8 4.0.0.0 interface Management 0 nexthop-vrf VrfReg2 tag 5 track 6 4 +# ip route vrf VrfREg1 3.0.0.0/8 blackhole tag 20 track 30 10 +# +# +# Modifying previous merge + + - name: Modify static routes configurations + dellemc.enterprise_sonic.sonic_static_routes: + config: + - vrf_name: '{{vrf_1}}' + static_list: + - prefix: '3.0.0.0/8' + next_hops: + - index: + blackhole: True + metric: 11 + tag: 22 + track: 33 + state: merged + +# After State: +# ------------ +# +# sonic# show running-configuration | grep "ip route" +# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2 +# ip route 2.0.0.0/8 interface Ethernet4 tag 2 track 3 1 +# ip route vrf VrfReg1 3.0.0.0/8 4.0.0.0 interface Management 0 nexthop-vrf VrfReg2 tag 5 track 6 4 +# ip route vrf VrfREg1 3.0.0.0/8 blackhole tag 22 track 33 11 + + +# Using deleted +# +# Before State: +# ------------- +# +# sonic# show running-configuration | grep "ip route" +# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2 +# ip route 2.0.0.0/8 interface Ethernet4 tag 2 track 3 1 +# ip route vrf VrfReg1 3.0.0.0/8 4.0.0.0 interface Management 0 nexthop-vrf VrfReg2 tag 5 track 6 4 +# ip route vrf VrfREg1 3.0.0.0/8 blackhole tag 22 track 33 11 + + - name: Delete static routes configurations + dellemc.enterprise_sonic.sonic_static_routes: + config: + - vrf_name: 'default' + static_list: + - prefix: '2.0.0.0/8' + next_hops: + - index: + interface: 'Ethernet4' + - vrf_name: '{{vrf_1}}' + state: deleted + +# After State: +# ------------ +# +# sonic# show running-configuration | grep "ip route" +# ip route 2.0.0.0/8 3.0.0.0 tag 4 track 8 2 + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.static_routes.static_routes import Static_routesArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.static_routes.static_routes import Static_routes + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Static_routesArgs.argument_spec, + supports_check_mode=True) + + result = Static_routes(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_system.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_system.py new file mode 100644 index 000000000..efb285a11 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_system.py @@ -0,0 +1,214 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_system +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_system +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Abirami N (@abirami-n) +short_description: Configure system parameters +description: + - This module is used for configuration management of global system parameters on devices running Enterprise SONiC. +options: + config: + description: + - Specifies the system related configurations + type: dict + suboptions: + hostname: + description: + - Specifies the hostname of the SONiC device + type: str + interface_naming: + description: + - Specifies the type of interface-naming in device + type: str + choices: + - standard + - native + anycast_address: + description: + - Specifies different types of anycast address that can be configured on the device + type: dict + suboptions: + ipv4: + description: + - Enable or disable ipv4 anycast-address + type: bool + ipv6: + description: + - Enable or disable ipv6 anycast-address + type: bool + mac_address: + description: + - Specifies the mac anycast-address + type: str + state: + description: + - Specifies the operation to be performed on the system parameters configured on the device. + - In case of merged, the input configuration will be merged with the existing system configuration on the device. + - In case of deleted the existing system configuration will be removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +#! +#SONIC(config)#do show running-configuration +#! +#ip anycast-mac-address aa:bb:cc:dd:ee:ff +#ip anycast-address enable +#ipv6 anycast-address enable +#interface-naming standard + +- name: Merge provided configuration with device configuration + dellemc.enterprise_sonic.sonic_system: + config: + hostname: SONIC + interface_naming: standard + anycast_address: + ipv6: true + state: deleted + +# After state: +# ------------ +#! +#sonic(config)#do show running-configuration +#! +#ip anycast-mac-address aa:bb:cc:dd:ee:ff +#ip anycast-address enable + + +# Using deleted +# +# Before state: +# ------------- +#! +#SONIC(config)#do show running-configuration +#! +#ip anycast-mac-address aa:bb:cc:dd:ee:ff +#ip anycast-address enable +#ipv6 anycast-address enable +#interface-naming standard + +- name: Delete all system related configs in device configuration + dellemc.enterprise_sonic.sonic_system: + config: + state: deleted + +# After state: +# ------------ +#! +#sonic(config)#do show running-configuration +#! + + +# Using merged +# +# Before state: +# ------------- +#! +#sonic(config)#do show running-configuration +#! + +- name: Merge provided configuration with device configuration + dellemc.enterprise_sonic.sonic_system: + config: + hostname: SONIC + interface_naming: standard + anycast_address: + ipv6: true + ipv4: true + mac_address: aa:bb:cc:dd:ee:ff + state: merged + +# After state: +# ------------ +#! +#SONIC(config)#do show running-configuration +#! +#ip anycast-mac-address aa:bb:cc:dd:ee:ff +#ip anycast-address enable +#ipv6 anycast-address enable +#interface-naming standard + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.system.system import SystemArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.system.system import System + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=SystemArgs.argument_spec, + supports_check_mode=True) + + result = System(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_tacacs_server.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_tacacs_server.py new file mode 100644 index 000000000..3295e11ba --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_tacacs_server.py @@ -0,0 +1,297 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_tacacs_server +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_tacacs_server +version_added: 1.1.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Niraimadaiselvam M (@niraimadaiselvamm) +short_description: Manage TACACS server and its parameters +description: + - This module provides configuration management of tacacs server parameters on devices running Enterprise SONiC. +options: + config: + description: + - Specifies the tacacs server related configuration. + type: dict + suboptions: + auth_type: + description: + - Specifies the authentication type of the tacacs server. + type: str + choices: + - pap + - chap + - mschap + - login + default: pap + key: + description: + - Specifies the key of the tacacs server. + type: str + timeout: + description: + - Specifies the timeout of the tacacs server. + type: int + source_interface: + description: + - Specifies the source interface of the tacacs server. + type: str + servers: + description: + - Specifies the servers list of the tacacs server. + type: dict + suboptions: + host: + description: + - Specifies the host details of the tacacs servers list. + type: list + elements: dict + suboptions: + name: + description: + - Specifies the name of the tacacs server host. + type: str + auth_type: + description: + - Specifies the authentication type of the tacacs server host. + type: str + choices: + - pap + - chap + - mschap + - login + default: pap + key: + description: + - Specifies the key of the tacacs server host. + type: str + priority: + description: + - Specifies the priority of the tacacs server host. + type: int + default: 1 + port: + description: + - Specifies the port of the tacacs server host. + type: int + default: 49 + timeout: + description: + - Specifies the timeout of the tacacs server host. + type: int + default: 5 + vrf: + description: + - Specifies the vrf of the tacacs server host. + type: str + default: default + state: + description: + - Specifies the operation to be performed on the tacacs server configured on the device. + - In case of merged, the input mode configuration will be merged with the existing tacacs server configuration on the device. + - In case of deleted the existing tacacs server mode configuration will be removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +# do show tacacs-server +#--------------------------------------------------------- +#TACACS Global Configuration +#--------------------------------------------------------- +#source-interface : Ethernet12 +#timeout : 10 +#auth-type : login +#key : login +#------------------------------------------------------------------------------------------------ +#HOST AUTH-TYPE KEY PORT PRIORITY TIMEOUT VRF +#------------------------------------------------------------------------------------------------ +#1.2.3.4 pap ***** 50 2 10 mgmt +#localhost pap 49 1 5 default +# + +- name: Merge tacacs configurations + dellemc.enterprise_sonic.sonic_tacacs_server: + config: + auth_type: login + key: login + source_interface: Ethernet 12 + timeout: 10 + servers: + host: + - name: 1.2.3.4 + state: deleted + +# After state: +# ------------ +# +#do show tacacs-server +#--------------------------------------------------------- +#TACACS Global Configuration +#--------------------------------------------------------- +#timeout : 5 +#auth-type : pap +#------------------------------------------------------------------------------------------------ +#HOST AUTH-TYPE KEY PORT PRIORITY TIMEOUT VRF +#------------------------------------------------------------------------------------------------ +#localhost pap 49 1 5 default + + +# Using deleted +# +# Before state: +# ------------- +# +# do show tacacs-server +#--------------------------------------------------------- +#TACACS Global Configuration +#--------------------------------------------------------- +#source-interface : Ethernet12 +#timeout : 10 +#auth-type : login +#key : login +#------------------------------------------------------------------------------------------------ +#HOST AUTH-TYPE KEY PORT PRIORITY TIMEOUT VRF +#------------------------------------------------------------------------------------------------ +#1.2.3.4 pap ***** 50 2 10 mgmt +#localhost pap 49 1 5 default +# + +- name: Merge tacacs configurations + dellemc.enterprise_sonic.sonic_tacacs_server: + config: + state: deleted + +# After state: +# ------------ +# +#do show tacacs-server +#--------------------------------------------------------- +#TACACS Global Configuration +#--------------------------------------------------------- +#timeout : 5 +#auth-type : pap + + +# Using merged +# +# Before state: +# ------------- +# +#sonic(config)# do show tacacs-server +#--------------------------------------------------------- +#TACACS Global Configuration +#--------------------------------------------------------- +# +- name: Merge tacacs configurations + dellemc.enterprise_sonic.sonic_tacacs_server: + config: + auth_type: pap + key: pap + source_interface: Ethernet 12 + timeout: 10 + servers: + host: + - name: 1.2.3.4 + auth_type: pap + key: 1234 + state: merged + +# After state: +# ------------ +# +#sonic(config)# do show tacacs-server +#--------------------------------------------------------- +#TACACS Global Configuration +#--------------------------------------------------------- +#source-interface : Ethernet12 +#timeout : 10 +#auth-type : pap +#key : pap +#------------------------------------------------------------------------------------------------ +#HOST AUTH-TYPE KEY PORT PRIORITY TIMEOUT VRF +#------------------------------------------------------------------------------------------------ +#1.2.3.4 pap 1234 49 1 5 default + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.tacacs_server.tacacs_server import Tacacs_serverArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.tacacs_server.tacacs_server import Tacacs_server + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=Tacacs_serverArgs.argument_spec, + supports_check_mode=True) + + result = Tacacs_server(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_users.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_users.py new file mode 100644 index 000000000..7f0855a94 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_users.py @@ -0,0 +1,210 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2019 Red Hat +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_users +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_users +version_added: 1.1.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Niraimadaiselvam M (@niraimadaiselvamm) +short_description: Manage users and its parameters +description: + - This module provides configuration management of users parameters on devices running Enterprise SONiC. +options: + config: + description: + - Specifies the users related configuration. + type: list + elements: dict + suboptions: + name: + description: + - Specifies the name of the user. + type: str + required: true + role: + description: + - Specifies the role of the user. + type: str + choices: + - admin + - operator + password: + description: + - Specifies the password of the user. + type: str + update_password: + description: + - Specifies the update password flag. + - In case of always, password will be updated every time. + - In case of on_create, password will be updated only when user is created. + type: str + choices: + - always + - on_create + default: always + state: + description: + - Specifies the operation to be performed on the users configured on the device. + - In case of merged, the input configuration will be merged with the existing users configuration on the device. + - In case of deleted the existing users configuration will be removed from the device. + default: merged + choices: ['merged', 'deleted'] + type: str +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#do show running-configuration +#! +#username admin password $6$sdZt2C7F$3oPSRkkJyLZtsKlFNGWdwssblQWBj5dXM6qAJAQl7dgOfqLSpZJ/n6xf8zPRcqPUFCu5ZKpEtynJ9sZ/S8Mgj. role admin +#username sysadmin password $6$3QNqJzpFAPL9JqHA$417xFKw6SRn.CiqMFJkDfQJXKJGjeYwi2A8BIyfuWjGimvunOOjTRunVluudey/W9l8jhzN1oewBW5iLxmq2Q1 role admin +#username sysoperator password $6$s1eTVjcX4Udi69gY$zlYgqwoKRGC6hGL5iKDImN/4BL7LXKNsx9e5PoSsBLs6C80ShYj2LoJAUZ58ia2WNjcHXhTD1p8eU9wyRTCiE0 role operator +# +- name: Merge users configurations + dellemc.enterprise_sonic.sonic_users: + config: + - name: sysoperator + state: deleted +# After state: +# ------------ +# +#do show running-configuration +#! +#username admin password $6$sdZt2C7F$3oPSRkkJyLZtsKlFNGWdwssblQWBj5dXM6qAJAQl7dgOfqLSpZJ/n6xf8zPRcqPUFCu5ZKpEtynJ9sZ/S8Mgj. role admin +#username sysadmin password $6$3QNqJzpFAPL9JqHA$417xFKw6SRn.CiqMFJkDfQJXKJGjeYwi2A8BIyfuWjGimvunOOjTRunVluudey/W9l8jhzN1oewBW5iLxmq2Q1 role admin + + +# Using deleted +# +# Before state: +# ------------- +# +#do show running-configuration +#! +#username admin password $6$sdZt2C7F$3oPSRkkJyLZtsKlFNGWdwssblQWBj5dXM6qAJAQl7dgOfqLSpZJ/n6xf8zPRcqPUFCu5ZKpEtynJ9sZ/S8Mgj. role admin +#username sysadmin password $6$3QNqJzpFAPL9JqHA$417xFKw6SRn.CiqMFJkDfQJXKJGjeYwi2A8BIyfuWjGimvunOOjTRunVluudey/W9l8jhzN1oewBW5iLxmq2Q1 role admin +#username sysoperator password $6$s1eTVjcX4Udi69gY$zlYgqwoKRGC6hGL5iKDImN/4BL7LXKNsx9e5PoSsBLs6C80ShYj2LoJAUZ58ia2WNjcHXhTD1p8eU9wyRTCiE0 role operator +# +- name: Merge users configurations + dellemc.enterprise_sonic.sonic_users: + config: + state: deleted + +# After state: +# ------------ +# +#do show running-configuration +#! +#username admin password $6$sdZt2C7F$3oPSRkkJyLZtsKlFNGWdwssblQWBj5dXM6qAJAQl7dgOfqLSpZJ/n6xf8zPRcqPUFCu5ZKpEtynJ9sZ/S8Mgj. role admin + + +# Using merged +# +# Before state: +# ------------- +# +#do show running-configuration +#! +#username admin password $6$sdZt2C7F$3oPSRkkJyLZtsKlFNGWdwssblQWBj5dXM6qAJAQl7dgOfqLSpZJ/n6xf8zPRcqPUFCu5ZKpEtynJ9sZ/S8Mgj. role admin +# +- name: Merge users configurations + dellemc.enterprise_sonic.sonic_users: + config: + - name: sysadmin + role: admin + password: admin + update_password: always + - name: sysoperator + role: operator + password: operator + update_password: always + state: merged + +# After state: +# ------------ +#! +#do show running-configuration +#! +#username admin password $6$sdZt2C7F$3oPSRkkJyLZtsKlFNGWdwssblQWBj5dXM6qAJAQl7dgOfqLSpZJ/n6xf8zPRcqPUFCu5ZKpEtynJ9sZ/S8Mgj. role admin +#username sysadmin password $6$3QNqJzpFAPL9JqHA$417xFKw6SRn.CiqMFJkDfQJXKJGjeYwi2A8BIyfuWjGimvunOOjTRunVluudey/W9l8jhzN1oewBW5iLxmq2Q1 role admin +#username sysoperator password $6$s1eTVjcX4Udi69gY$zlYgqwoKRGC6hGL5iKDImN/4BL7LXKNsx9e5PoSsBLs6C80ShYj2LoJAUZ58ia2WNjcHXhTD1p8eU9wyRTCiE0 role operator + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned will always be in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.users.users import UsersArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.users.users import Users + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=UsersArgs.argument_spec, + supports_check_mode=True) + + result = Users(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vlans.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vlans.py new file mode 100644 index 000000000..cfd536c79 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vlans.py @@ -0,0 +1,241 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_vlans +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_vlans +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +author: Mohamed Javeed (@javeedf) +short_description: Manage VLAN and its parameters +description: + - This module provides configuration management of VLANs parameters + on devices running Enterprise SONiC Distribution by Dell Technologies. +options: + config: + description: A dictionary of VLAN options. + type: list + elements: dict + suboptions: + vlan_id: + description: + - ID of the VLAN + - Range is 1 to 4094 + type: int + required: true + description: + description: + - Description about the VLAN. + type: str + state: + description: + - The state that the configuration should be left in. + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using merged + +# Before state: +# ------------- +# +#sonic# show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#30 Inactive +# +#sonic# +# + + +- name: Merges given VLAN attributes with the device configuration + dellemc.enterprise_sonic.sonic_vlans: + config: + - vlan_id: 10 + description: "Internal" + state: merged + +# After state: +# ------------ +# +#sonic# show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#30 Inactive +# +#sonic# +# +#sonic# show interface Vlan 10 +#Description: Internal +#Vlan10 is up +#Mode of IPV4 address assignment: not-set +#Mode of IPV6 address assignment: not-set +#IP MTU 6000 bytes +#sonic# +# + + +# Using deleted + +# Before state: +# ------------- +# +#sonic# show interface Vlan 70 +#Description: Internal +#Vlan70 is up +#Mode of IPV4 address assignment: not-set +#Mode of IPV6 address assignment: not-set +#IP MTU 6000 bytes + +- name: Deletes attributes of the given VLANs + dellemc.enterprise_sonic.sonic_vlans: + config: + - vlan_id: 70 + description: "Internal" + state: deleted + +# After state: +# ------------ +# +#sonic# show interface Vlan 70 +#Vlan70 is up +#Mode of IPV4 address assignment: not-set +#Mode of IPV6 address assignment: not-set +#IP MTU 6000 bytes + +# Before state: +# ------------- +# +#sonic# show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#20 Inactive +# +#sonic# + +- name: Deletes attributes of the given VLANs + dellemc.enterprise_sonic.sonic_vlans: + config: + - vlan_id: 20 + state: deleted + +# After state: +# ------------ +# +#sonic# show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +# +#sonic# + + +# Using deleted + +# Before state: +# ------------- +# +#sonic# show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +#10 Inactive +#20 Inactive +#30 Inactive +# +#sonic# + +- name: Deletes all the VLANs on the switch + dellemc.enterprise_sonic.sonic_vlans: + config: + state: deleted + +# After state: +# ------------ +# +#sonic# show Vlan +#Q: A - Access (Untagged), T - Tagged +#NUM Status Q Ports +# +#sonic# + + +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration that is returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.vlans.vlans import VlansArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.vlans.vlans import Vlans + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=VlansArgs.argument_spec, + supports_check_mode=True) + + result = Vlans(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vrfs.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vrfs.py new file mode 100644 index 000000000..4c881aee6 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vrfs.py @@ -0,0 +1,204 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_vrfs +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_vrfs +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage VRFs and associate VRFs to interfaces such as, Eth, LAG, VLAN, and loopback +description: Manages VRF and VRF interface attributes in Enterprise SONiC Distribution by Dell Technologies. +author: Abirami N (@abirami-n) +options: + config: + description: A list of VRF configurations. + type: list + elements: dict + suboptions: + name: + type: str + description: The name of the VRF interface. + required: true + members: + type: dict + description: Holds a dictionary mapping of list of interfaces linked to a VRF interface. + suboptions: + interfaces: + type: list + elements: dict + description: List of interface names that are linked to a specific VRF interface. + suboptions: + name: + type: str + description: The name of the physical interface. + state: + description: "The state of the configuration after module completion." + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +#show ip vrf +#VRF-NAME INTERFACES +#---------------------------------------------------------------- +#Vrfcheck1 +#Vrfcheck2 +#Vrfcheck3 Eth1/3 +# Eth1/14 +# Eth1/16 +# Eth1/17 +#Vrfcheck4 Eth1/5 +# Eth1/6 +# +- name: Configuring vrf deleted state + dellemc.enterprise_sonic.sonic_vrfs: + config: + - name: Vrfcheck4 + members: + interfaces: + - name: Eth1/6 + - name: Vrfcheck3 + members: + interfaces: + - name: Eth1/3 + - name: Eth1/14 + state: deleted +# +# After state: +# ------------ +# +#show ip vrf +#VRF-NAME INTERFACES +#---------------------------------------------------------------- +#Vrfcheck1 +#Vrfcheck2 +#Vrfcheck3 Eth1/16 +# Eth1/17 +#Vrfcheck4 Eth1/5 +# +# +# Using merged +# +# Before state: +# ------------- +# +#show ip vrf +#VRF-NAME INTERFACES +#---------------------------------------------------------------- +#Vrfcheck1 +#Vrfcheck2 +#Vrfcheck3 Eth1/16 +# Eth1/17 +#Vrfcheck4 +# +- name: Configuring vrf merged state + dellemc.enterprise_sonic.sonic_vrfs: + config: + - name: Vrfcheck4 + members: + interfaces: + - name: Eth1/5 + - name: Eth1/6 + - name: Vrfcheck3 + members: + interfaces: + - name: Eth1/3 + - name: Eth1/14 + state: merged +# +# After state: +# ------------ +# +#show ip vrf +#VRF-NAME INTERFACES +#---------------------------------------------------------------- +#Vrfcheck1 +#Vrfcheck2 +#Vrfcheck3 Eth1/3 +# Eth1/14 +# Eth1/16 +# Eth1/17 +#Vrfcheck4 Eth1/5 +# Eth1/6 +# +""" +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.vrfs.vrfs import VrfsArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.vrfs.vrfs import Vrfs + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=VrfsArgs.argument_spec, + supports_check_mode=True) + + result = Vrfs(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vxlans.py b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vxlans.py new file mode 100644 index 000000000..e6613ba24 --- /dev/null +++ b/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_vxlans.py @@ -0,0 +1,245 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved +# GNU General Public License v3.0+ +# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +############################################# +# WARNING # +############################################# +# +# This file is auto generated by the resource +# module builder playbook. +# +# Do not edit this file manually. +# +# Changes to this file will be over written +# by the resource module builder. +# +# Changes should be made in the model used to +# generate this file or in the resource module +# builder template. +# +############################################# + +""" +The module file for sonic_vxlans +""" + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +DOCUMENTATION = """ +--- +module: sonic_vxlans +version_added: 1.0.0 +notes: +- Tested against Enterprise SONiC Distribution by Dell Technologies. +- Supports C(check_mode). +short_description: Manage VxLAN EVPN and its parameters +description: 'Manages interface attributes of Enterprise SONiC interfaces.' +author: Niraimadaiselvam M (@niraimadaiselvamm) +options: + config: + description: + - A list of VxLAN configurations. + - source_ip and evpn_nvo are required together. + type: list + elements: dict + suboptions: + name: + type: str + description: 'The name of the VxLAN.' + required: true + evpn_nvo: + type: str + description: 'EVPN nvo name' + source_ip: + description: 'The source IP address of the VTEP.' + type: str + primary_ip: + description: 'The vtep mclag primary ip address for this node' + type: str + vlan_map: + description: 'The list of VNI map of VLAN.' + type: list + elements: dict + suboptions: + vni: + type: int + description: 'Specifies the VNI ID.' + required: true + vlan: + type: int + description: 'VLAN ID for VNI VLAN map.' + vrf_map: + description: 'list of VNI map of VRF.' + type: list + elements: dict + suboptions: + vni: + type: int + description: 'Specifies the VNI ID.' + required: true + vrf: + type: str + description: 'VRF name for VNI VRF map.' + state: + description: 'The state of the configuration after module completion.' + type: str + choices: + - merged + - deleted + default: merged +""" +EXAMPLES = """ +# Using deleted +# +# Before state: +# ------------- +# +# do show running-configuration +# +#interface vxlan vteptest1 +# source-ip 1.1.1.1 +# primary-ip 2.2.2.2 +# map vni 101 vlan 11 +# map vni 102 vlan 12 +# map vni 101 vrf Vrfcheck1 +# map vni 102 vrf Vrfcheck2 +#! +# +- name: "Test vxlans deleted state 01" + dellemc.enterprise_sonic.sonic_vxlans: + config: + - name: vteptest1 + source_ip: 1.1.1.1 + vlan_map: + - vni: 101 + vlan: 11 + vrf_map: + - vni: 101 + vrf: Vrfcheck1 + state: deleted +# +# After state: +# ------------ +# +# do show running-configuration +# +#interface vxlan vteptest1 +# source-ip 1.1.1.1 +# map vni 102 vlan 12 +# map vni 102 vrf Vrfcheck2 +#! +# +# Using deleted +# +# Before state: +# ------------- +# +# do show running-configuration +# +#interface vxlan vteptest1 +# source-ip 1.1.1.1 +# map vni 102 vlan 12 +# map vni 102 vrf Vrfcheck2 +#! +# +- name: "Test vxlans deleted state 02" + dellemc.enterprise_sonic.sonic_vxlans: + config: + state: deleted +# +# After state: +# ------------ +# +# do show running-configuration +# +#! +# +# Using merged +# +# Before state: +# ------------- +# +# do show running-configuration +# +#! +# +- name: "Test vxlans merged state 01" + dellemc.enterprise_sonic.sonic_vxlans: + config: + - name: vteptest1 + source_ip: 1.1.1.1 + primary_ip: 2.2.2.2 + evpn_nvo_name: nvo1 + vlan_map: + - vni: 101 + vlan: 11 + - vni: 102 + vlan: 12 + vrf_map: + - vni: 101 + vrf: Vrfcheck1 + - vni: 102 + vrf: Vrfcheck2 + state: merged +# +# After state: +# ------------ +# +# do show running-configuration +# +#interface vxlan vteptest1 +# source-ip 1.1.1.1 +# primary-ip 2.2.2.2 +# map vni 101 vlan 11 +# map vni 102 vlan 12 +# map vni 101 vrf Vrfcheck1 +# map vni 102 vrf Vrfcheck2 +#! +# """ +RETURN = """ +before: + description: The configuration prior to the model invocation. + returned: always + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +after: + description: The resulting configuration model invocation. + returned: when changed + type: list + sample: > + The configuration returned is always in the same format + of the parameters above. +commands: + description: The set of commands that are pushed to the remote device. + returned: always + type: list + sample: ['command 1', 'command 2', 'command 3'] +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.vxlans.vxlans import VxlansArgs +from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.config.vxlans.vxlans import Vxlans + + +def main(): + """ + Main entry point for module execution + + :returns: the result form module invocation + """ + module = AnsibleModule(argument_spec=VxlansArgs.argument_spec, + supports_check_mode=True) + + result = Vxlans(module).execute_module() + module.exit_json(**result) + + +if __name__ == '__main__': + main() |