0bbea9a579
* Bug in del(list) logic. Say you have a list of 4 elements a[0-3] and you have to remove index 1 and 3, if you remove index 1 first then list is cut short a[0-2] and does not have index 3 Fix: Remove indexes in reverse sorted order e.g. 3 and 1 in above example so that order of indexes remain preserved even after deleting fix is to remove indexes in reverse sorted order * Add test cases for failed case
63 lines
1.6 KiB
YAML
63 lines
1.6 KiB
YAML
---
|
|
- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}"
|
|
|
|
- name: setup- ensure interface is not present
|
|
vyos_config:
|
|
lines: delete interfaces loopback lo
|
|
|
|
- name: setup- create interface
|
|
vyos_config:
|
|
lines:
|
|
- interfaces
|
|
- interfaces loopback lo
|
|
- interfaces loopback lo description test
|
|
register: result
|
|
|
|
# note collapsing the duplicate lines doesn't work if
|
|
# lines:
|
|
# - interfaces loopback lo description test
|
|
# - interfaces loopback lo
|
|
# - interfaces
|
|
|
|
- name: Check that multiple duplicate lines collapse into a single commands
|
|
assert:
|
|
that:
|
|
- "{{ result.commands|length }} == 1"
|
|
|
|
- name: Check that set is correctly prepended
|
|
assert:
|
|
that:
|
|
- "result.commands[0] == 'set interfaces loopback lo description test'"
|
|
|
|
- name: configure config_check config command
|
|
vyos_config:
|
|
lines: delete interfaces loopback lo
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "result.changed == true"
|
|
|
|
- name: check config_check config command idempontent
|
|
vyos_config:
|
|
lines: delete interfaces loopback lo
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "result.changed == false"
|
|
|
|
- name: check multiple line config filter is working
|
|
vyos_config:
|
|
lines:
|
|
- set system login user esa level admin
|
|
- set system login user esa authentication encrypted-password '!abc!'
|
|
- set system login user vyos level admin
|
|
- set system login user vyos authentication encrypted-password 'abc'
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "{{ result.filtered|length }} == 2"
|
|
|
|
- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}"
|