mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add intent arguments for ios and iosxr interface modules (#28018)
* Add intent arguments for ios_interface * Intent argument support * Integration test case for intent arguments * Fix ci issue * Add intent arguments for iosxr_interface * Add intent check support for iosxr_interface * Integration test for intent + configuration * Fix ci failure
This commit is contained in:
parent
38c0b581c3
commit
a12e9807ba
11 changed files with 577 additions and 87 deletions
|
@ -46,10 +46,15 @@ options:
|
||||||
choices: ['full', 'half', 'auto']
|
choices: ['full', 'half', 'auto']
|
||||||
tx_rate:
|
tx_rate:
|
||||||
description:
|
description:
|
||||||
- Transmit rate
|
- Transmit rate.
|
||||||
rx_rate:
|
rx_rate:
|
||||||
description:
|
description:
|
||||||
- Receiver rate
|
- Receiver rate.
|
||||||
|
delay:
|
||||||
|
description:
|
||||||
|
- Time in seconds to wait before checking for the operational state on remote
|
||||||
|
device. This wait is applicable for operational state argument which are
|
||||||
|
I(state) with values C(up)/C(down), I(tx_rate) and I(rx_rate).
|
||||||
aggregate:
|
aggregate:
|
||||||
description: List of Interfaces definitions.
|
description: List of Interfaces definitions.
|
||||||
purge:
|
purge:
|
||||||
|
@ -105,6 +110,19 @@ EXAMPLES = """
|
||||||
- name: ge-0/0/1
|
- name: ge-0/0/1
|
||||||
- name: ge-0/0/2
|
- name: ge-0/0/2
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Check intent arguments
|
||||||
|
net_interface:
|
||||||
|
name: fxp0
|
||||||
|
state: up
|
||||||
|
tx_rate: ge(0)
|
||||||
|
rx_rate: le(0)
|
||||||
|
|
||||||
|
- name: Config + intent
|
||||||
|
net_interface:
|
||||||
|
name: fxp0
|
||||||
|
enabled: False
|
||||||
|
state: down
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
|
|
@ -46,17 +46,17 @@ options:
|
||||||
choices: ['full', 'half', 'auto']
|
choices: ['full', 'half', 'auto']
|
||||||
tx_rate:
|
tx_rate:
|
||||||
description:
|
description:
|
||||||
- Transmit rate
|
- Transmit rate in bits per second (bps).
|
||||||
rx_rate:
|
rx_rate:
|
||||||
description:
|
description:
|
||||||
- Receiver rate
|
- Receiver rate in bits per second (bps).
|
||||||
aggregate:
|
aggregate:
|
||||||
description: List of Interfaces definitions.
|
description: List of Interfaces definitions.
|
||||||
purge:
|
delay:
|
||||||
description:
|
description:
|
||||||
- Purge Interfaces not defined in the aggregate parameter.
|
- Time in seconds to wait before checking for the operational state on remote
|
||||||
This applies only for logical interface.
|
device. This wait is applicable for operational state argument which are
|
||||||
default: no
|
I(state) with values C(up)/C(down), I(tx_rate) and I(rx_rate).
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- State of the Interface configuration, C(up) means present and
|
- State of the Interface configuration, C(up) means present and
|
||||||
|
@ -82,11 +82,24 @@ EXAMPLES = """
|
||||||
- name: make interface up
|
- name: make interface up
|
||||||
ios_interface:
|
ios_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
state: up
|
enabled: True
|
||||||
|
|
||||||
- name: make interface down
|
- name: make interface down
|
||||||
ios_interface:
|
ios_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
|
enabled: False
|
||||||
|
|
||||||
|
- name: Check intent arguments
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
state: up
|
||||||
|
tx_rate: ge(0)
|
||||||
|
rx_rate: le(0)
|
||||||
|
|
||||||
|
- name: Config + intent
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
enabled: False
|
||||||
state: down
|
state: down
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -103,10 +116,15 @@ commands:
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_text
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.connection import exec_command
|
||||||
from ansible.module_utils.ios import get_config, load_config
|
from ansible.module_utils.ios import get_config, load_config
|
||||||
from ansible.module_utils.ios import ios_argument_spec, check_args
|
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
|
||||||
|
|
||||||
DEFAULT_DESCRIPTION = "configured by ios_interface"
|
DEFAULT_DESCRIPTION = "configured by ios_interface"
|
||||||
|
|
||||||
|
@ -207,12 +225,17 @@ def map_params_to_obj(module):
|
||||||
|
|
||||||
if not d.get('state'):
|
if not d.get('state'):
|
||||||
d['state'] = module.params['state']
|
d['state'] = module.params['state']
|
||||||
|
if d.get('enabled') is None:
|
||||||
|
d['enabled'] = module.params['enabled']
|
||||||
|
|
||||||
if d['state'] in ('present', 'up'):
|
if d['enabled']:
|
||||||
d['disable'] = False
|
d['disable'] = False
|
||||||
else:
|
else:
|
||||||
d['disable'] = True
|
d['disable'] = True
|
||||||
|
|
||||||
|
if d.get('delay') is None:
|
||||||
|
d['delay'] = module.params['delay']
|
||||||
|
|
||||||
obj.append(d)
|
obj.append(d)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -224,11 +247,13 @@ def map_params_to_obj(module):
|
||||||
'speed': module.params['speed'],
|
'speed': module.params['speed'],
|
||||||
'mtu': module.params['mtu'],
|
'mtu': module.params['mtu'],
|
||||||
'duplex': module.params['duplex'],
|
'duplex': module.params['duplex'],
|
||||||
'state': module.params['state']
|
'state': module.params['state'],
|
||||||
|
'delay': module.params['delay'],
|
||||||
|
'tx_rate': module.params['tx_rate'],
|
||||||
|
'rx_rate': module.params['rx_rate']
|
||||||
}
|
}
|
||||||
|
|
||||||
state = module.params['state']
|
if module.params['enabled']:
|
||||||
if state == 'present' or state == 'up':
|
|
||||||
params.update({'disable': False})
|
params.update({'disable': False})
|
||||||
else:
|
else:
|
||||||
params.update({'disable': True})
|
params.update({'disable': True})
|
||||||
|
@ -286,6 +311,53 @@ def map_obj_to_commands(updates):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
|
||||||
|
def check_declarative_intent_params(module, want, result):
|
||||||
|
failed_conditions = []
|
||||||
|
|
||||||
|
for w in want:
|
||||||
|
want_state = w.get('state')
|
||||||
|
want_tx_rate = w.get('tx_rate')
|
||||||
|
want_rx_rate = w.get('rx_rate')
|
||||||
|
if want_state not in ('up', 'down') and not want_tx_rate and not want_rx_rate:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if result['changed']:
|
||||||
|
sleep(w['delay'])
|
||||||
|
|
||||||
|
command = 'show interfaces %s' % w['name']
|
||||||
|
rc, out, err = exec_command(module, command)
|
||||||
|
if rc != 0:
|
||||||
|
module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc)
|
||||||
|
|
||||||
|
if want_state in ('up', 'down'):
|
||||||
|
match = re.search(r'%s (\w+)' % 'line protocol is', out, re.M)
|
||||||
|
have_state = None
|
||||||
|
if match:
|
||||||
|
have_state = match.group(1)
|
||||||
|
if have_state is None or not conditional(want_state, have_state.strip()):
|
||||||
|
failed_conditions.append('state ' + 'eq(%s)' % want_state)
|
||||||
|
|
||||||
|
if want_tx_rate:
|
||||||
|
match = re.search(r'%s (\d+)' % 'output rate', out, re.M)
|
||||||
|
have_tx_rate = None
|
||||||
|
if match:
|
||||||
|
have_tx_rate = match.group(1)
|
||||||
|
|
||||||
|
if have_tx_rate is None or not conditional(want_tx_rate, have_tx_rate.strip(), cast=int):
|
||||||
|
failed_conditions.append('tx_rate ' + want_tx_rate)
|
||||||
|
|
||||||
|
if want_rx_rate:
|
||||||
|
match = re.search(r'%s (\d+)' % 'input rate', out, re.M)
|
||||||
|
have_rx_rate = None
|
||||||
|
if match:
|
||||||
|
have_rx_rate = match.group(1)
|
||||||
|
|
||||||
|
if have_rx_rate is None or not conditional(want_rx_rate, have_rx_rate.strip(), cast=int):
|
||||||
|
failed_conditions.append('rx_rate ' + want_rx_rate)
|
||||||
|
|
||||||
|
return failed_conditions
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
@ -295,11 +367,11 @@ def main():
|
||||||
speed=dict(),
|
speed=dict(),
|
||||||
mtu=dict(),
|
mtu=dict(),
|
||||||
duplex=dict(choices=['full', 'half', 'auto']),
|
duplex=dict(choices=['full', 'half', 'auto']),
|
||||||
enabled=dict(),
|
enabled=dict(default=True, type='bool'),
|
||||||
tx_rate=dict(),
|
tx_rate=dict(),
|
||||||
rx_rate=dict(),
|
rx_rate=dict(),
|
||||||
|
delay=dict(default=10, type='int'),
|
||||||
aggregate=dict(type='list'),
|
aggregate=dict(type='list'),
|
||||||
purge=dict(default=False, type='bool'),
|
|
||||||
state=dict(default='present',
|
state=dict(default='present',
|
||||||
choices=['present', 'absent', 'up', 'down'])
|
choices=['present', 'absent', 'up', 'down'])
|
||||||
)
|
)
|
||||||
|
@ -331,6 +403,12 @@ def main():
|
||||||
load_config(module, commands)
|
load_config(module, commands)
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
|
||||||
|
failed_conditions = check_declarative_intent_params(module, want, result)
|
||||||
|
|
||||||
|
if failed_conditions:
|
||||||
|
msg = 'One or more conditional statements have not been satisfied'
|
||||||
|
module.fail_json(msg=msg, failed_conditions=failed_conditions)
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -45,17 +45,17 @@ options:
|
||||||
choices: ['full', 'half']
|
choices: ['full', 'half']
|
||||||
tx_rate:
|
tx_rate:
|
||||||
description:
|
description:
|
||||||
- Transmit rate
|
- Transmit rate in bits per second (bps).
|
||||||
rx_rate:
|
rx_rate:
|
||||||
description:
|
description:
|
||||||
- Receiver rate
|
- Receiver rate in bits per second (bps).
|
||||||
aggregate:
|
aggregate:
|
||||||
description: List of Interfaces definitions.
|
description: List of Interfaces definitions.
|
||||||
purge:
|
delay:
|
||||||
description:
|
description:
|
||||||
- Purge Interfaces not defined in the aggregate parameter.
|
- Time in seconds to wait before checking for the operational state on remote
|
||||||
This applies only for logical interface.
|
device. This wait is applicable for operational state argument which are
|
||||||
default: no
|
I(state) with values C(up)/C(down), I(tx_rate) and I(rx_rate).
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- State of the Interface configuration, C(up) means present and
|
- State of the Interface configuration, C(up) means present and
|
||||||
|
@ -81,12 +81,12 @@ EXAMPLES = """
|
||||||
- name: make interface up
|
- name: make interface up
|
||||||
iosxr_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: up
|
enabled: True
|
||||||
|
|
||||||
- name: make interface down
|
- name: make interface down
|
||||||
iosxr_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: down
|
enabled: False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
@ -102,9 +102,14 @@ commands:
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
from ansible.module_utils._text import to_text
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
from ansible.module_utils.connection import exec_command
|
||||||
from ansible.module_utils.iosxr import get_config, load_config
|
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
|
||||||
|
|
||||||
DEFAULT_DESCRIPTION = "configured by iosxr_interface"
|
DEFAULT_DESCRIPTION = "configured by iosxr_interface"
|
||||||
|
|
||||||
|
@ -173,11 +178,17 @@ def map_params_to_obj(module):
|
||||||
if not d.get('state'):
|
if not d.get('state'):
|
||||||
d['state'] = module.params['state']
|
d['state'] = module.params['state']
|
||||||
|
|
||||||
if d['state'] in ('present', 'up'):
|
if d.get('enabled') is None:
|
||||||
|
d['enabled'] = module.params['enabled']
|
||||||
|
|
||||||
|
if d['enabled']:
|
||||||
d['disable'] = False
|
d['disable'] = False
|
||||||
else:
|
else:
|
||||||
d['disable'] = True
|
d['disable'] = True
|
||||||
|
|
||||||
|
if d.get('delay') is None:
|
||||||
|
d['delay'] = module.params['delay']
|
||||||
|
|
||||||
obj.append(d)
|
obj.append(d)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -188,11 +199,13 @@ def map_params_to_obj(module):
|
||||||
'speed': module.params['speed'],
|
'speed': module.params['speed'],
|
||||||
'mtu': module.params['mtu'],
|
'mtu': module.params['mtu'],
|
||||||
'duplex': module.params['duplex'],
|
'duplex': module.params['duplex'],
|
||||||
'state': module.params['state']
|
'state': module.params['state'],
|
||||||
|
'delay': module.params['delay'],
|
||||||
|
'tx_rate': module.params['tx_rate'],
|
||||||
|
'rx_rate': module.params['rx_rate']
|
||||||
}
|
}
|
||||||
|
|
||||||
state = module.params['state']
|
if module.params['enabled']:
|
||||||
if state == 'present' or state == 'up':
|
|
||||||
params.update({'disable': False})
|
params.update({'disable': False})
|
||||||
else:
|
else:
|
||||||
params.update({'disable': True})
|
params.update({'disable': True})
|
||||||
|
@ -275,6 +288,57 @@ def map_obj_to_commands(updates):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
|
||||||
|
def check_declarative_intent_params(module, want, result):
|
||||||
|
failed_conditions = []
|
||||||
|
for w in want:
|
||||||
|
want_state = w.get('state')
|
||||||
|
want_tx_rate = w.get('tx_rate')
|
||||||
|
want_rx_rate = w.get('rx_rate')
|
||||||
|
if want_state not in ('up', 'down') and not want_tx_rate and not want_rx_rate:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if result['changed']:
|
||||||
|
sleep(w['delay'])
|
||||||
|
|
||||||
|
command = 'show interfaces %s' % w['name']
|
||||||
|
rc, out, err = exec_command(module, command)
|
||||||
|
if rc != 0:
|
||||||
|
module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc)
|
||||||
|
|
||||||
|
if want_state in ('up', 'down'):
|
||||||
|
match = re.search(r'%s (\w+)' % 'line protocol is', out, re.M)
|
||||||
|
have_state = None
|
||||||
|
if match:
|
||||||
|
have_state = match.group(1)
|
||||||
|
if have_state.strip() == 'administratively':
|
||||||
|
match = re.search(r'%s (\w+)' % 'administratively', out, re.M)
|
||||||
|
if match:
|
||||||
|
have_state = match.group(1)
|
||||||
|
|
||||||
|
if have_state is None or not conditional(want_state, have_state.strip()):
|
||||||
|
failed_conditions.append('state ' + 'eq(%s)' % want_state)
|
||||||
|
|
||||||
|
if want_tx_rate:
|
||||||
|
match = re.search(r'%s (\d+)' % 'output rate', out, re.M)
|
||||||
|
have_tx_rate = None
|
||||||
|
if match:
|
||||||
|
have_tx_rate = match.group(1)
|
||||||
|
|
||||||
|
if have_tx_rate is None or not conditional(want_tx_rate, have_tx_rate.strip(), cast=int):
|
||||||
|
failed_conditions.append('tx_rate ' + want_tx_rate)
|
||||||
|
|
||||||
|
if want_rx_rate:
|
||||||
|
match = re.search(r'%s (\d+)' % 'input rate', out, re.M)
|
||||||
|
have_rx_rate = None
|
||||||
|
if match:
|
||||||
|
have_rx_rate = match.group(1)
|
||||||
|
|
||||||
|
if have_rx_rate is None or not conditional(want_rx_rate, have_rx_rate.strip(), cast=int):
|
||||||
|
failed_conditions.append('rx_rate ' + want_rx_rate)
|
||||||
|
|
||||||
|
return failed_conditions
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main entry point for module execution
|
""" main entry point for module execution
|
||||||
"""
|
"""
|
||||||
|
@ -284,11 +348,11 @@ def main():
|
||||||
speed=dict(),
|
speed=dict(),
|
||||||
mtu=dict(),
|
mtu=dict(),
|
||||||
duplex=dict(choices=['full', 'half']),
|
duplex=dict(choices=['full', 'half']),
|
||||||
enabled=dict(),
|
enabled=dict(default=True, type='bool'),
|
||||||
tx_rate=dict(),
|
tx_rate=dict(),
|
||||||
rx_rate=dict(),
|
rx_rate=dict(),
|
||||||
|
delay=dict(default=10, type='int'),
|
||||||
aggregate=dict(type='list'),
|
aggregate=dict(type='list'),
|
||||||
purge=dict(default=False, type='bool'),
|
|
||||||
state=dict(default='present',
|
state=dict(default='present',
|
||||||
choices=['present', 'absent', 'up', 'down'])
|
choices=['present', 'absent', 'up', 'down'])
|
||||||
)
|
)
|
||||||
|
@ -316,14 +380,18 @@ def main():
|
||||||
result['commands'] = commands
|
result['commands'] = commands
|
||||||
result['warnings'] = warnings
|
result['warnings'] = warnings
|
||||||
|
|
||||||
if 'no username admin' in commands:
|
|
||||||
module.fail_json(msg='cannot delete the `admin` account')
|
|
||||||
|
|
||||||
if commands:
|
if commands:
|
||||||
if not module.check_mode:
|
if not module.check_mode:
|
||||||
load_config(module, commands, result['warnings'], commit=True)
|
load_config(module, commands, result['warnings'], commit=True)
|
||||||
|
exec_command(module, 'exit')
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
|
||||||
|
failed_conditions = check_declarative_intent_params(module, want, result)
|
||||||
|
|
||||||
|
if failed_conditions:
|
||||||
|
msg = 'One or more conditional statements have not been satisfied'
|
||||||
|
module.fail_json(msg=msg, failed_conditions=failed_conditions)
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START ios_interface netconf/basic.yaml"
|
- debug: msg="START ios_interface netconf/basic.yaml"
|
||||||
|
|
||||||
|
- name: Configure interface (setup)
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
description: test-interface-1
|
||||||
|
speed: 10
|
||||||
|
duplex: full
|
||||||
|
mtu: 256
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
- name: Confgure interface
|
- name: Confgure interface
|
||||||
ios_interface:
|
ios_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
|
@ -103,7 +115,7 @@
|
||||||
- name: Disable interface
|
- name: Disable interface
|
||||||
ios_interface:
|
ios_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
state: down
|
enabled: False
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -117,7 +129,7 @@
|
||||||
- name: Enable interface
|
- name: Enable interface
|
||||||
ios_interface:
|
ios_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
state: up
|
enabled: True
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -132,17 +144,14 @@
|
||||||
ios_interface:
|
ios_interface:
|
||||||
name: GigabitEthernet0/1
|
name: GigabitEthernet0/1
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
|
speed: 100
|
||||||
|
duplex: full
|
||||||
|
mtu: 516
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- 'result.changed == true'
|
|
||||||
- '"interface GigabitEthernet0/1" in result.commands'
|
|
||||||
- '"description test-interface-initial" in result.commands'
|
|
||||||
|
|
||||||
- name: Add interface aggregate
|
- name: Add interface aggregate
|
||||||
ios_interface:
|
ios_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
|
@ -209,8 +218,8 @@
|
||||||
- name: Disable interface aggregate
|
- name: Disable interface aggregate
|
||||||
ios_interface:
|
ios_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/1, state: down }
|
- { name: GigabitEthernet0/1, enabled: False }
|
||||||
- { name: GigabitEthernet0/2, state: down }
|
- { name: GigabitEthernet0/2, enabled: False }
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
@ -227,8 +236,8 @@
|
||||||
- name: Enable interface aggregate
|
- name: Enable interface aggregate
|
||||||
ios_interface:
|
ios_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/1, state: up }
|
- { name: GigabitEthernet0/1, enabled: True }
|
||||||
- { name: GigabitEthernet0/2, state: up }
|
- { name: GigabitEthernet0/2, enabled: True }
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
|
77
test/integration/targets/ios_interface/tests/cli/intent.yaml
Normal file
77
test/integration/targets/ios_interface/tests/cli/intent.yaml
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START ios_interface cli/intent.yaml"
|
||||||
|
|
||||||
|
- name: Check intent arguments
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
state: up
|
||||||
|
tx_rate: ge(0)
|
||||||
|
rx_rate: le(0)
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Check intent arguments (failed condition)
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
state: down
|
||||||
|
tx_rate: gt(0)
|
||||||
|
rx_rate: lt(0)
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(down)' in result.failed_conditions"
|
||||||
|
- "'tx_rate gt(0)' in result.failed_conditions"
|
||||||
|
- "'rx_rate lt(0)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Config + intent
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
enabled: False
|
||||||
|
state: down
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Config + intent (fail)
|
||||||
|
ios_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
enabled: False
|
||||||
|
authorize: yes
|
||||||
|
state: up
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(up)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Aggregate config + intent (pass)
|
||||||
|
ios_interface:
|
||||||
|
aggregate:
|
||||||
|
- name: GigabitEthernet0/2
|
||||||
|
enabled: True
|
||||||
|
state: up
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
|
@ -2,7 +2,7 @@
|
||||||
- debug: msg="START iosxr_interface cli/basic.yaml"
|
- debug: msg="START iosxr_interface cli/basic.yaml"
|
||||||
|
|
||||||
- name: Setup interface
|
- name: Setup interface
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: absent
|
state: absent
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
- name: Confgure interface
|
- name: Confgure interface
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
state: present
|
state: present
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
- '"interface GigabitEthernet0/0/0/2 description test-interface-initial" in result.commands'
|
- '"interface GigabitEthernet0/0/0/2 description test-interface-initial" in result.commands'
|
||||||
|
|
||||||
- name: Confgure interface (idempotent)
|
- name: Confgure interface (idempotent)
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
state: present
|
state: present
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
- 'result.changed == false'
|
- 'result.changed == false'
|
||||||
|
|
||||||
- name: Confgure interface parameters
|
- name: Confgure interface parameters
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
description: test-interface
|
description: test-interface
|
||||||
speed: 100
|
speed: 100
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
- '"interface GigabitEthernet0/0/0/2 mtu 512" in result.commands'
|
- '"interface GigabitEthernet0/0/0/2 mtu 512" in result.commands'
|
||||||
|
|
||||||
- name: Change interface parameters
|
- name: Change interface parameters
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
description: test-interface-1
|
description: test-interface-1
|
||||||
speed: 10
|
speed: 10
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
- '"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: Delete interface parameters
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
- '"no interface GigabitEthernet0/0/0/2 mtu 256" in result.commands'
|
- '"no interface GigabitEthernet0/0/0/2 mtu 256" in result.commands'
|
||||||
|
|
||||||
- name: Delete interface parameters (idempotent)
|
- name: Delete interface parameters (idempotent)
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
@ -99,9 +99,9 @@
|
||||||
- 'result.changed == false'
|
- 'result.changed == false'
|
||||||
|
|
||||||
- name: Disable interface
|
- name: Disable interface
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: down
|
enabled: False
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -111,9 +111,9 @@
|
||||||
- '"interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
- '"interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
||||||
|
|
||||||
- name: Enable interface
|
- name: Enable interface
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: up
|
enabled: True
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
- '"no interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
- '"no interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
||||||
|
|
||||||
- name: Confgure second interface (setup)
|
- name: Confgure second interface (setup)
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
name: GigabitEthernet0/0/0/3
|
name: GigabitEthernet0/0/0/3
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
state: present
|
state: present
|
||||||
|
@ -136,7 +136,7 @@
|
||||||
- '"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: Add interface aggregate
|
- name: Add interface aggregate
|
||||||
net_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, speed: 10, duplex: half, 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, speed: 100, duplex: full, mtu: 516, description: test-interface-2 }
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
- '"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:
|
iosxr_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/3, speed: 10, duplex: half, mtu: 256, description: test-interface-1 }
|
- { name: GigabitEthernet0/0/0/3, speed: 10, duplex: half, 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, speed: 100, duplex: full, mtu: 516, description: test-interface-2 }
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
|
|
||||||
|
|
||||||
- name: Change interface parameters in aggregate
|
- name: Change interface parameters in aggregate
|
||||||
net_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 }
|
||||||
|
@ -192,10 +192,10 @@
|
||||||
- '"no interface GigabitEthernet0/0/0/2 mtu 516" in result.commands'
|
- '"no interface GigabitEthernet0/0/0/2 mtu 516" in result.commands'
|
||||||
|
|
||||||
- name: Disable interface aggregate
|
- name: Disable interface aggregate
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/3, state: down }
|
- { name: GigabitEthernet0/0/0/3, enabled: False }
|
||||||
- { name: GigabitEthernet0/0/0/2, state: down }
|
- { name: GigabitEthernet0/0/0/2, enabled: False }
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -207,10 +207,10 @@
|
||||||
- '"interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
- '"interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
||||||
|
|
||||||
- name: Enable interface aggregate
|
- name: Enable interface aggregate
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/3, state: up }
|
- { name: GigabitEthernet0/0/0/3, enabled: True }
|
||||||
- { name: GigabitEthernet0/0/0/2, state: up }
|
- { name: GigabitEthernet0/0/0/2, enabled: True }
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -222,7 +222,7 @@
|
||||||
- '"no interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
- '"no interface GigabitEthernet0/0/0/2 shutdown" in result.commands'
|
||||||
|
|
||||||
- name: Create interface aggregate
|
- name: Create interface aggregate
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/4 }
|
- { name: GigabitEthernet0/0/0/4 }
|
||||||
- { name: GigabitEthernet0/0/0/5 }
|
- { name: GigabitEthernet0/0/0/5 }
|
||||||
|
@ -237,7 +237,7 @@
|
||||||
- '"interface GigabitEthernet0/0/0/5 description configured by iosxr_interface" in result.commands'
|
- '"interface GigabitEthernet0/0/0/5 description configured by iosxr_interface" in result.commands'
|
||||||
|
|
||||||
- name: Delete interface aggregate
|
- name: Delete interface aggregate
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/4, state: absent }
|
- { name: GigabitEthernet0/0/0/4, state: absent }
|
||||||
- { name: GigabitEthernet0/0/0/5, state: absent }
|
- { name: GigabitEthernet0/0/0/5, state: absent }
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
- '"no interface GigabitEthernet0/0/0/5" in result.commands'
|
- '"no interface GigabitEthernet0/0/0/5" in result.commands'
|
||||||
|
|
||||||
- name: Delete interface aggregate (idempotent)
|
- name: Delete interface aggregate (idempotent)
|
||||||
net_interface:
|
iosxr_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/4, state: absent }
|
- { name: GigabitEthernet0/0/0/4, state: absent }
|
||||||
- { name: GigabitEthernet0/0/0/5, state: absent }
|
- { name: GigabitEthernet0/0/0/5, state: absent }
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START iosxr_interface cli/intent.yaml"
|
||||||
|
|
||||||
|
- name: Setup (interface is up)
|
||||||
|
iosxr_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: True
|
||||||
|
state: present
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Check intent arguments
|
||||||
|
iosxr_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
state: up
|
||||||
|
delay: 20
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Check intent arguments (failed condition)
|
||||||
|
iosxr_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
state: down
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(down)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Config + intent
|
||||||
|
iosxr_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: False
|
||||||
|
state: down
|
||||||
|
delay: 20
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Config + intent (fail)
|
||||||
|
iosxr_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: False
|
||||||
|
state: up
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(up)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Aggregate config + intent (pass)
|
||||||
|
iosxr_interface:
|
||||||
|
aggregate:
|
||||||
|
- name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: True
|
||||||
|
state: up
|
||||||
|
delay: 20
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
|
@ -1,6 +1,18 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START net_interface ios/basic.yaml"
|
- debug: msg="START net_interface ios/basic.yaml"
|
||||||
|
|
||||||
|
- name: Configure interface (setup)
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
description: test-interface-1
|
||||||
|
speed: 10
|
||||||
|
duplex: full
|
||||||
|
mtu: 256
|
||||||
|
state: present
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
- name: Confgure interface
|
- name: Confgure interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
|
@ -103,7 +115,7 @@
|
||||||
- name: Disable interface
|
- name: Disable interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
state: down
|
enabled: False
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -117,7 +129,7 @@
|
||||||
- name: Enable interface
|
- name: Enable interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: GigabitEthernet0/2
|
name: GigabitEthernet0/2
|
||||||
state: up
|
enabled: True
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -132,17 +144,14 @@
|
||||||
net_interface:
|
net_interface:
|
||||||
name: GigabitEthernet0/1
|
name: GigabitEthernet0/1
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
|
speed: 100
|
||||||
|
duplex: full
|
||||||
|
mtu: 516
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- 'result.changed == true'
|
|
||||||
- '"interface GigabitEthernet0/1" in result.commands'
|
|
||||||
- '"description test-interface-initial" in result.commands'
|
|
||||||
|
|
||||||
- name: Add interface aggregate
|
- name: Add interface aggregate
|
||||||
net_interface:
|
net_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
|
@ -209,8 +218,8 @@
|
||||||
- name: Disable interface aggregate
|
- name: Disable interface aggregate
|
||||||
net_interface:
|
net_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/1, state: down }
|
- { name: GigabitEthernet0/1, enabled: False }
|
||||||
- { name: GigabitEthernet0/2, state: down }
|
- { name: GigabitEthernet0/2, enabled: False }
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
@ -227,8 +236,8 @@
|
||||||
- name: Enable interface aggregate
|
- name: Enable interface aggregate
|
||||||
net_interface:
|
net_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/1, state: up }
|
- { name: GigabitEthernet0/1, enabled: True }
|
||||||
- { name: GigabitEthernet0/2, state: up }
|
- { name: GigabitEthernet0/2, enabled: True }
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
|
@ -290,4 +299,4 @@
|
||||||
that:
|
that:
|
||||||
- 'result.changed == false'
|
- 'result.changed == false'
|
||||||
|
|
||||||
- debug: msg="END net_interface ios/basic.yaml"
|
- debug: msg="END net_interface ios/basic.yaml"
|
||||||
|
|
77
test/integration/targets/net_interface/tests/ios/intent.yaml
Normal file
77
test/integration/targets/net_interface/tests/ios/intent.yaml
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START net_interface ios/intent.yaml"
|
||||||
|
|
||||||
|
- name: Check intent arguments
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
state: up
|
||||||
|
tx_rate: ge(0)
|
||||||
|
rx_rate: le(0)
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Check intent arguments (failed condition)
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
state: down
|
||||||
|
tx_rate: gt(0)
|
||||||
|
rx_rate: lt(0)
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(down)' in result.failed_conditions"
|
||||||
|
- "'tx_rate gt(0)' in result.failed_conditions"
|
||||||
|
- "'rx_rate lt(0)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Config + intent
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
enabled: False
|
||||||
|
state: down
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Config + intent (fail)
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/2
|
||||||
|
enabled: False
|
||||||
|
authorize: yes
|
||||||
|
state: up
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(up)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Aggregate config + intent (pass)
|
||||||
|
net_interface:
|
||||||
|
aggregate:
|
||||||
|
- name: GigabitEthernet0/2
|
||||||
|
enabled: True
|
||||||
|
state: up
|
||||||
|
authorize: yes
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
|
@ -101,7 +101,7 @@
|
||||||
- name: Disable interface
|
- name: Disable interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: down
|
enabled: False
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
- name: Enable interface
|
- name: Enable interface
|
||||||
net_interface:
|
net_interface:
|
||||||
name: GigabitEthernet0/0/0/2
|
name: GigabitEthernet0/0/0/2
|
||||||
state: up
|
enabled: True
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -194,8 +194,8 @@
|
||||||
- name: Disable interface aggregate
|
- name: Disable interface aggregate
|
||||||
net_interface:
|
net_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/3, state: down }
|
- { name: GigabitEthernet0/0/0/3, enabled: False }
|
||||||
- { name: GigabitEthernet0/0/0/2, state: down }
|
- { name: GigabitEthernet0/0/0/2, enabled: False }
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
@ -209,8 +209,8 @@
|
||||||
- name: Enable interface aggregate
|
- name: Enable interface aggregate
|
||||||
net_interface:
|
net_interface:
|
||||||
aggregate:
|
aggregate:
|
||||||
- { name: GigabitEthernet0/0/0/3, state: up }
|
- { name: GigabitEthernet0/0/0/3, enabled: True }
|
||||||
- { name: GigabitEthernet0/0/0/2, state: up }
|
- { name: GigabitEthernet0/0/0/2, enabled: True }
|
||||||
state: present
|
state: present
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
- debug: msg="START net_interface cli/intent.yaml"
|
||||||
|
|
||||||
|
- name: Setup (interface is up)
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: True
|
||||||
|
state: present
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Check intent arguments
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
state: up
|
||||||
|
delay: 20
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Check intent arguments (failed condition)
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
state: down
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(down)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Config + intent
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: False
|
||||||
|
state: down
|
||||||
|
delay: 20
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
||||||
|
|
||||||
|
- name: Config + intent (fail)
|
||||||
|
net_interface:
|
||||||
|
name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: False
|
||||||
|
state: up
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "'state eq(up)' in result.failed_conditions"
|
||||||
|
|
||||||
|
- name: Aggregate config + intent (pass)
|
||||||
|
net_interface:
|
||||||
|
aggregate:
|
||||||
|
- name: GigabitEthernet0/0/0/5
|
||||||
|
enabled: True
|
||||||
|
state: up
|
||||||
|
delay: 20
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == false"
|
Loading…
Reference in a new issue