diff --git a/lib/ansible/modules/network/lenovo/cnos_bgp.py b/lib/ansible/modules/network/lenovo/cnos_bgp.py
new file mode 100644
index 0000000000..ee41ddbbed
--- /dev/null
+++ b/lib/ansible/modules/network/lenovo/cnos_bgp.py
@@ -0,0 +1,463 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2017 Lenovo, Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see .
+#
+# Module to send BGP commands to Lenovo Switches
+# Lenovo Networking
+#
+
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+DOCUMENTATION = '''
+---
+module: cnos_bgp
+short_description: Manage BGP resources and attributes on devices running Lenovo CNOS
+description:
+ - This module allows you to work with Border Gateway Protocol (BGP) related configurations.
+ The operators used are overloaded to ensure control over switch BGP configurations. This
+ module is invoked using method with asNumber as one of its arguments. The first level of
+ the BGP configuration allows to set up an AS number, with the following attributes going
+ into various configuration operations under the context of BGP. After passing this level,
+ there are eight BGP arguments that will perform further configurations. They are bgpArg1,
+ bgpArg2, bgpArg3, bgpArg4, bgpArg5, bgpArg6, bgpArg7, and bgpArg8. For more details on
+ how to use these arguments, see [Overloaded Variables].
+ This module uses SSH to manage network device configuration.
+ TThe results of the operation will be placed in a directory named 'results'
+ that must be created by the user in their local directory to where the playbook is run.
+ For more information about this module from Lenovo and customizing it usage for your
+ use cases, please visit our [User Guide](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_bgp.html)
+version_added: "2.3"
+extends_documentation_fragment: cnos
+options:
+ asNum:
+ description:
+ - AS number
+ required: Yes
+ default: Null
+ bgpArg1:
+ description:
+ - This is an overloaded bgp first argument. Usage of this argument can be found is the User Guide referenced above.
+ required: Yes
+ default: Null
+ choices: [address-family,bestpath,bgp,cluster-id,confederation,enforce-first-as,fast-external-failover,
+ graceful-restart,graceful-restart-helper,log-neighbor-changes,maxas-limit,neighbor,router-id,shutdown,
+ synchronization,timers,vrf]
+ bgpArg2:
+ description:
+ - This is an overloaded bgp second argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [ipv4 or ipv6, always-compare-med,compare-confed-aspath,compare-routerid,dont-compare-originator-id,tie-break-on-age,
+ as-path,med,identifier,peers]
+ bgpArg3:
+ description:
+ - This is an overloaded bgp third argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [aggregate-address,client-to-client,dampening,distance,maximum-paths,network,nexthop,redistribute,save,synchronization,
+ ignore or multipath-relax, confed or missing-as-worst or non-deterministic or remove-recv-med or remove-send-med]
+ bgpArg4:
+ description:
+ - This is an overloaded bgp fourth argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [Aggregate prefix, Reachability Half-life time,route-map, Distance for routes external,ebgp or ibgp,
+ IP prefix ,IP prefix /, synchronization, Delay value, direct, ospf, static, memory]
+ bgpArg5:
+ description:
+ - This is an overloaded bgp fifth argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [as-set, summary-only, Value to start reusing a route, Distance for routes internal, Supported multipath numbers,
+ backdoor, map, route-map ]
+ bgpArg6:
+ description:
+ - This is an overloaded bgp sixth argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [summary-only,as-set, route-map name, Value to start suppressing a route, Distance for local routes, Network mask,
+ Pointer to route-map entries]
+ bgpArg7:
+ description:
+ - This is an overloaded bgp seventh argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [ Maximum duration to suppress a stable route(minutes), backdoor,route-map, Name of the route map ]
+ bgpArg8:
+ description:
+ - This is an overloaded bgp eigth argument. Usage of this argument can be found is the User Guide referenced above.
+ required: No
+ default: Null
+ choices: [ Un-reachability Half-life time for the penalty(minutes), backdoor]
+'''
+EXAMPLES = '''
+Tasks: The following are examples of using the module cnos_bgp. These are written in the main.yml file of the tasks directory.
+---
+- name: Test BGP - neighbor
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "neighbor"
+ bgpArg2: "10.241.107.40"
+ bgpArg3: 13
+ bgpArg4: "address-family"
+ bgpArg5: "ipv4"
+ bgpArg6: "next-hop-self"
+
+- name: Test BGP - BFD
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "neighbor"
+ bgpArg2: "10.241.107.40"
+ bgpArg3: 13
+ bgpArg4: "bfd"
+
+- name: Test BGP - address-family - dampening
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "address-family"
+ bgpArg2: "ipv4"
+ bgpArg3: "dampening"
+ bgpArg4: 13
+ bgpArg5: 233
+ bgpArg6: 333
+ bgpArg7: 15
+ bgpArg8: 33
+
+- name: Test BGP - address-family - network
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "address-family"
+ bgpArg2: "ipv4"
+ bgpArg3: "network"
+ bgpArg4: "1.2.3.4/5"
+ bgpArg5: "backdoor"
+
+- name: Test BGP - bestpath - always-compare-med
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "bestpath"
+ bgpArg2: "always-compare-med"
+
+- name: Test BGP - bestpath-compare-confed-aspat
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "bestpath"
+ bgpArg2: "compare-confed-aspath"
+
+- name: Test BGP - bgp
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "bgp"
+ bgpArg2: 33
+
+- name: Test BGP - cluster-id
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "cluster-id"
+ bgpArg2: "1.2.3.4"
+
+- name: Test BGP - confederation-identifier
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "confederation"
+ bgpArg2: "identifier"
+ bgpArg3: 333
+
+- name: Test BGP - enforce-first-as
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "enforce-first-as"
+
+- name: Test BGP - fast-external-failover
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "fast-external-failover"
+
+- name: Test BGP - graceful-restart
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "graceful-restart"
+ bgpArg2: 333
+
+- name: Test BGP - graceful-restart-helper
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "graceful-restart-helper"
+
+- name: Test BGP - maxas-limit
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "maxas-limit"
+ bgpArg2: 333
+
+- name: Test BGP - neighbor
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "neighbor"
+ bgpArg2: "10.241.107.40"
+ bgpArg3: 13
+ bgpArg4: "address-family"
+ bgpArg5: "ipv4"
+ bgpArg6: "next-hop-self"
+
+- name: Test BGP - router-id
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "router-id"
+ bgpArg2: "1.2.3.4"
+
+- name: Test BGP - synchronization
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "synchronization"
+
+- name: Test BGP - timers
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "timers"
+ bgpArg2: 333
+ bgpArg3: 3333
+
+- name: Test BGP - vrf
+ cnos_bgp:
+ host: "{{ inventory_hostname }}"
+ username: "{{ hostvars[inventory_hostname]['username'] }}"
+ password: "{{ hostvars[inventory_hostname]['password'] }}"
+ deviceType: "{{ hostvars[inventory_hostname]['deviceType'] }}"
+ enablePassword: "{{ hostvars[inventory_hostname]['enablePassword'] }}"
+ outputfile: "./results/test_bgp_{{ inventory_hostname }}_output.txt"
+ asNum: 33
+ bgpArg1: "vrf"
+
+'''
+RETURN = '''
+ return value: |
+ On successful execution, the method returns an empty string with the following message in JSON format.
+ [BGP configurations accomplished]
+ Upon any failure, the method returns an error display string. The error must be corrected before attempting the method again.
+'''
+
+import sys
+import paramiko
+import time
+import argparse
+import socket
+import array
+import json
+import time
+import re
+try:
+ from ansible.module_utils import cnos
+ HAS_LIB = True
+except:
+ HAS_LIB = False
+from ansible.module_utils.basic import AnsibleModule
+from collections import defaultdict
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(
+ outputfile=dict(required=True),
+ host=dict(required=True),
+ username=dict(required=True),
+ password=dict(required=True, no_log=True),
+ enablePassword=dict(required=False, no_log=True),
+ deviceType=dict(required=True),
+ bgpArg1=dict(required=True),
+ bgpArg2=dict(required=False),
+ bgpArg3=dict(required=False),
+ bgpArg4=dict(required=False),
+ bgpArg5=dict(required=False),
+ bgpArg6=dict(required=False),
+ bgpArg7=dict(required=False),
+ bgpArg8=dict(required=False),
+ asNum=dict(required=True),),
+ supports_check_mode=False)
+
+ username = module.params['username']
+ password = module.params['password']
+ enablePassword = module.params['enablePassword']
+ bgpArg1 = module.params['bgpArg1']
+ bgpArg2 = module.params['bgpArg2']
+ bgpArg3 = module.params['bgpArg3']
+ bgpArg4 = module.params['bgpArg4']
+ bgpArg5 = module.params['bgpArg5']
+ bgpArg6 = module.params['bgpArg6']
+ bgpArg7 = module.params['bgpArg7']
+ bgpArg8 = module.params['bgpArg8']
+ asNum = module.params['asNum']
+ outputfile = module.params['outputfile']
+ hostIP = module.params['host']
+ deviceType = module.params['deviceType']
+ output = ""
+
+ # Create instance of SSHClient object
+ remote_conn_pre = paramiko.SSHClient()
+
+ # Automatically add untrusted hosts (make sure okay for security policy in your environment)
+ remote_conn_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+
+ # initiate SSH connection with the switch
+ remote_conn_pre.connect(hostIP, username=username, password=password)
+ time.sleep(2)
+
+ # Use invoke_shell to establish an 'interactive session'
+ remote_conn = remote_conn_pre.invoke_shell()
+ time.sleep(2)
+
+ # Enable and enter configure terminal then send command
+ output = output + cnos.waitForDeviceResponse("\n", ">", 2, remote_conn)
+
+ output = output + cnos.enterEnableModeForDevice(enablePassword, 3, remote_conn)
+
+ # Make terminal length = 0
+ output = output + cnos.waitForDeviceResponse("terminal length 0\n", "#", 2, remote_conn)
+
+ # Go to config mode
+ output = output + cnos.waitForDeviceResponse("configure d\n", "(config)#", 2, remote_conn)
+
+ # Send the CLi command
+ output = output + cnos.routerConfig(remote_conn, deviceType, "(config)#", 2, "bgp", asNum,
+ bgpArg1, bgpArg2, bgpArg3, bgpArg4, bgpArg5, bgpArg6, bgpArg7, bgpArg8)
+
+ # Save it into the file
+ file = open(outputfile, "a")
+ file.write(output)
+ file.close()
+
+ # Logic to check when changes occur or not
+ errorMsg = cnos.checkOutputForError(output)
+ if(errorMsg is None):
+ module.exit_json(changed=True, msg="BGP configurations accomplished")
+ else:
+ module.fail_json(msg=errorMsg)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/roles/cnos_bgp/README.md b/test/integration/roles/cnos_bgp/README.md
new file mode 100644
index 0000000000..74d3d1a895
--- /dev/null
+++ b/test/integration/roles/cnos_bgp/README.md
@@ -0,0 +1,118 @@
+# Ansible Role: cnos_bgp_sample - CNOS Switch BGP Configuration
+---
+
+
+This role is an example of using the *cnos_bgp.py* Lenovo module in the context of CNOS switch configuration. This module allows you to work with Border Gateway Protocol (BGP) related configurations. The operators used are overloaded to ensure control over switch BGP configurations. This module is invoked using method with *asNumber* as one of its arguments.
+
+The first level of the BGP configuration allows to set up an AS number, with the following attributes going into various configuration operations under the context of BGP. After passing this level, there are eight BGP arguments that will perform further configurations. They are *bgpArg1*, *bgpArg2*, *bgpArg3*, *bgpArg4*, *bgpArg5*, *bgpArg6*, *bgpArg7*, and *bgpArg8*.
+
+The results of the operation can be viewed in *results* directory.
+
+For more details, see [Lenovo modules for Ansible: cnos_bgp](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_bgp.html&cp=0_3_1_0_4_16).
+
+
+## Requirements
+---
+
+
+- Ansible version 2.2 or later ([Ansible installation documentation](http://docs.ansible.com/ansible/intro_installation.html))
+- Lenovo switches running CNOS version 10.2.1.0 or later
+- an SSH connection to the Lenovo switch (SSH must be enabled on the network device)
+
+
+## Role Variables
+---
+
+
+Available variables are listed below, along with description.
+
+The following are mandatory inventory variables:
+
+Variable | Description
+--- | ---
+`username` | Specifies the username used to log into the switch
+`password` | Specifies the password used to log into the switch
+`enablePassword` | Configures the password used to enter Global Configuration command mode on the switch (this is an optional parameter)
+`hostname` | Searches the hosts file at */etc/ansible/hosts* and identifies the IP address of the switch on which the role is going to be applied
+`deviceType` | Specifies the type of device from where the configuration will be backed up (**g8272_cnos** - G8272, **g8296_cnos** - G8296)
+
+The values of the variables used need to be modified to fit the specific scenario in which you are deploying the solution. To change the values of the variables, you need to visits the *vars* directory of each role and edit the *main.yml* file located there. The values stored in this file will be used by Ansible when the template is executed.
+
+The syntax of *main.yml* file for variables is the following:
+
+```
+:
+```
+
+You will need to replace the `` field with the value that suits your topology. The `` fields are taken from the template and it is recommended that you leave them unchanged.
+
+Variable | Description
+--- | ---
+`asNum` | Specifies the AS number
+`bgpArg1` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **address-family**, **bestpath**, **bgp**, **cluster-id**, **confederation**, **enforce-first-as**, **fast-external-failover**, **graceful-restart**, **graceful-restart-helper**, **log-neighbor-changes**, **maxas-limit**, **neighbor**, **router-id**, **shutdown**, **synchronization**, **timers**, **vrf**.
+`bgpArg2` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **ipv4**, **ipv6**, **always-compare-med**, **compare-confed-aspath**, **compare-routerid**, **dont-compare-originator-id**, **tie-break-on-age**, **as-path**, **med**, number of times to prepend the local AS, Route Reflector Cluster ID as a 32 bit quantity or in IP address format, **identifier**, **peers**, delay value, number of autonomous systems in the AS-path attribute, neighbor address, neighbor prefix, manually configured router identifier, keepalive interval.
+`bgpArg3` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **aggregate-address**, **client-to-client**, **dampening**, **distance**, **maximum-paths**, **network**, **nexthop**, **redistribute**, **save**, **synchronization**, **ignore**, **multipath-relax**, **confed**, **missing-as-worst**, **non-deterministic**, **remove-recv-med**, **remove-send-med**, set routing domain confederation AS, AS number.
+`bgpArg4` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: IP address/prefix length, **route-map**, time after which a penalty is decreased by half, administrative distance to routes outside the AS, **ebgp**, **ibgp**, **synchronization**, IP address, delay value, **direct**, **ospf**, **static**, **memory**.
+`bgpArg5` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **as-set**, **summary-only**, name of the route map that controls where BGP route dampening is enabled, value to start reusing a route, administrative distance to routes inside the AS, value for maximum path numbers, **backdoor**, **mask**, **route-map**.
+`bgpArg6` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: **summary-only**, **as-set**, value to start suppressing a route, administrative distance for local routes, IP subnet address mask, name of the route map.
+`bgpArg7` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: maximum duration to suppress a stable route, **route-map**, **backdoor**.
+`bgpArg8` | This is an overloaded BGP variable. Please refer to the [cnos_bgp module documentation](http://ralfss28.labs.lenovo.com:5555/help/topic/com.lenovo.switchmgt.ansible.doc/cnos_bgp.html?cp=0_3_1_0_2_13) for detailed information on usage. The values of these variables depend on the configuration context and the choices are the following: time after which an unreachable route’s penalty is decreased by half, **backdoor**.
+
+
+## Dependencies
+---
+
+
+- username.iptables - Configures the firewall and blocks all ports except those needed for web server and SSH access.
+- username.common - Performs common server configuration.
+- cnos_bgp.py - This modules needs to be present in the *library* directory of the role.
+- cnos.py - This module needs to be present in the PYTHONPATH environment variable set in the Ansible system.
+- /etc/ansible/hosts - You must edit the */etc/ansible/hosts* file with the device information of the switches designated as leaf switches. You may refer to *cnos_bgp_sample_hosts* for a sample configuration.
+
+Ansible keeps track of all network elements that it manages through a hosts file. Before the execution of a playbook, the hosts file must be set up.
+
+Open the */etc/ansible/hosts* file with root privileges. Most of the file is commented out by using **#**. You can also comment out the entries you will be adding by using **#**. You need to copy the content of the hosts file for the role into the */etc/ansible/hosts* file. The sample hosts file for the role is located in the main directory.
+
+```
+[cnos_bgp_sample]
+10.241.107.39 username= password= deviceType=g8272_cnos
+10.241.107.40 username= password= deviceType=g8272_cnos
+```
+
+**Note:** You need to change the IP addresses to fit your specific topology. You also need to change the `` and `` to the appropriate values used to log into the specific Lenovo network devices.
+
+
+## Example Playbook
+---
+
+
+To execute an Ansible playbook, use the following command:
+
+```
+ansible-playbook cnos_bgp_sample.yml -vvv
+```
+
+`-vvv` is an optional verbos command that helps identify what is happening during playbook execution. The playbook for each role is located in the main directory of the solution.
+
+```
+- name: Module to do BGP configuration
+ hosts: cnos_bgp_sample
+ gather_facts: no
+ connection: local
+ roles:
+ - cnos_bgp_sample
+```
+
+
+## License
+---
+
+Copyright (C) 2017 Lenovo, Inc.
+
+This file is part of Ansible
+
+Ansible is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+
+Ansible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with Ansible. If not, see .
\ No newline at end of file
diff --git a/test/integration/roles/cnos_bgp/cnos_bgp_sample_hosts b/test/integration/roles/cnos_bgp/cnos_bgp_sample_hosts
new file mode 100644
index 0000000000..0c27e2b1c6
--- /dev/null
+++ b/test/integration/roles/cnos_bgp/cnos_bgp_sample_hosts
@@ -0,0 +1,15 @@
+# You have to paste this dummy information in /etc/ansible/hosts
+# Notes:
+# - Comments begin with the '#' character
+# - Blank lines are ignored
+# - Groups of hosts are delimited by [header] elements
+# - You can enter hostnames or ip addresses
+# - A hostname/ip can be a member of multiple groups
+#
+# In the /etc/ansible/hosts file u have to enter [cnos_bgp_sample] tag
+# Following you should specify IP Adresses details
+# Please change and with appropriate value for your switch.
+
+[cnos_bgp_sample]
+10.241.107.39 username= password= deviceType=g8272_cnos
+
diff --git a/test/integration/roles/cnos_bgp/tasks/main.yml b/test/integration/roles/cnos_bgp/tasks/main.yml
new file mode 100644
index 0000000000..6a23d372de
--- /dev/null
+++ b/test/integration/roles/cnos_bgp/tasks/main.yml
@@ -0,0 +1,78 @@
+## This contain sample BGP execution tasks
+---
+- name: Test BGP - neighbor
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}' bgpArg4='{{item.bgpArg4}}' bgpArg5='{{item.bgpArg5}}' bgpArg6='{{item.bgpArg6}}'
+ with_items: "{{test_bgp_data13}}"
+
+- name: Test BGP - BFD
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}' bgpArg4='{{item.bgpArg4}}'
+ with_items: "{{test_bgp_data19}}"
+
+- name: Test BGP - address-family - dampening
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}' bgpArg4='{{item.bgpArg4}}' bgpArg5='{{item.bgpArg5}}' bgpArg6='{{item.bgpArg6}}' bgpArg7='{{item.bgpArg7}}' bgpArg8='{{item.bgpArg8}}'
+ with_items: "{{test_bgp_data1}}"
+
+- name: Test BGP - address-family - network
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}' bgpArg4='{{item.bgpArg4}}' bgpArg5='{{item.bgpArg5}}'
+ with_items: "{{test_bgp_data18}}"
+
+- name: Test BGP - bestpath - always-compare-med
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data2}}"
+
+- name: Test BGP - bestpath-compare-confed-aspat
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data3}}"
+
+- name: Test BGP - bgp
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data4}}"
+
+- name: Test BGP - cluster-id
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data5}}"
+
+- name: Test BGP - confederation-identifier
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}'
+ with_items: "{{test_bgp_data6}}"
+
+- name: Test BGP - enforce-first-as
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}'
+ with_items: "{{test_bgp_data7}}"
+
+- name: Test BGP - fast-external-failover
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}'
+ with_items: "{{test_bgp_data8}}"
+
+- name: Test BGP - graceful-restart
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data9}}"
+
+- name: Test BGP - graceful-restart-helper
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}'
+ with_items: "{{test_bgp_data10}}"
+
+- name: Test BGP - maxas-limit
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data11}}"
+
+#- name: Test BGP - neighbor
+# cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}'
+# with_items: "{{test_bgp_data13}}"
+
+- name: Test BGP - router-id
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}'
+ with_items: "{{test_bgp_data14}}"
+
+- name: Test BGP - synchronization
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}'
+ with_items: "{{test_bgp_data15}}"
+
+- name: Test BGP - timers
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}' bgpArg2='{{item.bgpArg2}}' bgpArg3='{{item.bgpArg3}}'
+ with_items: "{{test_bgp_data16}}"
+
+- name: Test BGP - vrf
+ cnos_bgp: host={{ inventory_hostname }} username={{ hostvars[inventory_hostname]['username']}} password={{ hostvars[inventory_hostname]['password']}} deviceType={{ hostvars[inventory_hostname]['deviceType']}} outputfile=./results/cnos_bgp_{{ inventory_hostname }}_output.txt asNum='{{item.asNum}}' bgpArg1='{{item.bgpArg1}}'
+ with_items: "{{test_bgp_data17}}"
+# Completed file
diff --git a/test/integration/roles/cnos_bgp/vars/main.yml b/test/integration/roles/cnos_bgp/vars/main.yml
new file mode 100644
index 0000000000..ba08d9c0ff
--- /dev/null
+++ b/test/integration/roles/cnos_bgp/vars/main.yml
@@ -0,0 +1,37 @@
+---
+test_bgp_data1:
+ - {asNum: 33, bgpArg1: "address-family", bgpArg2: "ipv4", bgpArg3: "dampening", bgpArg4: 13, bgpArg5: 233, bgpArg6: 333, bgpArg7: 15, bgpArg8: 33 }
+test_bgp_data2:
+ - {asNum: 33, bgpArg1: "bestpath", bgpArg2: "always-compare-med"}
+test_bgp_data3:
+ - {asNum: 33, bgpArg1: "bestpath", bgpArg2: "compare-confed-aspath"}
+test_bgp_data4:
+ - {asNum: 33, bgpArg1: "bgp", bgpArg2: 33}
+test_bgp_data5:
+ - {asNum: 33, bgpArg1: "cluster-id", bgpArg2: "1.2.3.4"}
+test_bgp_data6:
+ - {asNum: 33, bgpArg1: "confederation", bgpArg2: "identifier", bgpArg3: 333}
+test_bgp_data7:
+ - {asNum: 33, bgpArg1: "enforce-first-as"}
+test_bgp_data8:
+ - {asNum: 33, bgpArg1: "fast-external-failover"}
+test_bgp_data9:
+ - {asNum: 33, bgpArg1: "graceful-restart", bgpArg2: 333}
+test_bgp_data10:
+ - {asNum: 33, bgpArg1: "graceful-restart-helper"}
+test_bgp_data11:
+ - {asNum: 33, bgpArg1: "maxas-limit", bgpArg2: 333}
+test_bgp_data13:
+ - {asNum: 33, bgpArg1: "neighbor", bgpArg2: "10.241.107.40", bgpArg3: 13, bgpArg4: "address-family", bgpArg5: "ipv4", bgpArg6: "next-hop-self" }
+test_bgp_data14:
+ - {asNum: 33, bgpArg1: "router-id", bgpArg2: "1.2.3.4"}
+test_bgp_data15:
+ - {asNum: 33, bgpArg1: "synchronization"}
+test_bgp_data16:
+ - {asNum: 33, bgpArg1: "timers", bgpArg2: 333, bgpArg3: 3333}
+test_bgp_data17:
+ - {asNum: 33, bgpArg1: "vrf"}
+test_bgp_data18:
+ - {asNum: 33, bgpArg1: "address-family", bgpArg2: "ipv4", bgpArg3: "network", bgpArg4: "1.2.3.4/5", bgpArg5: "backdoor"}
+test_bgp_data19:
+ - {asNum: 33, bgpArg1: "neighbor", bgpArg2: "10.241.107.40", bgpArg3: 13, bgpArg4: "bfd"}