summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_l3_interface
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/targets/vyos_l3_interface')
-rw-r--r--tests/integration/targets/vyos_l3_interface/aliases0
-rw-r--r--tests/integration/targets/vyos_l3_interface/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_l3_interface/tasks/cli.yaml22
-rw-r--r--tests/integration/targets/vyos_l3_interface/tasks/main.yaml2
-rw-r--r--tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml203
5 files changed, 230 insertions, 0 deletions
diff --git a/tests/integration/targets/vyos_l3_interface/aliases b/tests/integration/targets/vyos_l3_interface/aliases
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interface/aliases
diff --git a/tests/integration/targets/vyos_l3_interface/defaults/main.yaml b/tests/integration/targets/vyos_l3_interface/defaults/main.yaml
new file mode 100644
index 0000000..9ef5ba5
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interface/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml b/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml
new file mode 100644
index 0000000..890d3ac
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml
@@ -0,0 +1,22 @@
+---
+- name: collect all cli test cases
+ find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: set test_items
+ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: run test case (connection=network_cli)
+ include: "{{ test_case_to_run }} ansible_connection=network_cli"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+
+- name: run test case (connection=local)
+ include: "{{ test_case_to_run }} ansible_connection=local"
+ with_first_found: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_l3_interface/tasks/main.yaml b/tests/integration/targets/vyos_l3_interface/tasks/main.yaml
new file mode 100644
index 0000000..415c99d
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interface/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: cli.yaml, tags: ['cli'] }
diff --git a/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml b/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml
new file mode 100644
index 0000000..9ad6955
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml
@@ -0,0 +1,203 @@
+---
+- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
+
+- name: Remove IP address
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ state: absent
+
+- name: Remove IP address
+ vyos.vyos.vyos_l3_interface:
+ name: eth2
+ state: absent
+
+- name: Set IPv4 address
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv4: 192.168.2.10/24
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
+
+- name: Set IPv4 address (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv4: 192.168.2.10/24
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Set IPv6 address
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv6: fd5d:12c9:2201:1::1/64
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands'
+
+- name: Set IPv6 address (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv6: fd5d:12c9:2201:1::1/64
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Remove all IP addresses
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"delete interfaces ethernet eth1 address" in result.commands'
+
+- name: Remove all IP addresses again (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Set IPv4 and IPv6 address
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv4: 192.168.2.10/24
+ ipv6: fd5d:12c9:2201:1::1/64
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
+ - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands'
+
+- name: Set IPv4 and IPv6 address again (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv4: 192.168.2.10/24
+ ipv6: fd5d:12c9:2201:1::1/64
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Remove IPv4 address
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv4: 192.168.2.10/24
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
+
+- name: Remove IPv4 address again (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv4: 192.168.2.10/24
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Remove IPv6 address
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv6: fd5d:12c9:2201:1::1/64
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"delete interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands'
+
+- name: Remove IPv6 address again (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ name: eth1
+ ipv6: fd5d:12c9:2201:1::1/64
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Set IP addresses on aggregate
+ vyos.vyos.vyos_l3_interface:
+ aggregate:
+ - { name: eth1, ipv4: 192.168.2.10/24 }
+ - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" }
+ - { name: eth2, ipv4: 192.168.4.10/24 }
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
+ - '"set interfaces ethernet eth2 address 192.168.3.10/24" in result.commands'
+ - '"set interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands'
+ - '"set interfaces ethernet eth2 address 192.168.4.10/24" in result.commands'
+
+- name: Set IP addresses on aggregate (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ aggregate:
+ - { name: eth1, ipv4: 192.168.2.10/24 }
+ - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" }
+ - { name: eth2, ipv4: 192.168.4.10/24 }
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'
+
+- name: Remove IP addresses on aggregate
+ vyos.vyos.vyos_l3_interface:
+ aggregate:
+ - { name: eth1, ipv4: 192.168.2.10/24 }
+ - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" }
+ - { name: eth2, ipv4: 192.168.4.10/24 }
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == true'
+ - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
+ - '"delete interfaces ethernet eth2 address 192.168.3.10/24" in result.commands'
+ - '"delete interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands'
+ - '"delete interfaces ethernet eth2 address 192.168.4.10/24" in result.commands'
+
+- name: Remove IP addresses on aggregate (idempotent)
+ vyos.vyos.vyos_l3_interface:
+ aggregate:
+ - { name: eth1, ipv4: 192.168.2.10/24 }
+ - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" }
+ - { name: eth2, ipv4: 192.168.4.10/24 }
+ state: absent
+ register: result
+
+- assert:
+ that:
+ - 'result.changed == false'