Remove default description in network DI modules (#28411)

This commit is contained in:
Ganesh Nalawade 2017-08-19 00:09:01 +05:30 committed by GitHub
parent a572de626c
commit c4b9dfe542
14 changed files with 140 additions and 280 deletions

View file

@ -143,8 +143,6 @@ from ansible.module_utils.ios import ios_argument_spec, check_args
from ansible.module_utils.netcfg import NetworkConfig from ansible.module_utils.netcfg import NetworkConfig
from ansible.module_utils.network_common import conditional, remove_default_spec from ansible.module_utils.network_common import conditional, remove_default_spec
DEFAULT_DESCRIPTION = "configured by ios_interface"
def validate_mtu(value, module): def validate_mtu(value, module):
if value and not 64 <= int(value) <= 9600: if value and not 64 <= int(value) <= 9600:
@ -284,13 +282,6 @@ def map_obj_to_commands(updates):
if candidate: if candidate:
cmd = item + ' ' + str(candidate) cmd = item + ' ' + str(candidate)
add_command_to_interface(interface, cmd, commands) add_command_to_interface(interface, cmd, commands)
elif running:
# if value present in device is default value for
# interface, don't delete
if running == 'auto' and item in ('speed', 'duplex'):
continue
cmd = 'no ' + item + ' ' + str(running)
add_command_to_interface(interface, cmd, commands)
if disable and not obj_in_have.get('disable', False): if disable and not obj_in_have.get('disable', False):
add_command_to_interface(interface, 'shutdown', commands) add_command_to_interface(interface, 'shutdown', commands)
@ -360,7 +351,7 @@ def main():
""" """
element_spec = dict( element_spec = dict(
name=dict(), name=dict(),
description=dict(default=DEFAULT_DESCRIPTION), description=dict(),
speed=dict(), speed=dict(),
mtu=dict(), mtu=dict(),
duplex=dict(choices=['full', 'half', 'auto']), duplex=dict(choices=['full', 'half', 'auto']),

View file

@ -93,6 +93,9 @@ EXAMPLES = """
aggregate: aggregate:
- name: GigabitEthernet0/0/0/3 - name: GigabitEthernet0/0/0/3
- name: GigabitEthernet0/0/0/2 - name: GigabitEthernet0/0/0/2
speed: 100
duplex: full
mtu: 512
state: present state: present
- name: Delete interface using aggregate - name: Delete interface using aggregate
@ -139,8 +142,6 @@ from ansible.module_utils.iosxr import get_config, load_config
from ansible.module_utils.iosxr import iosxr_argument_spec, check_args from ansible.module_utils.iosxr import iosxr_argument_spec, check_args
from ansible.module_utils.network_common import conditional, remove_default_spec from ansible.module_utils.network_common import conditional, remove_default_spec
DEFAULT_DESCRIPTION = "configured by iosxr_interface"
def validate_mtu(value, module): def validate_mtu(value, module):
if value and not 64 <= int(value) <= 65535: if value and not 64 <= int(value) <= 65535:
@ -182,7 +183,6 @@ def search_obj_in_list(name, lst):
def map_params_to_obj(module): def map_params_to_obj(module):
obj = [] obj = []
args = ['name', 'description', 'speed', 'duplex', 'mtu']
aggregate = module.params.get('aggregate') aggregate = module.params.get('aggregate')
if aggregate: if aggregate:
@ -202,7 +202,7 @@ def map_params_to_obj(module):
obj.append(d) obj.append(d)
else: else:
validate_param_values(module, args) validate_param_values(module, module.params)
params = { params = {
'name': module.params['name'], 'name': module.params['name'],
'description': module.params['description'], 'description': module.params['description'],
@ -279,9 +279,6 @@ def map_obj_to_commands(updates):
if candidate: if candidate:
cmd = interface + ' ' + item + ' ' + str(candidate) cmd = interface + ' ' + item + ' ' + str(candidate)
commands.append(cmd) commands.append(cmd)
elif running:
cmd = 'no ' + interface + ' ' + item + ' ' + str(running)
commands.append(cmd)
if disable and not obj_in_have.get('disable', False): if disable and not obj_in_have.get('disable', False):
commands.append(interface + ' shutdown') commands.append(interface + ' shutdown')
@ -292,7 +289,6 @@ def map_obj_to_commands(updates):
value = w.get(item) value = w.get(item)
if value: if value:
commands.append(interface + ' ' + item + ' ' + str(value)) commands.append(interface + ' ' + item + ' ' + str(value))
if disable: if disable:
commands.append('no ' + interface + ' shutdown') commands.append('no ' + interface + ' shutdown')
return commands return commands
@ -354,7 +350,7 @@ def main():
""" """
element_spec = dict( element_spec = dict(
name=dict(), name=dict(),
description=dict(default=DEFAULT_DESCRIPTION), description=dict(),
speed=dict(), speed=dict(),
mtu=dict(), mtu=dict(),
duplex=dict(choices=['full', 'half']), duplex=dict(choices=['full', 'half']),

View file

@ -170,7 +170,6 @@ except ImportError:
from xml.etree.ElementTree import tostring from xml.etree.ElementTree import tostring
USE_PERSISTENT_CONNECTION = True USE_PERSISTENT_CONNECTION = True
DEFAULT_COMMENT = 'configured by junos_linkagg'
def validate_device_count(value, module): def validate_device_count(value, module):
@ -263,7 +262,7 @@ def main():
members=dict(type='list'), members=dict(type='list'),
min_links=dict(type='int'), min_links=dict(type='int'),
device_count=dict(type='int'), device_count=dict(type='int'),
description=dict(default=DEFAULT_COMMENT), description=dict(),
state=dict(default='present', choices=['present', 'absent', 'up', 'down']), state=dict(default='present', choices=['present', 'absent', 'up', 'down']),
active=dict(default=True, type='bool') active=dict(default=True, type='bool')
) )

View file

@ -121,7 +121,6 @@ except ImportError:
from xml.etree.ElementTree import tostring from xml.etree.ElementTree import tostring
USE_PERSISTENT_CONNECTION = True USE_PERSISTENT_CONNECTION = True
DEFAULT_DESCRIPTION = "configured by junos_vlan"
def validate_vlan_id(value, module): def validate_vlan_id(value, module):
@ -145,7 +144,7 @@ def main():
element_spec = dict( element_spec = dict(
name=dict(), name=dict(),
vlan_id=dict(type='int'), vlan_id=dict(type='int'),
description=dict(default=DEFAULT_DESCRIPTION), description=dict(),
interfaces=dict(), interfaces=dict(),
state=dict(default='present', choices=['present', 'absent']), state=dict(default='present', choices=['present', 'absent']),
active=dict(default=True, type='bool') active=dict(default=True, type='bool')

View file

@ -138,8 +138,6 @@ from ansible.module_utils.network_common import conditional, remove_default_spec
from ansible.module_utils.vyos import load_config, get_config from ansible.module_utils.vyos import load_config, get_config
from ansible.module_utils.vyos import vyos_argument_spec, check_args from ansible.module_utils.vyos import vyos_argument_spec, check_args
DEFAULT_DESCRIPTION = "'configured by vyos_interface'"
def search_obj_in_list(name, lst): def search_obj_in_list(name, lst):
for o in lst: for o in lst:
@ -302,7 +300,7 @@ def main():
""" """
element_spec = dict( element_spec = dict(
name=dict(), name=dict(),
description=dict(default=DEFAULT_DESCRIPTION), description=dict(),
speed=dict(), speed=dict(),
mtu=dict(type='int'), mtu=dict(type='int'),
duplex=dict(choices=['full', 'half', 'auto']), duplex=dict(choices=['full', 'half', 'auto']),

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START ios_interface netconf/basic.yaml" - debug: msg="START ios_interface cli/basic.yaml"
- name: Configure interface (setup) - name: Configure interface (setup)
ios_interface: ios_interface:
@ -46,7 +46,6 @@
name: GigabitEthernet0/2 name: GigabitEthernet0/2
description: test-interface description: test-interface
speed: 100 speed: 100
duplex: half
mtu: 512 mtu: 512
state: present state: present
authorize: yes authorize: yes
@ -59,7 +58,6 @@
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"description test-interface" in result.commands' - '"description test-interface" in result.commands'
- '"speed 100" in result.commands' - '"speed 100" in result.commands'
- '"duplex half" in result.commands'
- '"mtu 512" in result.commands' - '"mtu 512" in result.commands'
- name: Change interface parameters - name: Change interface parameters
@ -67,7 +65,7 @@
name: GigabitEthernet0/2 name: GigabitEthernet0/2
description: test-interface-1 description: test-interface-1
speed: 10 speed: 10
duplex: full duplex: half
mtu: 256 mtu: 256
state: present state: present
authorize: yes authorize: yes
@ -80,38 +78,9 @@
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"description test-interface-1" in result.commands' - '"description test-interface-1" in result.commands'
- '"speed 10" in result.commands' - '"speed 10" in result.commands'
- '"duplex full" in result.commands' - '"duplex half" in result.commands'
- '"mtu 256" in result.commands' - '"mtu 256" in result.commands'
- name: Delete interface parameters
ios_interface:
name: GigabitEthernet0/2
state: present
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface GigabitEthernet0/2" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"no speed 10" in result.commands'
- '"no duplex full" in result.commands'
- '"no mtu 256" in result.commands'
- name: Delete interface parameters (idempotent)
ios_interface:
name: GigabitEthernet0/2
state: present
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == false'
- name: Disable interface - name: Disable interface
ios_interface: ios_interface:
name: GigabitEthernet0/2 name: GigabitEthernet0/2
@ -145,7 +114,7 @@
name: GigabitEthernet0/1 name: GigabitEthernet0/1
description: test-interface-initial description: test-interface-initial
speed: 100 speed: 100
duplex: full duplex: half
mtu: 516 mtu: 516
state: present state: present
authorize: yes authorize: yes
@ -194,31 +163,6 @@
that: that:
- 'result.changed == false' - 'result.changed == false'
- name: Change interface parameters in aggregate
ios_interface:
aggregate:
- { name: GigabitEthernet0/1 }
- { name: GigabitEthernet0/2 }
state: present
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface GigabitEthernet0/1" in result.commands'
- '"no speed 100" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"no duplex full" in result.commands'
- '"no mtu 256" in result.commands'
- '"interface GigabitEthernet0/2" in result.commands'
- '"no speed 100" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"no duplex full" in result.commands'
- '"no mtu 516" in result.commands'
- name: Disable interface aggregate - name: Disable interface aggregate
ios_interface: ios_interface:
aggregate: aggregate:
@ -257,6 +201,14 @@
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"no shutdown" in result.commands' - '"no shutdown" in result.commands'
- name: loopback interface setup
ios_interface:
aggregate:
- name: Loopback9
- name: Loopback10
state: absent
authorize: yes
- name: Create loopback interface aggregate - name: Create loopback interface aggregate
ios_interface: ios_interface:
aggregate: aggregate:
@ -271,9 +223,7 @@
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface Loopback9" in result.commands' - '"interface Loopback9" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"interface Loopback10" in result.commands' - '"interface Loopback10" in result.commands'
- '"description configured by ios_interface" in result.commands'
- name: Delete loopback interface aggregate - name: Delete loopback interface aggregate
ios_interface: ios_interface:

View file

@ -72,28 +72,16 @@
- '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands' - '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"interface GigabitEthernet0/0/0/2 mtu 256" in result.commands' - '"interface GigabitEthernet0/0/0/2 mtu 256" in result.commands'
- name: Delete interface parameters - name: Change interface parameters (idempotent)
iosxr_interface: iosxr_interface:
name: GigabitEthernet0/0/0/2 name: GigabitEthernet0/0/0/2
description: test-interface-1
speed: 10
duplex: full
mtu: 256
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
- assert:
that:
- 'result.changed == true'
- '"interface GigabitEthernet0/0/0/2 description configured by iosxr_interface" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 speed 10" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 mtu 256" in result.commands'
- name: Delete interface parameters (idempotent)
iosxr_interface:
name: GigabitEthernet0/0/0/2
state: present
provider: "{{ cli }}"
register: result
- assert: - assert:
that: that:
- 'result.changed == false' - 'result.changed == false'
@ -135,11 +123,20 @@
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/0/0/3 description test-interface-initial" in result.commands' - '"interface GigabitEthernet0/0/0/3 description test-interface-initial" in result.commands'
- name: Delete interface aggregate (setup)
iosxr_interface:
aggregate:
- name: GigabitEthernet0/0/0/3
- name: GigabitEthernet0/0/0/2
state: absent
- name: Add interface aggregate - name: Add interface aggregate
iosxr_interface: iosxr_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/3, speed: 10, duplex: half, mtu: 256, description: test-interface-1 } - { name: GigabitEthernet0/0/0/3, mtu: 256, description: test-interface-1 }
- { name: GigabitEthernet0/0/0/2, speed: 100, duplex: full, mtu: 516, description: test-interface-2 } - { name: GigabitEthernet0/0/0/2, mtu: 516, description: test-interface-2 }
speed: 100
duplex: full
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -147,20 +144,23 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/0/0/3 speed 10" in result.commands' - '"interface GigabitEthernet0/0/0/3 speed 100" in result.commands'
- '"interface GigabitEthernet0/0/0/3 description test-interface-1" in result.commands' - '"interface GigabitEthernet0/0/0/3 description test-interface-1" in result.commands'
- '"interface GigabitEthernet0/0/0/3 duplex half" in result.commands' - '"interface GigabitEthernet0/0/0/3 duplex full" in result.commands'
- '"interface GigabitEthernet0/0/0/3 mtu 256" in result.commands' - '"interface GigabitEthernet0/0/0/3 mtu 256" in result.commands'
- '"interface GigabitEthernet0/0/0/2 speed 100" in result.commands' - '"interface GigabitEthernet0/0/0/2 speed 100" in result.commands'
- '"interface GigabitEthernet0/0/0/2 description test-interface-2" in result.commands' - '"interface GigabitEthernet0/0/0/2 description test-interface-2" in result.commands'
- '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands' - '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"interface GigabitEthernet0/0/0/2 mtu 516" in result.commands' - '"interface GigabitEthernet0/0/0/2 mtu 516" in result.commands'
- name: Add interface aggregate (idempotent) - name: Add interface aggregate (idempotent)
iosxr_interface: iosxr_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/3, speed: 10, duplex: half, mtu: 256, description: test-interface-1 } - { name: GigabitEthernet0/0/0/3, mtu: 256, description: test-interface-1 }
- { name: GigabitEthernet0/0/0/2, speed: 100, duplex: full, mtu: 516, description: test-interface-2 } - { name: GigabitEthernet0/0/0/2, mtu: 516, description: test-interface-2 }
speed: 100
duplex: full
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -169,33 +169,12 @@
that: that:
- 'result.changed == false' - 'result.changed == false'
- name: Disable interface aggregate
- name: Change interface parameters in aggregate
iosxr_interface: iosxr_interface:
aggregate: aggregate:
- name: GigabitEthernet0/0/0/3 - name: GigabitEthernet0/0/0/3
- name: GigabitEthernet0/0/0/2 - name: GigabitEthernet0/0/0/2
state: present enabled: False
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"no interface GigabitEthernet0/0/0/3 speed 10" in result.commands'
- '"interface GigabitEthernet0/0/0/3 description configured by iosxr_interface" in result.commands'
- '"no interface GigabitEthernet0/0/0/3 duplex half" in result.commands'
- '"no interface GigabitEthernet0/0/0/3 mtu 256" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 speed 100" in result.commands'
- '"interface GigabitEthernet0/0/0/2 description configured by iosxr_interface" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 mtu 516" in result.commands'
- name: Disable interface aggregate
iosxr_interface:
aggregate:
- { name: GigabitEthernet0/0/0/3, enabled: False }
- { name: GigabitEthernet0/0/0/2, enabled: False }
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -235,7 +214,9 @@
iosxr_interface: iosxr_interface:
aggregate: aggregate:
- name: GigabitEthernet0/0/0/4 - name: GigabitEthernet0/0/0/4
description: test_interface_1
- name: GigabitEthernet0/0/0/5 - name: GigabitEthernet0/0/0/5
description: test_interface_2
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -243,8 +224,8 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/0/0/4 description configured by iosxr_interface" in result.commands' - '"interface GigabitEthernet0/0/0/4 description test_interface_1" in result.commands'
- '"interface GigabitEthernet0/0/0/5 description configured by iosxr_interface" in result.commands' - '"interface GigabitEthernet0/0/0/5 description test_interface_2" in result.commands'
- name: Delete interface aggregate - name: Delete interface aggregate
iosxr_interface: iosxr_interface:

View file

@ -4,6 +4,7 @@
- name: Setup (interface is up) - name: Setup (interface is up)
iosxr_interface: iosxr_interface:
name: GigabitEthernet0/0/0/5 name: GigabitEthernet0/0/0/5
description: test_interface_5
enabled: True enabled: True
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"

View file

@ -37,7 +37,6 @@
- "'<device-count>4</device-count>' in config.xml" - "'<device-count>4</device-count>' in config.xml"
- "'<bundle>ae0</bundle>' in config.xml" - "'<bundle>ae0</bundle>' in config.xml"
- "'<active/>' in config.xml" - "'<active/>' in config.xml"
- "'<description>configured by junos_linkagg</description>' in config.xml"
- name: configure linkagg (idempotent) - name: configure linkagg (idempotent)
junos_linkagg: junos_linkagg:

View file

@ -126,7 +126,6 @@
- result.diff.prepared | search("\+ *test_vlan_1") - result.diff.prepared | search("\+ *test_vlan_1")
- result.diff.prepared | search("\+ *vlan-id 159") - result.diff.prepared | search("\+ *vlan-id 159")
- result.diff.prepared | search("\+ *test_vlan_2") - result.diff.prepared | search("\+ *test_vlan_2")
- result.diff.prepared | search("\+ *description \"configured by junos_vlan\"")
- name: Deactivate vlan configuration using aggregate - name: Deactivate vlan configuration using aggregate
junos_vlan: junos_vlan:

View file

@ -1,5 +1,5 @@
--- ---
- debug: msg="START net_interface ios/basic.yaml" - debug: msg="START net_interface cli/basic.yaml"
- name: Configure interface (setup) - name: Configure interface (setup)
net_interface: net_interface:
@ -46,7 +46,6 @@
name: GigabitEthernet0/2 name: GigabitEthernet0/2
description: test-interface description: test-interface
speed: 100 speed: 100
duplex: half
mtu: 512 mtu: 512
state: present state: present
authorize: yes authorize: yes
@ -59,7 +58,6 @@
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"description test-interface" in result.commands' - '"description test-interface" in result.commands'
- '"speed 100" in result.commands' - '"speed 100" in result.commands'
- '"duplex half" in result.commands'
- '"mtu 512" in result.commands' - '"mtu 512" in result.commands'
- name: Change interface parameters - name: Change interface parameters
@ -67,7 +65,7 @@
name: GigabitEthernet0/2 name: GigabitEthernet0/2
description: test-interface-1 description: test-interface-1
speed: 10 speed: 10
duplex: full duplex: half
mtu: 256 mtu: 256
state: present state: present
authorize: yes authorize: yes
@ -80,38 +78,9 @@
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"description test-interface-1" in result.commands' - '"description test-interface-1" in result.commands'
- '"speed 10" in result.commands' - '"speed 10" in result.commands'
- '"duplex full" in result.commands' - '"duplex half" in result.commands'
- '"mtu 256" in result.commands' - '"mtu 256" in result.commands'
- name: Delete interface parameters
net_interface:
name: GigabitEthernet0/2
state: present
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface GigabitEthernet0/2" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"no speed 10" in result.commands'
- '"no duplex full" in result.commands'
- '"no mtu 256" in result.commands'
- name: Delete interface parameters (idempotent)
net_interface:
name: GigabitEthernet0/2
state: present
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == false'
- name: Disable interface - name: Disable interface
net_interface: net_interface:
name: GigabitEthernet0/2 name: GigabitEthernet0/2
@ -145,7 +114,7 @@
name: GigabitEthernet0/1 name: GigabitEthernet0/1
description: test-interface-initial description: test-interface-initial
speed: 100 speed: 100
duplex: full duplex: half
mtu: 516 mtu: 516
state: present state: present
authorize: yes authorize: yes
@ -155,8 +124,10 @@
- name: Add interface aggregate - name: Add interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/1, speed: 10, duplex: half, mtu: 256, description: test-interface-1 } - { name: GigabitEthernet0/1, mtu: 256, description: test-interface-1 }
- { name: GigabitEthernet0/2, speed: 100, duplex: full, mtu: 516, description: test-interface-2 } - { name: GigabitEthernet0/2, mtu: 516, description: test-interface-2 }
duplex: full
speed: 100
state: present state: present
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
@ -166,9 +137,9 @@
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/1" in result.commands' - '"interface GigabitEthernet0/1" in result.commands'
- '"speed 10" in result.commands' - '"speed 100" in result.commands'
- '"description test-interface-1" in result.commands' - '"description test-interface-1" in result.commands'
- '"duplex half" in result.commands' - '"duplex full" in result.commands'
- '"mtu 256" in result.commands' - '"mtu 256" in result.commands'
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"speed 100" in result.commands' - '"speed 100" in result.commands'
@ -179,8 +150,10 @@
- name: Add interface aggregate (idempotent) - name: Add interface aggregate (idempotent)
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/1, speed: 10, duplex: half, mtu: 256, description: test-interface-1 } - { name: GigabitEthernet0/1, mtu: 256, description: test-interface-1 }
- { name: GigabitEthernet0/2, speed: 100, duplex: full, mtu: 516, description: test-interface-2 } - { name: GigabitEthernet0/2, mtu: 516, description: test-interface-2 }
duplex: full
speed: 100
state: present state: present
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
@ -190,36 +163,12 @@
that: that:
- 'result.changed == false' - 'result.changed == false'
- name: Change interface parameters in aggregate
net_interface:
aggregate:
- { name: GigabitEthernet0/1 }
- { name: GigabitEthernet0/2 }
state: present
authorize: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"interface GigabitEthernet0/1" in result.commands'
- '"no speed 10" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"no duplex half" in result.commands'
- '"no mtu 256" in result.commands'
- '"interface GigabitEthernet0/2" in result.commands'
- '"no speed 100" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"no duplex full" in result.commands'
- '"no mtu 516" in result.commands'
- name: Disable interface aggregate - name: Disable interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/1, enabled: False } - name: GigabitEthernet0/1
- { name: GigabitEthernet0/2, enabled: False } - name: GigabitEthernet0/2
enabled: False
state: present state: present
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
@ -236,8 +185,9 @@
- name: Enable interface aggregate - name: Enable interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/1, enabled: True } - name: GigabitEthernet0/1
- { name: GigabitEthernet0/2, enabled: True } - name: GigabitEthernet0/2
enabled: True
state: present state: present
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
@ -251,11 +201,19 @@
- '"interface GigabitEthernet0/2" in result.commands' - '"interface GigabitEthernet0/2" in result.commands'
- '"no shutdown" in result.commands' - '"no shutdown" in result.commands'
- name: loopback interface setup
net_interface:
aggregate:
- name: Loopback9
- name: Loopback10
state: absent
authorize: yes
- name: Create loopback interface aggregate - name: Create loopback interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: Loopback9 } - name: Loopback9
- { name: Loopback10 } - name: Loopback10
state: present state: present
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
@ -265,16 +223,14 @@
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface Loopback9" in result.commands' - '"interface Loopback9" in result.commands'
- '"description configured by ios_interface" in result.commands'
- '"interface Loopback10" in result.commands' - '"interface Loopback10" in result.commands'
- '"description configured by ios_interface" in result.commands'
- name: Delete loopback interface aggregate - name: Delete loopback interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: Loopback9, state: absent } - name: Loopback9
- { name: Loopback10, state: absent } - name: Loopback10
state: present state: absent
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -288,9 +244,9 @@
- name: Delete loopback interface aggregate (idempotent) - name: Delete loopback interface aggregate (idempotent)
net_interface: net_interface:
aggregate: aggregate:
- { name: Loopback9, state: absent } - name: Loopback9
- { name: Loopback10, state: absent } - name: Loopback10
state: present state: absent
authorize: yes authorize: yes
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -299,4 +255,4 @@
that: that:
- 'result.changed == false' - 'result.changed == false'
- debug: msg="END net_interface ios/basic.yaml" - debug: msg="END net_interface cli/basic.yaml"

View file

@ -72,28 +72,16 @@
- '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands' - '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"interface GigabitEthernet0/0/0/2 mtu 256" in result.commands' - '"interface GigabitEthernet0/0/0/2 mtu 256" in result.commands'
- name: Delete interface parameters - name: Change interface parameters (idempotent)
net_interface: net_interface:
name: GigabitEthernet0/0/0/2 name: GigabitEthernet0/0/0/2
description: test-interface-1
speed: 10
duplex: full
mtu: 256
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
- assert:
that:
- 'result.changed == true'
- '"interface GigabitEthernet0/0/0/2 description configured by iosxr_interface" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 speed 10" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 mtu 256" in result.commands'
- name: Delete interface parameters (idempotent)
net_interface:
name: GigabitEthernet0/0/0/2
state: present
provider: "{{ cli }}"
register: result
- assert: - assert:
that: that:
- 'result.changed == false' - 'result.changed == false'
@ -135,11 +123,20 @@
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/0/0/3 description test-interface-initial" in result.commands' - '"interface GigabitEthernet0/0/0/3 description test-interface-initial" in result.commands'
- name: Delete interface aggregate (setup)
net_interface:
aggregate:
- name: GigabitEthernet0/0/0/3
- name: GigabitEthernet0/0/0/2
state: absent
- name: Add interface aggregate - name: Add interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/3, speed: 10, duplex: half, mtu: 256, description: test-interface-1 } - { name: GigabitEthernet0/0/0/3, mtu: 256, description: test-interface-1 }
- { name: GigabitEthernet0/0/0/2, speed: 100, duplex: full, mtu: 516, description: test-interface-2 } - { name: GigabitEthernet0/0/0/2, mtu: 516, description: test-interface-2 }
speed: 100
duplex: full
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -147,20 +144,23 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/0/0/3 speed 10" in result.commands' - '"interface GigabitEthernet0/0/0/3 speed 100" in result.commands'
- '"interface GigabitEthernet0/0/0/3 description test-interface-1" in result.commands' - '"interface GigabitEthernet0/0/0/3 description test-interface-1" in result.commands'
- '"interface GigabitEthernet0/0/0/3 duplex half" in result.commands' - '"interface GigabitEthernet0/0/0/3 duplex full" in result.commands'
- '"interface GigabitEthernet0/0/0/3 mtu 256" in result.commands' - '"interface GigabitEthernet0/0/0/3 mtu 256" in result.commands'
- '"interface GigabitEthernet0/0/0/2 speed 100" in result.commands' - '"interface GigabitEthernet0/0/0/2 speed 100" in result.commands'
- '"interface GigabitEthernet0/0/0/2 description test-interface-2" in result.commands' - '"interface GigabitEthernet0/0/0/2 description test-interface-2" in result.commands'
- '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands' - '"interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"interface GigabitEthernet0/0/0/2 mtu 516" in result.commands' - '"interface GigabitEthernet0/0/0/2 mtu 516" in result.commands'
- name: Add interface aggregate (idempotent) - name: Add interface aggregate (idempotent)
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/3, speed: 10, duplex: half, mtu: 256, description: test-interface-1 } - { name: GigabitEthernet0/0/0/3, mtu: 256, description: test-interface-1 }
- { name: GigabitEthernet0/0/0/2, speed: 100, duplex: full, mtu: 516, description: test-interface-2 } - { name: GigabitEthernet0/0/0/2, mtu: 516, description: test-interface-2 }
speed: 100
duplex: full
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -169,33 +169,12 @@
that: that:
- 'result.changed == false' - 'result.changed == false'
- name: Change interface parameters in aggregate
net_interface:
aggregate:
- { name: GigabitEthernet0/0/0/3 }
- { name: GigabitEthernet0/0/0/2 }
state: present
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == true'
- '"no interface GigabitEthernet0/0/0/3 speed 10" in result.commands'
- '"interface GigabitEthernet0/0/0/3 description configured by iosxr_interface" in result.commands'
- '"no interface GigabitEthernet0/0/0/3 duplex half" in result.commands'
- '"no interface GigabitEthernet0/0/0/3 mtu 256" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 speed 100" in result.commands'
- '"interface GigabitEthernet0/0/0/2 description configured by iosxr_interface" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 duplex full" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 mtu 516" in result.commands'
- name: Disable interface aggregate - name: Disable interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/3, enabled: False } - name: GigabitEthernet0/0/0/3
- { name: GigabitEthernet0/0/0/2, enabled: False } - name: GigabitEthernet0/0/0/2
enabled: False
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -209,8 +188,9 @@
- name: Enable interface aggregate - name: Enable interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/3, enabled: True } - name: GigabitEthernet0/0/0/3
- { name: GigabitEthernet0/0/0/2, enabled: True } - name: GigabitEthernet0/0/0/2
enabled: True
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -221,11 +201,22 @@
- '"no interface GigabitEthernet0/0/0/3 shutdown" in result.commands' - '"no interface GigabitEthernet0/0/0/3 shutdown" in result.commands'
- '"no interface GigabitEthernet0/0/0/2 shutdown" in result.commands' - '"no interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
- name: interface aggregate (setup)
net_interface:
aggregate:
- name: GigabitEthernet0/0/0/4
- name: GigabitEthernet0/0/0/5
description: test-interface-initial
provider: "{{ cli }}"
register: result
- name: Create interface aggregate - name: Create interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/4 } - name: GigabitEthernet0/0/0/4
- { name: GigabitEthernet0/0/0/5 } description: test_interface_1
- name: GigabitEthernet0/0/0/5
description: test_interface_2
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -233,15 +224,15 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"interface GigabitEthernet0/0/0/4 description configured by iosxr_interface" in result.commands' - '"interface GigabitEthernet0/0/0/4 description test_interface_1" in result.commands'
- '"interface GigabitEthernet0/0/0/5 description configured by iosxr_interface" in result.commands' - '"interface GigabitEthernet0/0/0/5 description test_interface_2" in result.commands'
- name: Delete interface aggregate - name: Delete interface aggregate
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/4, state: absent } - name: GigabitEthernet0/0/0/4
- { name: GigabitEthernet0/0/0/5, state: absent } - name: GigabitEthernet0/0/0/5
state: present state: absent
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result
@ -254,9 +245,9 @@
- name: Delete interface aggregate (idempotent) - name: Delete interface aggregate (idempotent)
net_interface: net_interface:
aggregate: aggregate:
- { name: GigabitEthernet0/0/0/4, state: absent } - name: GigabitEthernet0/0/0/4
- { name: GigabitEthernet0/0/0/5, state: absent } - name: GigabitEthernet0/0/0/5
state: present state: absent
provider: "{{ cli }}" provider: "{{ cli }}"
register: result register: result

View file

@ -1,9 +1,10 @@
--- ---
- debug: msg="START net_interface cli/intent.yaml" - debug: msg="START net_interface iosxr/intent.yaml"
- name: Setup (interface is up) - name: Setup (interface is up)
net_interface: net_interface:
name: GigabitEthernet0/0/0/5 name: GigabitEthernet0/0/0/5
description: test_interface_5
enabled: True enabled: True
state: present state: present
provider: "{{ cli }}" provider: "{{ cli }}"

View file

@ -37,7 +37,6 @@
- "'<device-count>4</device-count>' in config.xml" - "'<device-count>4</device-count>' in config.xml"
- "'<bundle>ae0</bundle>' in config.xml" - "'<bundle>ae0</bundle>' in config.xml"
- "'<active/>' in config.xml" - "'<active/>' in config.xml"
- "'<description>configured by junos_linkagg</description>' in config.xml"
- name: configure linkagg (idempotent) - name: configure linkagg (idempotent)
net_linkagg: net_linkagg: