summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/ios
diff options
context:
space:
mode:
authorSumit Jaiswal <sjaiswal@redhat.com>2019-08-19 20:41:00 +0530
committerGitHub <noreply@github.com>2019-08-19 20:41:00 +0530
commit04ef376ab2359a301e9b6ba6cffb149093fd2e6a (patch)
tree546899944108a05bd5915e45b68d07d361a16210 /lib/ansible/modules/network/ios
parent31bfcd4745fdceeb0c29f77f43726abfed044cab (diff)
downloadansible-04ef376ab2359a301e9b6ba6cffb149093fd2e6a.tar.gz
Resource module for ios_lag_interfaces (#60672)
Signed-off-by: Sumit Jaiswal <sjaiswal@redhat.com>
Diffstat (limited to 'lib/ansible/modules/network/ios')
-rw-r--r--lib/ansible/modules/network/ios/ios_facts.py3
-rw-r--r--lib/ansible/modules/network/ios/ios_lag_interfaces.py384
2 files changed, 386 insertions, 1 deletions
diff --git a/lib/ansible/modules/network/ios/ios_facts.py b/lib/ansible/modules/network/ios/ios_facts.py
index bc75d1886f..18de677090 100644
--- a/lib/ansible/modules/network/ios/ios_facts.py
+++ b/lib/ansible/modules/network/ios/ios_facts.py
@@ -54,7 +54,8 @@ options:
to a given subset. Possible values for this argument include
all and the resources like interfaces, vlans etc.
Can specify a list of values to include a larger subset.
- choices: ['all', '!all', 'interfaces', '!interfaces', 'l2_interfaces', '!l2_interfaces', 'vlans', '!vlans']
+ choices: ['all', '!all', 'interfaces', '!interfaces', 'l2_interfaces', '!l2_interfaces', 'vlans', '!vlans',
+ 'lag_interfaces', '!lag_interfaces']
version_added: "2.9"
"""
diff --git a/lib/ansible/modules/network/ios/ios_lag_interfaces.py b/lib/ansible/modules/network/ios/ios_lag_interfaces.py
new file mode 100644
index 0000000000..d24d02e758
--- /dev/null
+++ b/lib/ansible/modules/network/ios/ios_lag_interfaces.py
@@ -0,0 +1,384 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Copyright 2019 Red Hat Inc.
+# 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 ios_l3_interfaces
+"""
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+
+ANSIBLE_METADATA = {'metadata_version': '1.1',
+ 'status': ['preview'],
+ 'supported_by': 'network'}
+
+
+DOCUMENTATION = """
+---
+module: ios_lag_interfaces
+version_added: 2.9
+short_description: Manage Link Aggregation on Cisco IOS devices.
+description: This module manages properties of Link Aggregation Group on Cisco IOS devices.
+author: Sumit Jaiswal (@justjais)
+notes:
+ - Tested against Cisco IOSv Version 15.2 on VIRL
+ - This module works with connection C(network_cli).
+ See L(IOS Platform Options,../network/user_guide/platform_ios.html).
+options:
+ config:
+ description: A list of link aggregation group configurations.
+ type: list
+ elements: dict
+ suboptions:
+ name:
+ description:
+ - ID of Ethernet Channel of interfaces.
+ - Refer to vendor documentation for valid port values.
+ type: str
+ required: True
+ members:
+ description:
+ - Interface options for the link aggregation group.
+ type: list
+ suboptions:
+ member:
+ description:
+ - Interface member of the link aggregation group.
+ type: str
+ mode:
+ description:
+ - Etherchannel Mode of the interface for link aggregation.
+ type: str
+ choices:
+ - 'auto'
+ - 'on'
+ - 'desirable'
+ - 'active'
+ - 'passive'
+ link:
+ description:
+ - Assign a link identifier used for load-balancing.
+ - Refer to vendor documentation for valid values.
+ - NOTE, parameter only supported on Cisco IOS XE platform.
+ type: int
+ state:
+ description:
+ - The state the configuration should be left in
+ type: str
+ choices:
+ - merged
+ - replaced
+ - overridden
+ - deleted
+ default: merged
+"""
+
+EXAMPLES = """
+---
+# Using merged
+#
+# Before state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface GigabitEthernet0/1
+# shutdown
+# interface GigabitEthernet0/2
+# shutdown
+# interface GigabitEthernet0/3
+# shutdown
+# interface GigabitEthernet0/4
+# shutdown
+
+- name: Merge provided configuration with device configuration
+ ios_lag_interfaces:
+ config:
+ - name: 10
+ members:
+ - member: GigabitEthernet0/1
+ mode: auto
+ - member: GigabitEthernet0/2
+ mode: auto
+ - name: 20
+ members:
+ - member: GigabitEthernet0/3
+ mode: on
+ - name: 30
+ members:
+ - member: GigabitEthernet0/4
+ mode: active
+ state: merged
+
+# After state:
+# ------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 20 mode on
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+# Using overridden
+#
+# Before state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 20 mode on
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+- name: Override device configuration of all interfaces with provided configuration
+ ios_lag_interfaces:
+ config:
+ - name: 20
+ members:
+ - member: GigabitEthernet0/2
+ mode: auto
+ - member: GigabitEthernet0/3
+ mode: auto
+ state: overridden
+
+# After state:
+# ------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 20 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 20 mode auto
+# interface GigabitEthernet0/4
+# shutdown
+
+# Using replaced
+#
+# Before state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 20 mode on
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+- name: Replaces device configuration of listed interfaces with provided configuration
+ ios_lag_interfaces:
+ config:
+ - name: 40
+ members:
+ - member: GigabitEthernet0/3
+ mode: auto
+ state: replaced
+
+# After state:
+# ------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface Port-channel40
+# interface GigabitEthernet0/1
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 40 mode on
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+# Using Deleted
+#
+# Before state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 20 mode on
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+- name: "Delete LAG attributes of given interfaces (Note: This won't delete the interface itself)"
+ ios_lag_interfaces:
+ config:
+ - name: 10
+ - name: 20
+ state: deleted
+
+# After state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# interface GigabitEthernet0/2
+# shutdown
+# interface GigabitEthernet0/3
+# shutdown
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+# Using Deleted without any config passed
+#"(NOTE: This will delete all of configured LLDP module attributes)"
+
+#
+# Before state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/2
+# shutdown
+# channel-group 10 mode auto
+# interface GigabitEthernet0/3
+# shutdown
+# channel-group 20 mode on
+# interface GigabitEthernet0/4
+# shutdown
+# channel-group 30 mode active
+
+- name: "Delete all configured LAG attributes for interfaces (Note: This won't delete the interface itself)"
+ ios_lag_interfaces:
+ state: deleted
+
+# After state:
+# -------------
+#
+# vios#show running-config | section ^interface
+# interface Port-channel10
+# interface Port-channel20
+# interface Port-channel30
+# interface GigabitEthernet0/1
+# shutdown
+# interface GigabitEthernet0/2
+# shutdown
+# interface GigabitEthernet0/3
+# shutdown
+# interface GigabitEthernet0/4
+# shutdown
+"""
+
+RETURN = """
+before:
+ description: The configuration prior to the model invocation
+ returned: always
+ type: list
+ sample: The configuration returned will alwys be in the same format of the paramters above.
+after:
+ description: The resulting configuration model invocation
+ returned: when changed
+ type: list
+ sample: The configuration returned will alwys be in the same format of the paramters above.
+commands:
+ description: The set of commands pushed to the remote device
+ returned: always
+ type: list
+ sample: ['interface GigabitEthernet0/1', 'channel-group 1 mode active']
+"""
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.network.ios.argspec.lag_interfaces.lag_interfaces import Lag_interfacesArgs
+from ansible.module_utils.network.ios.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()