summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/overridden.yaml30
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/replaced.yaml31
-rw-r--r--tests/integration/targets/vyos_banner/tests/httpapi/rtt.yaml41
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/overridden.yaml32
-rw-r--r--tests/integration/targets/vyos_hostname/tests/httpapi/rtt.yaml48
-rw-r--r--tests/integration/targets/vyos_interfaces/aliases (renamed from tests/integration/targets/vyos_prefix_lists/aliases)0
-rw-r--r--tests/integration/targets/vyos_interfaces/defaults/main.yaml (renamed from tests/integration/targets/vyos_prefix_lists/defaults/main.yaml)0
-rw-r--r--tests/integration/targets/vyos_interfaces/tasks/httpapi.yaml (renamed from tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml)0
-rw-r--r--tests/integration/targets/vyos_interfaces/tasks/main.yaml (renamed from tests/integration/targets/vyos_prefix_lists/tasks/main.yaml)0
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/httpapi/_populate_config.yaml9
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/httpapi/_remove_config.yaml7
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/httpapi/deleted.yaml30
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/httpapi/gathered.yaml21
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/httpapi/merged.yaml32
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/httpapi/replaced.yaml33
-rw-r--r--tests/integration/targets/vyos_interfaces/vars/main.yaml (renamed from tests/integration/targets/vyos_prefix_lists/vars/main.yaml)0
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/aliases1
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_populate_config.yaml15
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_remove_config.yaml10
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/deleted.yaml33
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/gathered.yaml21
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/merged.yaml33
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/overridden.yaml35
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/replaced.yaml33
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/httpapi/rtt.yaml48
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/aliases1
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_populate_config.yaml13
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/gathered.yaml21
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/merged.yaml36
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/overridden.yaml32
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/replaced.yaml37
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/httpapi/rtt.yaml56
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/overridden.yaml34
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/httpapi/rtt.yaml53
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/aliases1
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_populate_config.yaml16
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/deleted.yaml28
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/gathered.yaml21
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/merged.yaml48
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/overridden.yaml32
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/replaced.yaml34
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/rtt.yaml55
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml6
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/overridden.yaml37
-rw-r--r--tests/integration/targets/vyos_logging_global/tests/httpapi/rtt.yaml58
-rw-r--r--tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml65
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/aliases1
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_populate_config.yaml19
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/deleted.yaml40
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/gathered.yaml20
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/merged.yaml44
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/overridden.yaml33
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/replaced.yaml35
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/rtt.yaml66
-rw-r--r--tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_ospfv2/aliases1
-rw-r--r--tests/integration/targets/vyos_ospfv2/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_ospfv2/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_ospfv2/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/_populate_config.yaml34
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/deleted.yaml29
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/gathered.yaml22
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/merged.yaml56
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/overridden.yaml37
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/replaced.yaml37
-rw-r--r--tests/integration/targets/vyos_ospfv2/tests/httpapi/rtt.yaml61
-rw-r--r--tests/integration/targets/vyos_ospfv2/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_ospfv3/aliases1
-rw-r--r--tests/integration/targets/vyos_ospfv3/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_ospfv3/tasks/httpapi.yaml21
-rw-r--r--tests/integration/targets/vyos_ospfv3/tasks/main.yaml5
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/_populate_config.yaml17
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/deleted.yaml29
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/gathered.yaml21
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/merged.yaml48
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/overridden.yaml35
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/replaced.yaml35
-rw-r--r--tests/integration/targets/vyos_ospfv3/tests/httpapi/rtt.yaml60
-rw-r--r--tests/integration/targets/vyos_ospfv3/vars/main.yaml2
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml28
-rw-r--r--tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml5
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/overridden.yaml40
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml53
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/overridden.yaml35
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml53
106 files changed, 2422 insertions, 39 deletions
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..f80add0
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/overridden.yaml
@@ -0,0 +1,30 @@
+---
+- debug:
+ msg: START vyos_hostname overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override hostname configuration
+ register: result
+ vyos.rest.vyos_hostname: &id001
+ config:
+ hostname: ansible-overridden-host
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override hostname configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_hostname: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..2dddc90
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/replaced.yaml
@@ -0,0 +1,31 @@
+---
+- debug:
+ msg: START vyos_banner replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace pre-login banner
+ register: result
+ vyos.rest.vyos_banner: &id001
+ config:
+ banner: pre-login
+ text: "Replaced by ansible"
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace pre-login banner (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_banner: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_banner/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_banner/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..233f1ef
--- /dev/null
+++ b/tests/integration/targets/vyos_banner/tests/httpapi/rtt.yaml
@@ -0,0 +1,41 @@
+---
+- debug:
+ msg: START vyos_hostname round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_hostname:
+ config:
+ hostname: ansible-rtt-host
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_hostname:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered.hostname == "ansible-rtt-host"
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_hostname:
+ config:
+ hostname: ansible-rtt-modified
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_hostname:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered.hostname == "ansible-rtt-modified"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..671ac41
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/overridden.yaml
@@ -0,0 +1,32 @@
+---
+- debug:
+ msg: START vyos_interfaces overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override interface configuration
+ register: result
+ vyos.rest.vyos_interfaces: &id001
+ config:
+ - name: eth0
+ description: Ansible overridden interface
+ mtu: 1400
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_hostname/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_hostname/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..74261f8
--- /dev/null
+++ b/tests/integration/targets/vyos_hostname/tests/httpapi/rtt.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_interfaces:
+ config:
+ - name: eth0
+ description: Ansible RTT interface
+ mtu: 1450
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_interfaces:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered | selectattr('name', 'eq', 'eth0') | list | length == 1
+ - gathered.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='description') | first == 'Ansible RTT interface'
+ - gathered.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='mtu') | first == 1450
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_interfaces:
+ config:
+ - name: eth0
+ description: Ansible RTT modified
+ mtu: 1400
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_interfaces:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='description') | first == 'Ansible RTT modified'
+ - gathered2.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='mtu') | first == 1400
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/aliases b/tests/integration/targets/vyos_interfaces/aliases
index cc0afef..cc0afef 100644
--- a/tests/integration/targets/vyos_prefix_lists/aliases
+++ b/tests/integration/targets/vyos_interfaces/aliases
diff --git a/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml b/tests/integration/targets/vyos_interfaces/defaults/main.yaml
index 164afea..164afea 100644
--- a/tests/integration/targets/vyos_prefix_lists/defaults/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/defaults/main.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml b/tests/integration/targets/vyos_interfaces/tasks/httpapi.yaml
index 4147e6d..4147e6d 100644
--- a/tests/integration/targets/vyos_prefix_lists/tasks/httpapi.yaml
+++ b/tests/integration/targets/vyos_interfaces/tasks/httpapi.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml b/tests/integration/targets/vyos_interfaces/tasks/main.yaml
index b1f6193..b1f6193 100644
--- a/tests/integration/targets/vyos_prefix_lists/tasks/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/tasks/main.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_interfaces/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..9562fce
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Populate interface config for testing
+ vyos.rest.vyos_interfaces:
+ config:
+ - name: eth0
+ description: Ansible test interface
+ mtu: 1450
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_interfaces/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_interfaces/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..4014e56
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Remove interface L2 config
+ vyos.rest.vyos_interfaces:
+ config:
+ - name: eth0
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_interfaces/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..e8dfd06
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/httpapi/deleted.yaml
@@ -0,0 +1,30 @@
+---
+- debug:
+ msg: START vyos_interfaces deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete interface configuration
+ register: result
+ vyos.rest.vyos_interfaces: &id001
+ config:
+ - name: eth0
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..022e21e
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/httpapi/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- debug:
+ msg: START vyos_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather interface configuration
+ register: result
+ vyos.rest.vyos_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('name', 'eq', 'eth0') | list | length == 1
+ - result.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='description') | first == 'Ansible test interface'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_interfaces/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..b5a82ef
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/httpapi/merged.yaml
@@ -0,0 +1,32 @@
+---
+- debug:
+ msg: START vyos_interfaces merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge interface configuration
+ register: result
+ vyos.rest.vyos_interfaces: &id001
+ config:
+ - name: eth0
+ description: Ansible test interface
+ mtu: 1450
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_interfaces/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..430b441
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/httpapi/replaced.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_interfaces replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace interface configuration
+ register: result
+ vyos.rest.vyos_interfaces: &id001
+ config:
+ - name: eth0
+ description: Ansible replaced interface
+ mtu: 1400
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_prefix_lists/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml
index 4303881..4303881 100644
--- a/tests/integration/targets/vyos_prefix_lists/vars/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/aliases b/tests/integration/targets/vyos_l3_interfaces/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_l3_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_l3_interfaces/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..af425ae
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,15 @@
+---
+- name: Populate L3 interface config for testing
+ vyos.rest.vyos_l3_interfaces:
+ config:
+ - name: lo
+ ipv4:
+ - address: 10.0.0.1/32
+ - address: 10.0.0.2/32
+ - name: eth0
+ vifs:
+ - vlan_id: 100
+ ipv4:
+ - address: 192.0.2.100/24
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..44453c3
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,10 @@
+---
+- name: Remove test L3 config
+ vyos.rest.vyos_l3_interfaces:
+ config:
+ - name: lo
+ - name: eth0
+ vifs:
+ - vlan_id: 100
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..a583354
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/deleted.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete L3 interface configuration
+ register: result
+ vyos.rest.vyos_l3_interfaces: &id001
+ config:
+ - name: lo
+ - name: eth0
+ vifs:
+ - vlan_id: 100
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete L3 interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_l3_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..cfd380a
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather L3 interface configuration
+ register: result
+ vyos.rest.vyos_l3_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('name', 'eq', 'lo') | list | length == 1
+ - result.gathered | selectattr('name', 'eq', 'lo') | map(attribute='ipv4') | first | length == 2
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..eabd97b
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/merged.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge L3 interface configuration
+ register: result
+ vyos.rest.vyos_l3_interfaces: &id001
+ config:
+ - name: lo
+ ipv4:
+ - address: 10.0.0.1/32
+ - address: 10.0.0.2/32
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge L3 interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_l3_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..09d72ae
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/overridden.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override L3 interface configuration
+ register: result
+ vyos.rest.vyos_l3_interfaces: &id001
+ config:
+ - name: eth0
+ ipv4:
+ - address: dhcp
+ - name: lo
+ ipv4:
+ - address: 10.0.0.1/32
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override L3 interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_l3_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..e193ced
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/replaced.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace L3 interface configuration
+ register: result
+ vyos.rest.vyos_l3_interfaces: &id001
+ config:
+ - name: lo
+ ipv4:
+ - address: 10.0.0.1/32
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace L3 interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_l3_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..c347f1a
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/httpapi/rtt.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_l3_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_l3_interfaces:
+ config:
+ - name: lo
+ ipv4:
+ - address: 10.0.0.1/32
+ - address: 10.0.0.2/32
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_l3_interfaces:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered | selectattr('name', 'eq', 'lo') | list | length == 1
+ - gathered.gathered | selectattr('name', 'eq', 'lo') | map(attribute='ipv4') | first | length == 2
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_l3_interfaces:
+ config:
+ - name: lo
+ ipv4:
+ - address: 10.0.0.1/32
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_l3_interfaces:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered | selectattr('name', 'eq', 'lo') | map(attribute='ipv4') | first | length == 1
+ - gathered2.gathered | selectattr('name', 'eq', 'lo') | map(attribute='ipv4') | first | map(attribute='address') | first == '10.0.0.1/32'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_lag_interfaces/aliases b/tests/integration/targets/vyos_lag_interfaces/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_lag_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_lag_interfaces/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..c21a3e6
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,13 @@
+---
+- name: Populate LAG config for testing
+ vyos.rest.vyos_lag_interfaces:
+ config:
+ - name: bond0
+ mode: active-backup
+ hash_policy: layer2
+ arp_monitor:
+ interval: 100
+ target:
+ - 192.0.2.1
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..f2dab9d
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing LAG config
+ vyos.rest.vyos_lag_interfaces:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..c7959ec
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete all LAG configuration
+ register: result
+ vyos.rest.vyos_lag_interfaces: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete LAG configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lag_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..7bf3a6e
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather LAG configuration
+ register: result
+ vyos.rest.vyos_lag_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('name', 'eq', 'bond0') | list | length == 1
+ - result.gathered | selectattr('name', 'eq', 'bond0') | map(attribute='mode') | first == 'active-backup'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..8bda2ee
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/merged.yaml
@@ -0,0 +1,36 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge LAG configuration
+ register: result
+ vyos.rest.vyos_lag_interfaces: &id001
+ config:
+ - name: bond0
+ mode: active-backup
+ hash_policy: layer2
+ arp_monitor:
+ interval: 100
+ target:
+ - 192.0.2.1
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge LAG configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lag_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..3024d71
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/overridden.yaml
@@ -0,0 +1,32 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override LAG configuration
+ register: result
+ vyos.rest.vyos_lag_interfaces: &id001
+ config:
+ - name: bond0
+ mode: active-backup
+ hash_policy: layer2+3
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override LAG configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lag_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..e8eb972
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/replaced.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace LAG configuration
+ register: result
+ vyos.rest.vyos_lag_interfaces: &id001
+ config:
+ - name: bond0
+ mode: active-backup
+ hash_policy: layer2+3
+ arp_monitor:
+ interval: 200
+ target:
+ - 192.0.2.2
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace LAG configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lag_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..4e58069
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/httpapi/rtt.yaml
@@ -0,0 +1,56 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_lag_interfaces:
+ config:
+ - name: bond0
+ mode: active-backup
+ hash_policy: layer2
+ arp_monitor:
+ interval: 100
+ target:
+ - 192.0.2.1
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_lag_interfaces:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered | selectattr('name', 'eq', 'bond0') | list | length == 1
+ - gathered.gathered | selectattr('name', 'eq', 'bond0') | map(attribute='mode') | first == 'active-backup'
+ - gathered.gathered | selectattr('name', 'eq', 'bond0') | map(attribute='hash_policy') | first == 'layer2'
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_lag_interfaces:
+ config:
+ - name: bond0
+ mode: active-backup
+ hash_policy: layer2+3
+ arp_monitor:
+ interval: 200
+ target:
+ - 192.0.2.2
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_lag_interfaces:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered | selectattr('name', 'eq', 'bond0') | map(attribute='hash_policy') | first == 'layer2+3'
+ - gathered2.gathered | selectattr('name', 'eq', 'bond0') | map(attribute='arp_monitor') | map(attribute='interval') | first == 200
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml b/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..8f85df5
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/overridden.yaml
@@ -0,0 +1,34 @@
+---
+- debug:
+ msg: START vyos_lldp_global overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override LLDP global configuration
+ register: result
+ vyos.rest.vyos_lldp_global: &id001
+ config:
+ enable: true
+ addresses:
+ - 192.0.2.20
+ legacy_protocols:
+ - cdp
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override LLDP global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_global: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_lldp_global/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..421f966
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/httpapi/rtt.yaml
@@ -0,0 +1,53 @@
+---
+- debug:
+ msg: START vyos_lldp_global round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_lldp_global:
+ config:
+ enable: true
+ addresses:
+ - 192.0.2.17
+ legacy_protocols:
+ - cdp
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_lldp_global:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered.enable == true
+ - "'192.0.2.17' in gathered.gathered.addresses"
+ - "'cdp' in gathered.gathered.legacy_protocols"
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_lldp_global:
+ config:
+ enable: true
+ addresses:
+ - 192.0.2.20
+ legacy_protocols:
+ - fdp
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_lldp_global:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - "'192.0.2.20' in gathered2.gathered.addresses"
+ - "'fdp' in gathered2.gathered.legacy_protocols"
+ - "'cdp' not in gathered2.gathered.legacy_protocols"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/aliases b/tests/integration/targets/vyos_lldp_interfaces/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_lldp_interfaces/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..f7f27b0
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,16 @@
+---
+- name: Ensure LLDP service is enabled
+ vyos.rest.vyos_configure:
+ commands:
+ - "set service lldp"
+ ignore_errors: true
+
+- name: Populate LLDP interface config for testing
+ vyos.rest.vyos_lldp_interfaces:
+ config:
+ - name: eth0
+ mode: disable
+ location:
+ elin: "1234567890"
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..8612bd7
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove LLDP interface config
+ vyos.rest.vyos_lldp_interfaces:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..cd432bb
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/deleted.yaml
@@ -0,0 +1,28 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete LLDP interface configuration
+ register: result
+ vyos.rest.vyos_lldp_interfaces: &id001
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete LLDP interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..590fe01
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather LLDP interface configuration
+ register: result
+ vyos.rest.vyos_lldp_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.gathered | selectattr('name', 'eq', 'eth0') | list | length == 1
+ - result.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='mode') | first == 'disable'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..636157a
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/merged.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Merge LLDP interface configuration
+ register: result
+ vyos.rest.vyos_lldp_interfaces: &id001
+ config:
+ - name: eth0
+ mode: disable
+ location:
+ elin: "1234567890"
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+
+ - name: Merge LLDP interface — add elin change
+ register: result
+ vyos.rest.vyos_lldp_interfaces: &id002
+ config:
+ - name: eth0
+ mode: disable
+ location:
+ elin: "0000000911"
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge LLDP interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_interfaces: *id002
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..4bc0a94
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/overridden.yaml
@@ -0,0 +1,32 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override LLDP interface configuration
+ register: result
+ vyos.rest.vyos_lldp_interfaces: &id001
+ config:
+ - name: eth0
+ mode: rx-tx
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override LLDP interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..bc9542b
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/replaced.yaml
@@ -0,0 +1,34 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace LLDP interface configuration
+ register: result
+ vyos.rest.vyos_lldp_interfaces: &id001
+ config:
+ - name: eth0
+ mode: rx-tx
+ location:
+ elin: "9876543210"
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace LLDP interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_lldp_interfaces: *id001
+
+ - name: Assert idempotent
+ assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..44ad3c7
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/httpapi/rtt.yaml
@@ -0,0 +1,55 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Ensure LLDP service is enabled
+ vyos.rest.vyos_configure:
+ commands:
+ - "set service lldp"
+
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_lldp_interfaces:
+ config:
+ - name: eth0
+ mode: disable
+ location:
+ elin: "1234567890"
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_lldp_interfaces:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered | selectattr('name', 'eq', 'eth0') | list | length == 1
+ - gathered.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='mode') | first == 'disable'
+ - gathered.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='location') | map(attribute='elin') | first == '1234567890'
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_lldp_interfaces:
+ config:
+ - name: eth0
+ mode: rx-tx
+ location:
+ elin: "9876543210"
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_lldp_interfaces:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='mode') | first == 'rx-tx'
+ - gathered2.gathered | selectattr('name', 'eq', 'eth0') | map(attribute='location') | map(attribute='elin') | first == '9876543210'
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml
index c081853..548038d 100644
--- a/tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/_populate_config.yaml
@@ -6,12 +6,6 @@
facilities:
- facility: local7
severity: err
- hosts:
- - hostname: 172.16.0.1
- port: 514
- facilities:
- - facility: local7
- severity: all
global_params:
facilities:
- facility: cron
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..76867cc
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/overridden.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_logging_global overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override logging_global configuration
+ register: result
+ vyos.rest.vyos_logging_global: &id001
+ config:
+ console:
+ facilities:
+ - facility: local7
+ severity: warning
+ global_params:
+ facilities:
+ - facility: cron
+ severity: debug
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override logging_global configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_logging_global: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_logging_global/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_logging_global/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..8bea580
--- /dev/null
+++ b/tests/integration/targets/vyos_logging_global/tests/httpapi/rtt.yaml
@@ -0,0 +1,58 @@
+---
+- debug:
+ msg: START vyos_logging_global round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_logging_global:
+ config:
+ console:
+ facilities:
+ - facility: local7
+ severity: err
+ global_params:
+ facilities:
+ - facility: cron
+ severity: debug
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_logging_global:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered.console is defined
+ - gathered.gathered.global is defined
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_logging_global:
+ config:
+ console:
+ facilities:
+ - facility: local7
+ severity: warning
+ global_params:
+ facilities:
+ - facility: cron
+ severity: info
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_logging_global:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered.console is defined
+ - gathered2.gathered.global is defined
+ - gathered2.gathered.global.facilities.cron == "info"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..d05e203
--- /dev/null
+++ b/tests/integration/targets/vyos_ntp_global/tests/httpapi/rtt.yaml
@@ -0,0 +1,65 @@
+---
+- debug:
+ msg: START vyos_ntp_global round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_ntp_global:
+ config:
+ servers:
+ - server: 10.3.6.5
+ options:
+ - noselect
+ - prefer
+ - server: server4.example.com
+ options:
+ - pool
+ allow_clients:
+ - 10.4.9.0/24
+ listen_addresses:
+ - 10.1.9.16
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_ntp_global:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - "'10.3.6.5' in gathered.gathered.servers"
+ - "'10.4.9.0/24' in gathered.gathered.allow_clients"
+ - "'10.1.9.16' in gathered.gathered.listen_addresses"
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_ntp_global:
+ config:
+ servers:
+ - server: 10.3.6.5
+ options:
+ - noselect
+ - server: server5.example.com
+ allow_clients:
+ - 10.4.8.0/24
+ listen_addresses:
+ - 10.1.9.16
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_ntp_global:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - "'server5.example.com' in gathered2.gathered.servers"
+ - "'server4.example.com' not in gathered2.gathered.servers"
+ - "'10.4.8.0/24' in gathered2.gathered.allow_clients"
+ - "'10.4.9.0/24' not in gathered2.gathered.allow_clients"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/aliases b/tests/integration/targets/vyos_ospf_interfaces/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml b/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..cee0e3e
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,19 @@
+---
+- name: Populate ospf_interfaces config for testing
+ vyos.rest.vyos_ospf_interfaces:
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 100
+ transmit_delay: 50
+ priority: 26
+ - afi: ipv6
+ dead_interval: 39
+ passive: true
+ - name: eth2
+ address_family:
+ - afi: ipv4
+ cost: 200
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..ed1b31b
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing ospf_interfaces config
+ vyos.rest.vyos_ospf_interfaces:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..09ce0de
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/deleted.yaml
@@ -0,0 +1,40 @@
+---
+- debug:
+ msg: START vyos_ospf_interfaces deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete specific interface OSPF configuration
+ register: result
+ vyos.rest.vyos_ospf_interfaces:
+ config:
+ - name: eth1
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete all OSPF interface configuration
+ register: result
+ vyos.rest.vyos_ospf_interfaces:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete all OSPF interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospf_interfaces:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..13eaa25
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- debug:
+ msg: START vyos_ospf_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather OSPF interface configuration
+ register: result
+ vyos.rest.vyos_ospf_interfaces:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered | selectattr('name', 'eq', 'eth1') | list | length == 1
+ - result.gathered | selectattr('name', 'eq', 'eth2') | list | length == 1
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..f9fcd27
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/merged.yaml
@@ -0,0 +1,44 @@
+---
+- debug:
+ msg: START vyos_ospf_interfaces merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge OSPF interface configuration
+ register: result
+ vyos.rest.vyos_ospf_interfaces:
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 100
+ transmit_delay: 50
+ - afi: ipv6
+ dead_interval: 39
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge OSPF interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospf_interfaces:
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 100
+ transmit_delay: 50
+ - afi: ipv6
+ dead_interval: 39
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..9a57bf7
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/overridden.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_ospf_interfaces overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override OSPF interface configuration
+ register: result
+ vyos.rest.vyos_ospf_interfaces: &id001
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 300
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override OSPF interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospf_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..359c647
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/replaced.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_ospf_interfaces replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace OSPF interface configuration
+ register: result
+ vyos.rest.vyos_ospf_interfaces: &id001
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 200
+ - afi: ipv6
+ passive: true
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace OSPF interface configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospf_interfaces: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..1997870
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/tests/httpapi/rtt.yaml
@@ -0,0 +1,66 @@
+---
+- debug:
+ msg: START vyos_ospf_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_ospf_interfaces:
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 100
+ transmit_delay: 50
+ - afi: ipv6
+ dead_interval: 39
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_ospf_interfaces:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ vars:
+ eth1_afs: >-
+ {{ gathered.gathered
+ | selectattr('name', 'eq', 'eth1')
+ | map(attribute='address_family')
+ | first }}
+ assert:
+ that:
+ - gathered.gathered | selectattr('name', 'eq', 'eth1') | list | length == 1
+ - eth1_afs | selectattr('afi', 'eq', 'ipv4') | map(attribute='cost') | first == 100
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_ospf_interfaces:
+ config:
+ - name: eth1
+ address_family:
+ - afi: ipv4
+ cost: 200
+ - afi: ipv6
+ passive: true
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_ospf_interfaces:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ vars:
+ eth1_afs2: >-
+ {{ gathered2.gathered
+ | selectattr('name', 'eq', 'eth1')
+ | map(attribute='address_family')
+ | first }}
+ assert:
+ that:
+ - eth1_afs2 | selectattr('afi', 'eq', 'ipv4') | map(attribute='cost') | first == 200
+ - eth1_afs2 | selectattr('afi', 'eq', 'ipv6') | map(attribute='passive') | first == true
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_ospf_interfaces/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_ospfv2/aliases b/tests/integration/targets/vyos_ospfv2/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_ospfv2/defaults/main.yaml b/tests/integration/targets/vyos_ospfv2/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_ospfv2/tasks/httpapi.yaml b/tests/integration/targets/vyos_ospfv2/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_ospfv2/tasks/main.yaml b/tests/integration/targets/vyos_ospfv2/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..67aa729
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,34 @@
+---
+- name: Populate ospfv2 config for testing
+ vyos.rest.vyos_ospfv2:
+ config:
+ parameters:
+ router_id: 192.0.1.1
+ abr_type: cisco
+ auto_cost:
+ reference_bandwidth: 2
+ log_adjacency_changes: detail
+ redistribute:
+ - route_type: bgp
+ metric: 10
+ passive_interface:
+ - eth1
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ - area_id: "3"
+ area_type:
+ nssa:
+ set: true
+ - area_id: "4"
+ area_type:
+ stub:
+ default_cost: 20
+ range:
+ - address: 192.0.3.0/24
+ cost: 10
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..171ab62
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing ospfv2 config
+ vyos.rest.vyos_ospfv2:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..f656d4a
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/deleted.yaml
@@ -0,0 +1,29 @@
+---
+- debug:
+ msg: START vyos_ospfv2 deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete OSPFv2 configuration
+ register: result
+ vyos.rest.vyos_ospfv2:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete OSPFv2 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv2:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..9b06985
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/gathered.yaml
@@ -0,0 +1,22 @@
+---
+- debug:
+ msg: START vyos_ospfv2 gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather OSPFv2 configuration
+ register: result
+ vyos.rest.vyos_ospfv2:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.parameters.router_id == "192.0.1.1"
+ - result.gathered.areas | selectattr('area_id', 'eq', '2') | list | length == 1
+ - result.gathered.redistribute | selectattr('route_type', 'eq', 'bgp') | list | length == 1
+ - "'eth1' in result.gathered.passive_interface"
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..db07c48
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/merged.yaml
@@ -0,0 +1,56 @@
+---
+- debug:
+ msg: START vyos_ospfv2 merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge OSPFv2 configuration
+ register: result
+ vyos.rest.vyos_ospfv2:
+ config:
+ parameters:
+ router_id: 192.0.1.1
+ auto_cost:
+ reference_bandwidth: 2
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ redistribute:
+ - route_type: bgp
+ metric: 10
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge OSPFv2 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv2:
+ config:
+ parameters:
+ router_id: 192.0.1.1
+ auto_cost:
+ reference_bandwidth: 2
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ redistribute:
+ - route_type: bgp
+ metric: 10
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..a364c0f
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/overridden.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_ospfv2 overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override OSPFv2 configuration
+ register: result
+ vyos.rest.vyos_ospfv2: &id001
+ config:
+ parameters:
+ router_id: 192.0.1.2
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override OSPFv2 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv2: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..7a58000
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/replaced.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_ospfv2 replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace OSPFv2 configuration
+ register: result
+ vyos.rest.vyos_ospfv2: &id001
+ config:
+ parameters:
+ router_id: 192.0.1.2
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace OSPFv2 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv2: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv2/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_ospfv2/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..be2a3c9
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/tests/httpapi/rtt.yaml
@@ -0,0 +1,61 @@
+---
+- debug:
+ msg: START vyos_ospfv2 round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_ospfv2:
+ config:
+ parameters:
+ router_id: 192.0.1.1
+ redistribute:
+ - route_type: bgp
+ metric: 10
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_ospfv2:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered.parameters.router_id == "192.0.1.1"
+ - gathered.gathered.areas | selectattr('area_id', 'eq', '2') | list | length == 1
+ - gathered.gathered.redistribute | selectattr('route_type', 'eq', 'bgp') | list | length == 1
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_ospfv2:
+ config:
+ parameters:
+ router_id: 192.0.1.2
+ areas:
+ - area_id: "2"
+ area_type:
+ normal: true
+ network:
+ - address: 192.0.2.0/24
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_ospfv2:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered.parameters.router_id == "192.0.1.2"
+ - gathered2.gathered.redistribute is not defined or gathered2.gathered.redistribute | length == 0
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv2/vars/main.yaml b/tests/integration/targets/vyos_ospfv2/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv2/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_ospfv3/aliases b/tests/integration/targets/vyos_ospfv3/aliases
new file mode 100644
index 0000000..cc0afef
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/aliases
@@ -0,0 +1 @@
+network/vyos
diff --git a/tests/integration/targets/vyos_ospfv3/defaults/main.yaml b/tests/integration/targets/vyos_ospfv3/defaults/main.yaml
new file mode 100644
index 0000000..164afea
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/tests/integration/targets/vyos_ospfv3/tasks/httpapi.yaml b/tests/integration/targets/vyos_ospfv3/tasks/httpapi.yaml
new file mode 100644
index 0000000..4147e6d
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tasks/httpapi.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all httpapi test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/httpapi"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=httpapi)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.httpapi
+ ansible_network_os: vyos.rest.vyos
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_ospfv3/tasks/main.yaml b/tests/integration/targets/vyos_ospfv3/tasks/main.yaml
new file mode 100644
index 0000000..b1f6193
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Run httpapi tests
+ ansible.builtin.include_tasks: httpapi.yaml
+ tags:
+ - httpapi
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/_populate_config.yaml
new file mode 100644
index 0000000..19a61c7
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/_populate_config.yaml
@@ -0,0 +1,17 @@
+---
+- name: Populate ospfv3 config for testing
+ vyos.rest.vyos_ospfv3:
+ config:
+ parameters:
+ router_id: 192.0.2.10
+ redistribute:
+ - route_type: bgp
+ areas:
+ - area_id: "2"
+ export_list: export1
+ import_list: import1
+ range:
+ - address: "2001:db10::/32"
+ - address: "2001:db20::/32"
+ state: merged
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/_remove_config.yaml
new file mode 100644
index 0000000..fe60eaf
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove pre-existing ospfv3 config
+ vyos.rest.vyos_ospfv3:
+ state: deleted
+ ignore_errors: true
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/deleted.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/deleted.yaml
new file mode 100644
index 0000000..9b09ccd
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/deleted.yaml
@@ -0,0 +1,29 @@
+---
+- debug:
+ msg: START vyos_ospfv3 deleted integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete OSPFv3 configuration
+ register: result
+ vyos.rest.vyos_ospfv3:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Delete OSPFv3 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv3:
+ state: deleted
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/gathered.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/gathered.yaml
new file mode 100644
index 0000000..bf2cc0c
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- debug:
+ msg: START vyos_ospfv3 gathered integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather OSPFv3 configuration
+ register: result
+ vyos.rest.vyos_ospfv3:
+ state: gathered
+
+ - assert:
+ that:
+ - result.gathered.parameters.router_id == "192.0.2.10"
+ - result.gathered.redistribute | selectattr('route_type', 'eq', 'bgp') | list | length == 1
+ - result.gathered.areas | selectattr('area_id', 'eq', '2') | list | length == 1
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/merged.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/merged.yaml
new file mode 100644
index 0000000..10702e4
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/merged.yaml
@@ -0,0 +1,48 @@
+---
+- debug:
+ msg: START vyos_ospfv3 merged integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge OSPFv3 configuration
+ register: result
+ vyos.rest.vyos_ospfv3:
+ config:
+ parameters:
+ router_id: 192.0.2.10
+ redistribute:
+ - route_type: bgp
+ areas:
+ - area_id: "2"
+ export_list: export1
+ range:
+ - address: "2001:db10::/32"
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Merge OSPFv3 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv3:
+ config:
+ parameters:
+ router_id: 192.0.2.10
+ redistribute:
+ - route_type: bgp
+ areas:
+ - area_id: "2"
+ export_list: export1
+ range:
+ - address: "2001:db10::/32"
+ state: merged
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..609e7ff
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/overridden.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_ospfv3 overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override OSPFv3 configuration
+ register: result
+ vyos.rest.vyos_ospfv3: &id001
+ config:
+ parameters:
+ router_id: 192.0.2.11
+ areas:
+ - area_id: "3"
+ range:
+ - address: "2001:db40::/32"
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override OSPFv3 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv3: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/replaced.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/replaced.yaml
new file mode 100644
index 0000000..3f1be83
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/replaced.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_ospfv3 replaced integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replace OSPFv3 configuration
+ register: result
+ vyos.rest.vyos_ospfv3: &id001
+ config:
+ parameters:
+ router_id: 192.0.2.11
+ areas:
+ - area_id: "3"
+ range:
+ - address: "2001:db40::/32"
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Replace OSPFv3 configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_ospfv3: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv3/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_ospfv3/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..7636c23
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/tests/httpapi/rtt.yaml
@@ -0,0 +1,60 @@
+---
+- debug:
+ msg: START vyos_ospfv3 round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_ospfv3:
+ config:
+ parameters:
+ router_id: 192.0.2.10
+ redistribute:
+ - route_type: bgp
+ areas:
+ - area_id: "2"
+ export_list: export1
+ range:
+ - address: "2001:db10::/32"
+ - address: "2001:db20::/32"
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_ospfv3:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered.parameters.router_id == "192.0.2.10"
+ - "'bgp' in gathered.gathered.redistribute | map(attribute='route_type') | list"
+ - gathered.gathered.areas | selectattr('area_id', 'eq', '2') | list | length == 1
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_ospfv3:
+ config:
+ parameters:
+ router_id: 192.0.2.11
+ areas:
+ - area_id: "2"
+ export_list: export1
+ range:
+ - address: "2001:db10::/32"
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_ospfv3:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered.parameters.router_id == "192.0.2.11"
+ - gathered2.gathered.redistribute is not defined or gathered2.gathered.redistribute | length == 0
+ - gathered2.gathered.areas | selectattr('area_id', 'eq', '2') | map(attribute='range') | first | length == 1
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_ospfv3/vars/main.yaml b/tests/integration/targets/vyos_ospfv3/vars/main.yaml
new file mode 100644
index 0000000..4303881
--- /dev/null
+++ b/tests/integration/targets/vyos_ospfv3/vars/main.yaml
@@ -0,0 +1,2 @@
+---
+# only common vars here
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml
deleted file mode 100644
index 9d73f0b..0000000
--- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_populate_config.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
----
-- name: Populate prefix_lists config for testing
- vyos.rest.vyos_prefix_lists:
- config:
- - afi: ipv4
- prefix_lists:
- - name: AnsibleIPv4PrefixList
- description: PL configured by ansible
- entries:
- - sequence: 2
- action: permit
- prefix: 92.168.10.0/26
- le: 32
- - sequence: 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
- action: permit
- prefix: 2001:db8:8000::/35
- le: 37
- state: merged
- ignore_errors: true
diff --git a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml b/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml
deleted file mode 100644
index 043fb3e..0000000
--- a/tests/integration/targets/vyos_prefix_lists/tests/httpapi/_remove_config.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-- name: Remove pre-existing prefix_lists config
- vyos.rest.vyos_prefix_lists:
- state: deleted
- ignore_errors: true
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..cbe3908
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/overridden.yaml
@@ -0,0 +1,40 @@
+---
+- debug:
+ msg: START vyos_route_maps overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override route_maps configuration
+ register: result
+ vyos.rest.vyos_route_maps: &id001
+ config:
+ - route_map: RM-TEST-EXPORT-POLICY
+ entries:
+ - sequence: 10
+ action: permit
+ match:
+ peer: 192.0.2.32
+ set:
+ metric: "10"
+ as_path_exclude: "111"
+ aggregator:
+ as: 100
+ state: overridden
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override route_maps configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_route_maps: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..641a46f
--- /dev/null
+++ b/tests/integration/targets/vyos_route_maps/tests/httpapi/rtt.yaml
@@ -0,0 +1,53 @@
+---
+- debug:
+ msg: START vyos_route_maps round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_route_maps:
+ config:
+ - route_map: RM-TEST-EXPORT-POLICY
+ entries:
+ - sequence: 10
+ action: permit
+ match:
+ peer: 192.0.2.32
+ set:
+ metric: "5"
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_route_maps:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | list | length == 1
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_route_maps:
+ config:
+ - route_map: RM-TEST-EXPORT-POLICY
+ entries:
+ - sequence: 10
+ action: permit
+ set:
+ metric: "20"
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_route_maps:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered | selectattr('route_map', 'eq', 'RM-TEST-EXPORT-POLICY') | list | length == 1
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/overridden.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/overridden.yaml
new file mode 100644
index 0000000..61a3311
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/overridden.yaml
@@ -0,0 +1,35 @@
+---
+- debug:
+ msg: START vyos_snmp_server overridden integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+- include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override snmp_server configuration
+ register: result
+ vyos.rest.vyos_snmp_server: &id001
+ config:
+ communities:
+ - name: switches
+ authorization_type: rw
+ contact: admin@example.com
+ listen_addresses:
+ - address: 20.1.1.1
+ state: replaced
+
+ - assert:
+ that:
+ - result.changed == true
+
+ - name: Override snmp_server configuration (IDEMPOTENT)
+ register: result
+ vyos.rest.vyos_snmp_server: *id001
+
+ - assert:
+ that:
+ - result.changed == false
+ - result.commands == []
+
+ always:
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml b/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml
new file mode 100644
index 0000000..1d354b7
--- /dev/null
+++ b/tests/integration/targets/vyos_snmp_server/tests/httpapi/rtt.yaml
@@ -0,0 +1,53 @@
+---
+- debug:
+ msg: START vyos_snmp_server round trip integration tests on connection={{ ansible_connection }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+ - name: RTT - Apply base configuration
+ vyos.rest.vyos_snmp_server:
+ config:
+ communities:
+ - name: switches
+ authorization_type: rw
+ contact: admin@example.com
+ listen_addresses:
+ - address: 20.1.1.1
+ state: merged
+
+ - name: RTT - Gather configuration
+ register: gathered
+ vyos.rest.vyos_snmp_server:
+ state: gathered
+
+ - name: RTT - Assert gathered matches applied
+ assert:
+ that:
+ - gathered.gathered.contact == "admin@example.com"
+ - gathered.gathered.communities | selectattr('name', 'eq', 'switches') | list | length == 1
+
+ - name: RTT - Modify configuration
+ vyos.rest.vyos_snmp_server:
+ config:
+ communities:
+ - name: switches
+ authorization_type: ro
+ contact: ops@example.com
+ listen_addresses:
+ - address: 20.1.1.1
+ state: replaced
+
+ - name: RTT - Gather modified configuration
+ register: gathered2
+ vyos.rest.vyos_snmp_server:
+ state: gathered
+
+ - name: RTT - Assert modification applied correctly
+ assert:
+ that:
+ - gathered2.gathered.contact == "ops@example.com"
+ - gathered2.gathered.communities | selectattr('name', 'eq', 'switches') | map(attribute='authorization_type') | first == 'ro'
+
+ always:
+ - include_tasks: _remove_config.yaml