summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/vyos_prefix_lists/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tasks/cli.yaml19
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/_parsed.cfg18
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml22
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/_remove_config.yaml11
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml108
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/empty_config.yaml58
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/gathered.yaml24
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml77
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml61
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/parsed.yaml16
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml51
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml57
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml87
-rw-r--r--tests/integration/targets/vyos_prefix_lists/vars/main.yaml145
16 files changed, 761 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml b/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_prefix_lists/tasks/cli.yaml b/tests/integration/targets/vyos_prefix_lists/tasks/cli.yaml
new file mode 100644
index 0000000..93eb2fe
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tasks/cli.yaml
@@ -0,0 +1,19 @@
+---
+- name: Collect all cli test cases
+ find:
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml b/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml
new file mode 100644
index 0000000..b957d2f
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- include: cli.yaml
+ tags:
+ - network_cli
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/_parsed.cfg b/tests/integration/targets/vyos_prefix_lists/tests/cli/_parsed.cfg
new file mode 100644
index 0000000..25744b3
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/_parsed.cfg
@@ -0,0 +1,18 @@
+set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible'
+set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'permit'
+set policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given by ansible'
+set policy prefix-list AnsibleIPv4PrefixList rule 2 le '32'
+set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '92.168.10.0/26'
+set policy prefix-list AnsibleIPv4PrefixList rule 3 action 'deny'
+set policy prefix-list AnsibleIPv4PrefixList rule 3 description 'Rule 3'
+set policy prefix-list AnsibleIPv4PrefixList rule 3 ge '26'
+set policy prefix-list AnsibleIPv4PrefixList rule 3 prefix '72.168.2.0/24'
+set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks'
+set policy prefix-list6 AllowIPv6Prefix rule 5 action 'permit'
+set policy prefix-list6 AllowIPv6Prefix rule 5 description 'Permit rule'
+set policy prefix-list6 AllowIPv6Prefix rule 5 le '37'
+set policy prefix-list6 AllowIPv6Prefix rule 5 prefix '2001:db8:8000::/35'
+set policy prefix-list6 DenyIPv6Prefix description 'Configured by ansible for disallowing IPv6 networks'
+set policy prefix-list6 DenyIPv6Prefix rule 8 action 'deny'
+set policy prefix-list6 DenyIPv6Prefix rule 8 le '37'
+set policy prefix-list6 DenyIPv6Prefix rule 8 prefix '2001:db8:2000::/35' \ No newline at end of file
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml
new file mode 100644
index 0000000..9be477d
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/_populate_config.yaml
@@ -0,0 +1,22 @@
+---
+- name: Populate config
+ vyos.vyos.vyos_config:
+ lines:
+ - "set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'permit'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given by ansible'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 2 le '32'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '92.168.10.0/26'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 3 action 'deny'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 3 description 'Rule 3'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 3 ge '26'"
+ - "set policy prefix-list AnsibleIPv4PrefixList rule 3 prefix '72.168.2.0/24'"
+ - "set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks'"
+ - "set policy prefix-list6 AllowIPv6Prefix rule 5 action 'permit'"
+ - "set policy prefix-list6 AllowIPv6Prefix rule 5 description 'Permit rule'"
+ - "set policy prefix-list6 AllowIPv6Prefix rule 5 le '37'"
+ - "set policy prefix-list6 AllowIPv6Prefix rule 5 prefix '2001:db8:8000::/35'"
+ - "set policy prefix-list6 DenyIPv6Prefix description 'Configured by ansible for disallowing IPv6 networks'"
+ - "set policy prefix-list6 DenyIPv6Prefix rule 8 action 'deny'"
+ - "set policy prefix-list6 DenyIPv6Prefix rule 8 le '37'"
+ - "set policy prefix-list6 DenyIPv6Prefix rule 8 prefix '2001:db8:2000::/35'"
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/_remove_config.yaml
new file mode 100644
index 0000000..f0777b6
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/_remove_config.yaml
@@ -0,0 +1,11 @@
+---
+- name: Remove pre-existing prefix-list configurations
+ vyos.vyos.vyos_config:
+ lines:
+ - delete policy prefix-list AnsibleIPv4PrefixList
+ - delete policy prefix-list OverriddenPrefixList
+ - delete policy prefix-list6 AllowIPv6Prefix
+ - delete policy prefix-list6 DenyIPv6Prefix
+ ignore_errors: true
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml
new file mode 100644
index 0000000..9209fad
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/deleted.yaml
@@ -0,0 +1,108 @@
+---
+- debug:
+ msg: START vyos_prefix_lists deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ # Delete all prefix-lists
+ - name: Delete all prefix-lists
+ register: result
+ vyos.vyos.vyos_prefix_lists: &id006
+ config:
+ state: deleted
+
+ - name: Assert that before dicts are correctly generated
+ assert:
+ that:
+ - "{{ result['before'][0] == merged['after'][0] }}"
+ - "{{ result['before'][1] == merged['after'][1] }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ assert:
+ that:
+ - result["after"] == []
+
+ - name: Delete all prefix-lists (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_prefix_lists: *id006
+
+ - name: Assert that task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+ - result.commands|length == 0
+
+ - include_tasks: _remove_config.yaml
+
+ - include_tasks: _populate_config.yaml
+
+ # Delete all prefix-lists for an AFI
+ - name: Delete all prefix-lists for IPv6 AFI
+ register: result
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ - afi: "ipv6"
+ state: deleted
+
+ - name: Assert that before dicts are correctly generated
+ assert:
+ that:
+ - "{{ result['before'][0] == merged['after'][0] }}"
+ - "{{ result['before'][1] == merged['after'][1] }}"
+ - "{{ result['before']|length == 2 }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - '"delete policy prefix-list6 AllowIPv6Prefix" in result.commands'
+ - '"delete policy prefix-list6 DenyIPv6Prefix" in result.commands'
+ - result.commands|length == 2
+
+ - name: Assert that after dict is correctly generated
+ assert:
+ that:
+ - result["after"][0] == merged["after"][0]
+ - result["after"]|length == 1
+
+ - include_tasks: _remove_config.yaml
+
+ - include_tasks: _populate_config.yaml
+
+ # Delete single prefix-list from different AFIs
+ - name: Delete a single prefix-list from different AFIs
+ register: result
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ - afi: "ipv6"
+ prefix_lists:
+ - name: "DenyIPv6Prefix"
+ state: deleted
+
+ - name: Assert that before dicts are correctly generated
+ assert:
+ that:
+ - "{{ result['before'][0] == merged['after'][0] }}"
+ - "{{ result['before'][1] == merged['after'][1] }}"
+ - "{{ result['before']|length == 2 }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - '"delete policy prefix-list AnsibleIPv4PrefixList" in result.commands'
+ - '"delete policy prefix-list6 DenyIPv6Prefix" in result.commands'
+ - result.commands|length == 2
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..70ac937
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- debug:
+ msg: START vyos_prefix_lists empty_config integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ state: merged
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ state: replaced
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ state: overridden
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ state: rendered
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_prefix_lists:
+ running_config:
+ state: parsed
+
+- assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/gathered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/gathered.yaml
new file mode 100644
index 0000000..ef23bcc
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/gathered.yaml
@@ -0,0 +1,24 @@
+---
+- debug:
+ msg: START vyos_prefix_lists gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather prefix-lists configurations
+ register: result
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ state: gathered
+
+ - name: Assert that facts are correctly generated
+ assert:
+ that:
+ - result["gathered"][0] == merged["after"][0]
+ - result["gathered"][1] == merged["after"][1]
+ - result['gathered']|length == 2
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml
new file mode 100644
index 0000000..ef94743
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/merged.yaml
@@ -0,0 +1,77 @@
+---
+- debug:
+ msg: START vyos_prefix_lists merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge the provided configuration with the existing running configuration
+ register: result
+ vyos.vyos.vyos_prefix_lists: &id001
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ description: "PL configured by ansible"
+ entries:
+ - sequence: 2
+ description: "Rule 2 given by ansible"
+ action: "permit"
+ prefix: "92.168.10.0/26"
+ le: 32
+
+ - sequence: 3
+ description: "Rule 3"
+ action: "deny"
+ prefix: "72.168.2.0/24"
+ ge: 26
+
+ - afi: "ipv6"
+ prefix_lists:
+ - name: "AllowIPv6Prefix"
+ description: "Configured by ansible for allowing IPv6 networks"
+ entries:
+ - sequence: 5
+ description: "Permit rule"
+ action: "permit"
+ prefix: "2001:db8:8000::/35"
+ le: 37
+
+ - name: DenyIPv6Prefix
+ description: "Configured by ansible for disallowing IPv6 networks"
+ entries:
+ - sequence: 8
+ action: deny
+ prefix: "2001:db8:2000::/35"
+ le: 37
+ state: merged
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that: "{{ result['before'] == [] }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
+
+ - name: Assert that after dicts were correctly generated
+ assert:
+ that:
+ - "{{ result['after'][0] == merged['after'][0] }}"
+ - "{{ result['after'][1] == merged['after'][1] }}"
+ - "{{ result['after']|length == 2 }}"
+
+ - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
+ vyos.vyos.vyos_prefix_lists: *id001
+ register: result
+
+ - name: Assert that the previous task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+ - result.commands|length == 0
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml
new file mode 100644
index 0000000..7bcd26b
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/overridden.yaml
@@ -0,0 +1,61 @@
+---
+- debug:
+ msg: START vyos_prefix_lists overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override all prefix-lists configuration with provided configuration
+ register: result
+ vyos.vyos.vyos_prefix_lists: &id003
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ description: Rule 3 overridden by ansible
+ entries:
+ - sequence: 2
+ action: "deny"
+ ge: 26
+ prefix: "82.168.2.0/24"
+
+ - name: "OverriddenPrefixList"
+ description: Configuration overridden by ansible
+ entries:
+ - sequence: 10
+ action: permit
+ prefix: "203.0.113.96/27"
+ le: 32
+ state: overridden
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ result['before'][0] == merged['after'][0] }}"
+ - "{{ result['before'][1] == merged['after'][1] }}"
+ - "{{ result['before']|length == 2 }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
+
+ - name: Assert that after dicts were correctly generated
+ assert:
+ that:
+ - "{{ overridden['after'][0] == result['after'][0] }}"
+
+ - name: Override all prefix-lists configuration with provided configuration (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_prefix_lists: *id003
+
+ - name: Assert that task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+ - result.commands|length == 0
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/parsed.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/parsed.yaml
new file mode 100644
index 0000000..86772ef
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- debug:
+ msg: START vyos_prefix_lists parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse externally provided prefix-lists configuration
+ register: result
+ vyos.vyos.vyos_prefix_lists:
+ running_config: "{{ lookup('file', './_parsed.cfg') }}"
+ state: parsed
+
+- name: Assert that config was correctly parsed
+ assert:
+ that:
+ - "{{ result['parsed'][0] == merged['after'][0] }}"
+ - "{{ result['parsed'][1] == merged['after'][1] }}"
+ - "{{ result['parsed']|length == 2 }}"
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml
new file mode 100644
index 0000000..12a0deb
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/rendered.yaml
@@ -0,0 +1,51 @@
+---
+- debug:
+ msg: START vyos_prefix_lists rendered integration tests on connection={{ ansible_connection }}
+
+- name: Render commands externally for the described prefix-list configurations
+ register: result
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ description: "PL configured by ansible"
+ entries:
+ - sequence: 2
+ description: "Rule 2 given by ansible"
+ action: "permit"
+ prefix: "92.168.10.0/26"
+ le: 32
+
+ - sequence: 3
+ description: "Rule 3"
+ action: "deny"
+ prefix: "72.168.2.0/24"
+ ge: 26
+
+ - afi: "ipv6"
+ prefix_lists:
+ - name: "AllowIPv6Prefix"
+ description: "Configured by ansible for allowing IPv6 networks"
+ entries:
+ - sequence: 5
+ description: "Permit rule"
+ action: "permit"
+ prefix: "2001:db8:8000::/35"
+ le: 37
+
+ - name: DenyIPv6Prefix
+ description: "Configured by ansible for disallowing IPv6 networks"
+ entries:
+ - sequence: 8
+ action: deny
+ prefix: "2001:db8:2000::/35"
+ le: 37
+ state: rendered
+
+- name: Assert that correct set of commands were rendered
+ assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['rendered']) |length\
+ \ == 0 }}"
+ - result.changed == False
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml
new file mode 100644
index 0000000..fc9f5da
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/replaced.yaml
@@ -0,0 +1,57 @@
+---
+- debug:
+ msg: START vyos_prefix_lists replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace prefix-lists configurations of listed prefix-lists with provided configurations
+ register: result
+ vyos.vyos.vyos_prefix_lists: &id002
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ description: "Configuration replaced by ansible"
+ entries:
+ - sequence: 3
+ description: "Rule 3 replaced by ansible"
+ action: "permit"
+ prefix: "82.168.2.0/24"
+ ge: 26
+ state: replaced
+
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ result['before'][0] == merged['after'][0] }}"
+ - "{{ result['before'][1] == merged['after'][1] }}"
+ - "{{ result['before']|length == 2 }}"
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
+
+ - name: Assert that after dicts were correctly generated
+ assert:
+ that:
+ - "{{ replaced['after'][0] == result['after'][0] }}"
+ - "{{ replaced['after'][1] == result['after'][1] }}"
+ - "{{ result['after']|length == 2 }}"
+
+ - name: Replace prefix-lists configurations of listed prefix-lists with provided configurations (IDEMPOTENT)
+ register: result
+ vyos.vyos.vyos_prefix_lists: *id002
+
+ - name: Assert that task was idempotent
+ assert:
+ that:
+ - result['changed'] == false
+ - result.commands|length == 0
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml b/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml
new file mode 100644
index 0000000..2be2515
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/tests/cli/rtt.yaml
@@ -0,0 +1,87 @@
+---
+- debug:
+ msg: START vyos_prefix_lists round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ description: "PL configured by ansible"
+ entries:
+ - sequence: 2
+ description: "Rule 2 given by ansible"
+ action: "permit"
+ prefix: "92.168.10.0/26"
+ le: 32
+
+ - sequence: 3
+ description: "Rule 3"
+ action: "deny"
+ prefix: "72.168.2.0/24"
+ ge: 26
+
+ - afi: "ipv6"
+ prefix_lists:
+ - name: "AllowIPv6Prefix"
+ description: "Configured by ansible for allowing IPv6 networks"
+ entries:
+ - sequence: 5
+ description: "Permit rule"
+ action: "permit"
+ prefix: "2001:db8:8000::/35"
+ le: 37
+
+ - name: DenyIPv6Prefix
+ description: "Configured by ansible for disallowing IPv6 networks"
+ entries:
+ - sequence: 8
+ action: deny
+ prefix: "2001:db8:2000::/35"
+ le: 37
+ state: merged
+
+ - name: Gather prefix-lists facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - prefix_lists
+
+ - name: Update the configuration with the provided one (config to be reverted back)
+ register: result
+ vyos.vyos.vyos_prefix_lists:
+ config:
+ - afi: "ipv4"
+ prefix_lists:
+ - name: "AnsibleIPv4PrefixList"
+ description: "Configuration replaced by ansible"
+ entries:
+ - sequence: 3
+ description: "Rule 3 replaced by ansible"
+ action: "permit"
+ prefix: "82.168.2.0/24"
+ ge: 26
+ state: replaced
+
+ - name: Assert that changes were applied
+ assert:
+ that: "{{ result['after'] == replaced['after'] }}"
+
+ - name: Revert back to base config using facts round trip
+ register: revert
+ vyos.vyos.vyos_prefix_lists:
+ config: "{{ ansible_facts['network_resources']['prefix_lists'] }}"
+ state: replaced
+
+ - name: Assert that config was reverted
+ assert:
+ that: "{{ revert['after'] == base_config['after']}}"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/vars/main.yaml b/tests/integration/targets/vyos_prefix_lists/vars/main.yaml
new file mode 100644
index 0000000..3a30342
--- /dev/null
+++ b/tests/integration/targets/vyos_prefix_lists/vars/main.yaml
@@ -0,0 +1,145 @@
+---
+merged:
+ before: []
+
+ commands:
+ - set policy prefix-list6 AllowIPv6Prefix
+ - set policy prefix-list6 AllowIPv6Prefix description 'Configured by ansible for allowing IPv6 networks'
+ - set policy prefix-list6 AllowIPv6Prefix rule 5
+ - set policy prefix-list6 AllowIPv6Prefix rule 5 action 'permit'
+ - set policy prefix-list6 AllowIPv6Prefix rule 5 description 'Permit rule'
+ - set policy prefix-list6 AllowIPv6Prefix rule 5 le '37'
+ - set policy prefix-list6 AllowIPv6Prefix rule 5 prefix '2001:db8:8000::/35'
+ - set policy prefix-list6 DenyIPv6Prefix
+ - set policy prefix-list6 DenyIPv6Prefix description 'Configured by ansible for disallowing IPv6 networks'
+ - set policy prefix-list6 DenyIPv6Prefix rule 8
+ - set policy prefix-list6 DenyIPv6Prefix rule 8 action 'deny'
+ - set policy prefix-list6 DenyIPv6Prefix rule 8 le '37'
+ - set policy prefix-list6 DenyIPv6Prefix rule 8 prefix '2001:db8:2000::/35'
+ - set policy prefix-list AnsibleIPv4PrefixList
+ - set policy prefix-list AnsibleIPv4PrefixList description 'PL configured by ansible'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'permit'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given by ansible'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 le '32'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '92.168.10.0/26'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 action 'deny'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 description 'Rule 3'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 ge '26'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 prefix '72.168.2.0/24'
+
+ after:
+ - afi: ipv4
+ prefix_lists:
+ - description: PL configured by ansible
+ name: AnsibleIPv4PrefixList
+ entries:
+ - action: permit
+ description: Rule 2 given by ansible
+ sequence: 2
+ le: 32
+ prefix: 92.168.10.0/26
+ - action: deny
+ description: Rule 3
+ ge: 26
+ sequence: 3
+ prefix: 72.168.2.0/24
+ - afi: ipv6
+ prefix_lists:
+ - description: Configured by ansible for allowing IPv6 networks
+ name: AllowIPv6Prefix
+ entries:
+ - action: permit
+ description: Permit rule
+ sequence: 5
+ le: 37
+ prefix: 2001:db8:8000::/35
+ - description: Configured by ansible for disallowing IPv6 networks
+ name: DenyIPv6Prefix
+ entries:
+ - action: deny
+ sequence: 8
+ le: 37
+ prefix: 2001:db8:2000::/35
+
+replaced:
+ commands:
+ - set policy prefix-list AnsibleIPv4PrefixList description 'Configuration replaced by ansible'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 action 'permit'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 description 'Rule 3 replaced by ansible'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 3 prefix '82.168.2.0/24'
+ - delete policy prefix-list AnsibleIPv4PrefixList rule 2
+
+ after:
+ - afi: ipv4
+ prefix_lists:
+ - description: Configuration replaced by ansible
+ name: AnsibleIPv4PrefixList
+ entries:
+ - action: permit
+ description: Rule 3 replaced by ansible
+ ge: 26
+ sequence: 3
+ prefix: 82.168.2.0/24
+ - afi: ipv6
+ prefix_lists:
+ - description: Configured by ansible for allowing IPv6 networks
+ name: AllowIPv6Prefix
+ entries:
+ - action: permit
+ description: Permit rule
+ sequence: 5
+ le: 37
+ prefix: 2001:db8:8000::/35
+ - description: Configured by ansible for disallowing IPv6 networks
+ name: DenyIPv6Prefix
+ entries:
+ - action: deny
+ sequence: 8
+ le: 37
+ prefix: 2001:db8:2000::/35
+
+overridden:
+ commands:
+ - delete policy prefix-list6 AllowIPv6Prefix
+ - delete policy prefix-list6 DenyIPv6Prefix
+ - set policy prefix-list AnsibleIPv4PrefixList description 'Rule 3 overridden by ansible'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 action 'deny'
+ - delete policy prefix-list AnsibleIPv4PrefixList rule 2 description 'Rule 2 given
+ by ansible'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 ge '26'
+ - delete policy prefix-list AnsibleIPv4PrefixList rule 2 le '32'
+ - set policy prefix-list AnsibleIPv4PrefixList rule 2 prefix '82.168.2.0/24'
+ - delete policy prefix-list AnsibleIPv4PrefixList rule 3
+ - set policy prefix-list OverriddenPrefixList
+ - set policy prefix-list OverriddenPrefixList description 'Configuration overridden
+ by ansible'
+ - set policy prefix-list OverriddenPrefixList rule 10
+ - set policy prefix-list OverriddenPrefixList rule 10 action 'permit'
+ - set policy prefix-list OverriddenPrefixList rule 10 le '32'
+ - set policy prefix-list OverriddenPrefixList rule 10 prefix '203.0.113.96/27'
+
+ after:
+ - afi: ipv4
+ prefix_lists:
+ - description: Rule 3 overridden by ansible
+ name: AnsibleIPv4PrefixList
+ entries:
+ - action: deny
+ ge: 26
+ sequence: 2
+ prefix: 82.168.2.0/24
+ - description: Configuration overridden by ansible
+ name: OverriddenPrefixList
+ entries:
+ - action: permit
+ sequence: 10
+ le: 32
+ prefix: 203.0.113.96/27
+
+deleted:
+ commands:
+ - delete policy prefix-list AnsibleIPv4PrefixList
+ - delete policy prefix-list6 AllowIPv6Prefix
+ - delete policy prefix-list6 DenyIPv6Prefix