summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorCaptTrews <capttrews@gmail.com>2020-01-16 15:50:24 +0000
committerCaptTrews <capttrews@gmail.com>2020-01-16 15:50:24 +0000
commit6b6166151faa3d811ae0ec3010a89e518a26287b (patch)
tree9cf59872c2ddc7e99595db4f47c72a7ce08b6c10 /tests/integration
parentd31b74ba6c74a6e3cdebd80b9eb5272aeb9b0fb4 (diff)
downloadvyos-ansible-collection-6b6166151faa3d811ae0ec3010a89e518a26287b.tar.gz
vyos-ansible-collection-6b6166151faa3d811ae0ec3010a89e518a26287b.zip
Updated from network content collector
Signed-off-by: CaptTrews <capttrews@gmail.com>
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/targets/prepare_vyos_tests/tasks/main.yaml14
-rw-r--r--tests/integration/targets/vyos_banner/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_banner/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_banner/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml23
-rw-r--r--tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml29
-rw-r--r--tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml29
-rw-r--r--tests/integration/targets/vyos_command/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_command/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_command/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml4
-rw-r--r--tests/integration/targets/vyos_command/tests/cli/cli_command.yaml30
-rw-r--r--tests/integration/targets/vyos_command/tests/cli/contains.yaml2
-rw-r--r--tests/integration/targets/vyos_command/tests/cli/invalid.yaml14
-rw-r--r--tests/integration/targets/vyos_command/tests/cli/output.yaml8
-rw-r--r--tests/integration/targets/vyos_command/tests/cli/timeout.yaml4
-rw-r--r--tests/integration/targets/vyos_config/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_config/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_config/tasks/cli_config.yaml10
-rw-r--r--tests/integration/targets/vyos_config/tasks/main.yaml9
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/backup.yaml60
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/check_config.yaml24
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/comment.yaml6
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/config.cfg3
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/save.yaml16
-rw-r--r--tests/integration/targets/vyos_config/tests/cli/simple.yaml26
-rw-r--r--tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml68
-rw-r--r--tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml20
-rw-r--r--tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml18
-rw-r--r--tests/integration/targets/vyos_facts/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_facts/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_facts/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml18
-rw-r--r--tests/integration/targets/vyos_interface/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_interface/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_interface/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_interface/tests/cli/basic.yaml116
-rw-r--r--tests/integration/targets/vyos_interface/tests/cli/intent.yaml75
-rw-r--r--tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml33
-rw-r--r--tests/integration/targets/vyos_interfaces/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_interfaces/tasks/cli.yaml12
-rw-r--r--tests/integration/targets/vyos_interfaces/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml16
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml16
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml25
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml15
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml38
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml31
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml34
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml40
-rw-r--r--tests/integration/targets/vyos_interfaces/vars/main.yaml225
-rw-r--r--tests/integration/targets/vyos_l3_interface/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_l3_interface/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_l3_interface/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml116
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml12
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml14
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml9
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml25
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml15
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml36
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml29
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml30
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/vars/main.yaml118
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml12
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml8
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml21
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml8
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml18
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml25
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml15
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml40
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml27
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml35
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml41
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/vars/main.yaml128
-rw-r--r--tests/integration/targets/vyos_linkagg/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_linkagg/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_linkagg/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml80
-rw-r--r--tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml19
-rw-r--r--tests/integration/targets/vyos_lldp/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_lldp/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp/tests/cli/basic.yaml16
-rw-r--r--tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml9
-rw-r--r--tests/integration/targets/vyos_lldp_global/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp_global/tasks/cli.yaml12
-rw-r--r--tests/integration/targets/vyos_lldp_global/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml10
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml10
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml17
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml11
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml24
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml26
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml22
-rw-r--r--tests/integration/targets/vyos_lldp_global/vars/main.yaml56
-rw-r--r--tests/integration/targets/vyos_lldp_interface/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_lldp_interface/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml74
-rw-r--r--tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml15
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml12
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml20
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml12
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml8
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml30
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml15
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml45
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml31
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml45
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml36
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml134
-rw-r--r--tests/integration/targets/vyos_logging/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_logging/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_logging/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_logging/tests/cli/basic.yaml81
-rw-r--r--tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml23
-rw-r--r--tests/integration/targets/vyos_smoke/defaults/main.yaml3
-rw-r--r--tests/integration/targets/vyos_smoke/tasks/cli.yaml22
-rw-r--r--tests/integration/targets/vyos_smoke/tasks/main.yaml2
-rw-r--r--tests/integration/targets/vyos_smoke/tests/cli/common_config.yaml11
-rw-r--r--tests/integration/targets/vyos_smoke/tests/cli/common_utils.yaml50
-rw-r--r--tests/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml14
-rw-r--r--tests/integration/targets/vyos_static_route/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_static_route/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_static_route/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_static_route/tests/cli/basic.yaml69
-rw-r--r--tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml23
-rw-r--r--tests/integration/targets/vyos_system/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_system/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_system/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_system/tests/cli/basic.yaml6
-rw-r--r--tests/integration/targets/vyos_system/tests/cli/net_system.yaml10
-rw-r--r--tests/integration/targets/vyos_user/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_user/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_user/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_user/tests/cli/auth.yaml51
-rw-r--r--tests/integration/targets/vyos_user/tests/cli/basic.yaml37
-rw-r--r--tests/integration/targets/vyos_vlan/defaults/main.yaml2
-rw-r--r--tests/integration/targets/vyos_vlan/tasks/cli.yaml14
-rw-r--r--tests/integration/targets/vyos_vlan/tasks/main.yaml4
-rw-r--r--tests/integration/targets/vyos_vlan/tests/cli/basic.yaml50
-rw-r--r--tests/integration/targets/vyos_vlan/tests/cli/intent.yaml20
-rw-r--r--tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml20
151 files changed, 1807 insertions, 1673 deletions
diff --git a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
index 5813284..afbc291 100644
--- a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
+++ b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
@@ -1,13 +1,9 @@
---
- name: Ensure required interfaces are present in running-config
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set interfaces ethernet eth0 address dhcp
- set interfaces ethernet eth0 speed auto
- set interfaces ethernet eth0 duplex auto
- set interfaces ethernet eth1
- set interfaces ethernet eth2
- delete interfaces loopback lo
+ lines: "set interfaces ethernet eth0 address dhcp\nset interfaces ethernet eth0\
+ \ speed auto\nset interfaces ethernet eth0 duplex auto\nset interfaces ethernet\
+ \ eth1\nset interfaces ethernet eth2\ndelete interfaces loopback lo\n"
ignore_errors: true
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_banner/defaults/main.yaml b/tests/integration/targets/vyos_banner/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_banner/defaults/main.yaml
+++ b/tests/integration/targets/vyos_banner/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_banner/tasks/cli.yaml b/tests/integration/targets/vyos_banner/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_banner/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_banner/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_banner/tasks/main.yaml b/tests/integration/targets/vyos_banner/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_banner/tasks/main.yaml
+++ b/tests/integration/targets/vyos_banner/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml b/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml
index 5efdf8e..1ade232 100644
--- a/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml
+++ b/tests/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml
@@ -1,41 +1,34 @@
---
- debug:
- msg: "cli/basic-no-login.yaml on connection={{ ansible_connection }}"
+ msg: cli/basic-no-login.yaml on connection={{ ansible_connection }}
- name: Setup
vyos.vyos.vyos_banner:
banner: pre-login
- text: |
- Junk pre-login banner
- over multiple lines
+ text: "Junk pre-login banner\nover multiple lines\n"
state: present
- name: remove pre-login
+ register: result
vyos.vyos.vyos_banner:
banner: pre-login
state: absent
- register: result
- debug:
- msg: "{{ result }}"
+ msg: '{{ result }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'delete system login banner pre-login' in result.commands"
- name: remove pre-login (idempotent)
+ register: result
vyos.vyos.vyos_banner:
banner: pre-login
state: absent
- register: result
- assert:
that:
- - "result.changed == false"
- - "result.commands | length == 0"
-
-
-# FIXME add in tests for everything defined in docs
-# FIXME Test state:absent + test:
-# FIXME Without powers ensure "privileged mode required"
+ - result.changed == false
+ - result.commands | length == 0
diff --git a/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml b/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml
index ff6cbad..17cc07d 100644
--- a/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml
+++ b/tests/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml
@@ -1,6 +1,6 @@
---
- debug:
- msg: "cli/basic-post-login.yaml on connection={{ ansible_connection }}"
+ msg: cli/basic-post-login.yaml on connection={{ ansible_connection }}
- name: setup - remove post-login
vyos.vyos.vyos_banner:
@@ -8,40 +8,29 @@
state: absent
- name: Set post-login
+ register: result
vyos.vyos.vyos_banner:
banner: post-login
- text: |
- this is my post-login banner
- that has a multiline
- string
+ text: "this is my post-login banner\nthat has a multiline\nstring\n"
state: present
- register: result
- debug:
- msg: "{{ result }}"
+ msg: '{{ result }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'this is my post-login banner' in result.commands[0]"
- "'that has a multiline' in result.commands[0]"
- name: Set post-login again (idempotent)
+ register: result
vyos.vyos.vyos_banner:
banner: post-login
- text: |
- this is my post-login banner
- that has a multiline
- string
+ text: "this is my post-login banner\nthat has a multiline\nstring\n"
state: present
- register: result
- assert:
that:
- - "result.changed == false"
- - "result.commands | length == 0"
-
-
-# FIXME add in tests for everything defined in docs
-# FIXME Test state:absent + test:
-# FIXME Without powers ensure "privileged mode required"
+ - result.changed == false
+ - result.commands | length == 0
diff --git a/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml b/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml
index 8489d87..526c657 100644
--- a/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml
+++ b/tests/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml
@@ -1,6 +1,6 @@
---
- debug:
- msg: "cli/basic-pre-login.yaml on connection={{ ansible_connection }}"
+ msg: cli/basic-pre-login.yaml on connection={{ ansible_connection }}
- name: setup - remove pre-login
vyos.vyos.vyos_banner:
@@ -8,40 +8,29 @@
state: absent
- name: Set pre-login
+ register: result
vyos.vyos.vyos_banner:
banner: pre-login
- text: |
- this is my pre-login banner
- that has a multiline
- string
+ text: "this is my pre-login banner\nthat has a multiline\nstring\n"
state: present
- register: result
- debug:
- msg: "{{ result }}"
+ msg: '{{ result }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'this is my pre-login banner' in result.commands[0]"
- "'that has a multiline' in result.commands[0]"
- name: Set pre-login again (idempotent)
+ register: result
vyos.vyos.vyos_banner:
banner: pre-login
- text: |
- this is my pre-login banner
- that has a multiline
- string
+ text: "this is my pre-login banner\nthat has a multiline\nstring\n"
state: present
- register: result
- assert:
that:
- - "result.changed == false"
- - "result.commands | length == 0"
-
-
-# FIXME add in tests for everything defined in docs
-# FIXME Test state:absent + test:
-# FIXME Without powers ensure "privileged mode required"
+ - result.changed == false
+ - result.commands | length == 0
diff --git a/tests/integration/targets/vyos_command/defaults/main.yaml b/tests/integration/targets/vyos_command/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_command/defaults/main.yaml
+++ b/tests/integration/targets/vyos_command/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_command/tasks/cli.yaml b/tests/integration/targets/vyos_command/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_command/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_command/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_command/tasks/main.yaml b/tests/integration/targets/vyos_command/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_command/tasks/main.yaml
+++ b/tests/integration/targets/vyos_command/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml
index 5ff72fa..690937f 100644
--- a/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml
+++ b/tests/integration/targets/vyos_command/tests/cli/bad_operator.yaml
@@ -2,14 +2,14 @@
- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}"
- name: test bad operator
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_command:
commands:
- show version
- show interfaces
wait_for:
- result[0] is 'VyOS'
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml b/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml
index a10f2bc..61ed054 100644
--- a/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml
+++ b/tests/integration/targets/vyos_command/tests/cli/cli_command.yaml
@@ -1,41 +1,43 @@
---
- debug:
- msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}"
+ msg: START cli/cli_command.yaml on connection={{ ansible_connection }}
- block:
+
- name: get output for single command
- network.cli.cli_command:
- command: show version
register: result
+ ansible.netcommon.cli_command:
+ command: show version
- assert:
that:
- - "result.changed == false"
- - "result.stdout is defined"
+ - result.changed == false
+ - result.stdout is defined
- name: send invalid command
- network.cli.cli_command:
- command: 'show foo'
register: result
ignore_errors: true
+ ansible.netcommon.cli_command:
+ command: show foo
- assert:
that:
- - "result.failed == true"
- - "result.msg is defined"
- when: "ansible_connection == 'network_cli'"
+ - result.failed == true
+ - result.msg is defined
+ when: ansible_connection == 'ansible.netcommon.network_cli'
- block:
+
- name: test failure for local connection
- network.cli.cli_command:
- command: show version
register: result
ignore_errors: true
+ ansible.netcommon.cli_command:
+ command: show version
- assert:
that:
- - 'result.failed == true'
+ - result.failed == true
- "'Connection type local is not valid for this module' in result.msg"
- when: "ansible_connection == 'local'"
+ when: ansible_connection == 'local'
- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_command/tests/cli/contains.yaml b/tests/integration/targets/vyos_command/tests/cli/contains.yaml
index b8665fa..efaf811 100644
--- a/tests/integration/targets/vyos_command/tests/cli/contains.yaml
+++ b/tests/integration/targets/vyos_command/tests/cli/contains.yaml
@@ -2,6 +2,7 @@
- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}"
- name: test contains operator
+ register: result
vyos.vyos.vyos_command:
commands:
- show version
@@ -9,7 +10,6 @@
wait_for:
- result[0] contains VyOS
- result[1] contains eth0
- register: result
- assert:
that:
diff --git a/tests/integration/targets/vyos_command/tests/cli/invalid.yaml b/tests/integration/targets/vyos_command/tests/cli/invalid.yaml
index 04d203d..ac8af3f 100644
--- a/tests/integration/targets/vyos_command/tests/cli/invalid.yaml
+++ b/tests/integration/targets/vyos_command/tests/cli/invalid.yaml
@@ -2,21 +2,23 @@
- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}"
- name: run invalid command
- vyos.vyos.vyos_command:
- commands: show foo
register: result
ignore_errors: true
+ vyos.vyos.vyos_command:
+ commands: show foo
-- assert: {that: result.failed}
+- assert:
+ that: result.failed
- name: run commands that include invalid command
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_command:
commands:
- show version
- show foo
- register: result
- ignore_errors: true
-- assert: {that: result.failed}
+- assert:
+ that: result.failed
- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_command/tests/cli/output.yaml b/tests/integration/targets/vyos_command/tests/cli/output.yaml
index 1bc0dc6..9ed1906 100644
--- a/tests/integration/targets/vyos_command/tests/cli/output.yaml
+++ b/tests/integration/targets/vyos_command/tests/cli/output.yaml
@@ -2,9 +2,9 @@
- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}"
- name: get output for single command
+ register: result
vyos.vyos.vyos_command:
commands: show version
- register: result
- assert:
that:
@@ -13,11 +13,11 @@
- result.stdout_lines is defined
- name: get output for multiple commands
+ register: result
vyos.vyos.vyos_command:
commands:
- show version
- show interfaces
- register: result
- assert:
that:
@@ -26,14 +26,12 @@
- result.stdout | length == 2
- name: Get output for multiple commands that call less explicitly
+ register: result
vyos.vyos.vyos_command:
commands:
- # NOTE: We only test show commands that will output <ANSIBLE_VYOS_TERMINAL_LENGTH
- # Otherwise you will get ": "command timeout triggered"
- show hardware cpu detail
- show hardware mem
- show license
- register: result
- assert:
that:
diff --git a/tests/integration/targets/vyos_command/tests/cli/timeout.yaml b/tests/integration/targets/vyos_command/tests/cli/timeout.yaml
index 57120ac..fceea5c 100644
--- a/tests/integration/targets/vyos_command/tests/cli/timeout.yaml
+++ b/tests/integration/targets/vyos_command/tests/cli/timeout.yaml
@@ -2,13 +2,13 @@
- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}"
- name: test bad condition
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_command:
commands:
- show version
wait_for:
- result[0] contains bad_value_string
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_config/defaults/main.yaml b/tests/integration/targets/vyos_config/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_config/defaults/main.yaml
+++ b/tests/integration/targets/vyos_config/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_config/tasks/cli.yaml b/tests/integration/targets/vyos_config/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_config/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_config/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_config/tasks/cli_config.yaml b/tests/integration/targets/vyos_config/tasks/cli_config.yaml
index f5d5b55..98bd1fc 100644
--- a/tests/integration/targets/vyos_config/tasks/cli_config.yaml
+++ b/tests/integration/targets/vyos_config/tasks/cli_config.yaml
@@ -1,16 +1,16 @@
---
- name: collect all cli_config test cases
find:
- paths: "{{ role_path }}/tests/cli_config"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli_config'
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli'
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_config/tasks/main.yaml b/tests/integration/targets/vyos_config/tasks/main.yaml
index 13977a4..8d10ebb 100644
--- a/tests/integration/targets/vyos_config/tasks/main.yaml
+++ b/tests/integration/targets/vyos_config/tasks/main.yaml
@@ -1,3 +1,8 @@
---
-- {include: cli.yaml, tags: ['cli']}
-- {include: cli_config.yaml, tags: ['cli_config']}
+- include: cli.yaml
+ tags:
+ - cli
+
+- include: cli_config.yaml
+ tags:
+ - cli_config
diff --git a/tests/integration/targets/vyos_config/tests/cli/backup.yaml b/tests/integration/targets/vyos_config/tests/cli/backup.yaml
index af6a772..ae59a0d 100644
--- a/tests/integration/targets/vyos_config/tests/cli/backup.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/backup.yaml
@@ -3,111 +3,111 @@
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- name: delete backup files
file:
- path: "{{ item.path }}"
+ path: '{{ item.path }}'
state: absent
- with_items: "{{backup_files.files|default([])}}"
+ with_items: '{{backup_files.files|default([])}}'
- name: take configure backup
+ register: result
vyos.vyos.vyos_config:
backup: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- assert:
that:
- - "backup_files.files is defined"
+ - backup_files.files is defined
- name: delete configurable backup file path
file:
- path: "{{ item }}"
+ path: '{{ item }}'
state: absent
with_items:
- - "{{ role_path }}/backup_test_dir/"
- - "{{ role_path }}/backup/backup.cfg"
+ - '{{ role_path }}/backup_test_dir/'
+ - '{{ role_path }}/backup/backup.cfg'
- name: take configuration backup in custom filename and directory path
+ become: true
+ register: result
vyos.vyos.vyos_config:
backup: true
backup_options:
filename: backup.cfg
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- become: true
- register: result
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-1 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom filename
+ become: true
+ register: result
vyos.vyos.vyos_config:
backup: true
backup_options:
filename: backup.cfg
- become: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-2 exist
find:
- paths: "{{ role_path }}/backup/backup.cfg"
+ paths: '{{ role_path }}/backup/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom path and default filename
+ become: true
+ register: result
vyos.vyos.vyos_config:
backup: true
backup_options:
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- become: true
- register: result
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-3 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
index f1ddc71..4300c10 100644
--- a/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/check_config.yaml
@@ -6,58 +6,52 @@
lines: delete interfaces loopback lo
- name: setup- create interface
+ register: result
vyos.vyos.vyos_config:
lines:
- interfaces
- interfaces loopback lo
- interfaces loopback lo description test
- register: result
-
-# note collapsing the duplicate lines doesn't work if
-# lines:
-# - interfaces loopback lo description test
-# - interfaces loopback lo
-# - interfaces
- name: Check that multiple duplicate lines collapse into a single commands
assert:
that:
- - "{{ result.commands|length }} == 1"
+ - '{{ result.commands|length }} == 1'
- name: Check that set is correctly prepended
assert:
that:
- - "result.commands[0] == 'set interfaces loopback lo description test'"
+ - result.commands[0] == 'set interfaces loopback lo description test'
- name: configure config_check config command
+ register: result
vyos.vyos.vyos_config:
lines: delete interfaces loopback lo
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check config_check config command idempontent
+ register: result
vyos.vyos.vyos_config:
lines: delete interfaces loopback lo
- register: result
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: check multiple line config filter is working
+ register: result
vyos.vyos.vyos_config:
lines:
- set system login user esa level admin
- set system login user esa authentication encrypted-password '!abc!'
- set system login user vyos level admin
- set system login user vyos authentication encrypted-password 'abc'
- register: result
- assert:
that:
- - "{{ result.filtered|length }} == 2"
+ - '{{ result.filtered|length }} == 2'
- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli/comment.yaml b/tests/integration/targets/vyos_config/tests/cli/comment.yaml
index 2cd1350..3032585 100644
--- a/tests/integration/targets/vyos_config/tests/cli/comment.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/comment.yaml
@@ -7,20 +7,20 @@
match: none
- name: configure using comment
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
comment: this is a test
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name foo' in result.commands"
- name: collect system commits
+ register: result
vyos.vyos.vyos_command:
commands: show system commit
- register: result
- assert:
that:
diff --git a/tests/integration/targets/vyos_config/tests/cli/config.cfg b/tests/integration/targets/vyos_config/tests/cli/config.cfg
new file mode 100644
index 0000000..36c98f1
--- /dev/null
+++ b/tests/integration/targets/vyos_config/tests/cli/config.cfg
@@ -0,0 +1,3 @@
+ set service lldp
+ set protocols static
+
diff --git a/tests/integration/targets/vyos_config/tests/cli/save.yaml b/tests/integration/targets/vyos_config/tests/cli/save.yaml
index d8e45e2..e8a9035 100644
--- a/tests/integration/targets/vyos_config/tests/cli/save.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/save.yaml
@@ -7,43 +7,43 @@
match: none
- name: configure hostaname and save
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
save: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name foo' in result.commands"
- name: configure hostaname and don't save
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name bar
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name bar' in result.commands"
- name: save config
+ register: result
vyos.vyos.vyos_config:
save: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: save config again
+ register: result
vyos.vyos.vyos_config:
save: true
- register: result
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: teardown
vyos.vyos.vyos_config:
diff --git a/tests/integration/targets/vyos_config/tests/cli/simple.yaml b/tests/integration/targets/vyos_config/tests/cli/simple.yaml
index af211f5..4e2db4e 100644
--- a/tests/integration/targets/vyos_config/tests/cli/simple.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli/simple.yaml
@@ -7,23 +7,43 @@
match: none
- name: configure simple config command
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set system host-name foo' in result.commands"
- name: check simple config command idempontent
+ register: result
vyos.vyos.vyos_config:
lines: set system host-name foo
+
+- assert:
+ that:
+ - result.changed == false
+
+- name: Delete services
+ vyos.vyos.vyos_config: &id001
+ lines:
+ - delete service lldp
+ - delete protocols static
+
+- name: Configuring when commands starts with whitespaces
register: result
+ vyos.vyos.vyos_config:
+ src: '{{ role_path }}/tests/cli/config.cfg'
- assert:
that:
- - "result.changed == false"
+ - result.changed == true
+ - '"set service lldp" in result.commands'
+ - '"set protocols static" in result.commands'
+
+- name: Delete services
+ vyos.vyos.vyos_config: *id001
- name: teardown
vyos.vyos.vyos_config:
diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
index a573d6c..3880a04 100644
--- a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml
@@ -3,112 +3,112 @@
- name: delete configurable backup file path
file:
- path: "{{ item }}"
+ path: '{{ item }}'
state: absent
with_items:
- - "{{ role_path }}/backup_test_dir/"
- - "{{ role_path }}/backup/backup.cfg"
+ - '{{ role_path }}/backup_test_dir/'
+ - '{{ role_path }}/backup/backup.cfg'
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- name: delete backup files
file:
- path: "{{ item.path }}"
+ path: '{{ item.path }}'
state: absent
- with_items: "{{backup_files.files|default([])}}"
+ with_items: '{{backup_files.files|default([])}}'
- name: take config backup
- network.cli.cli_config:
- backup: true
become: true
register: result
+ ansible.netcommon.cli_config:
+ backup: true
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: collect any backup files
find:
- paths: "{{ role_path }}/backup"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_files
connection: local
- assert:
that:
- - "backup_files.files is defined"
+ - backup_files.files is defined
- name: take configuration backup in custom filename and directory path
- network.cli.cli_config:
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
backup: true
backup_options:
filename: backup.cfg
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- become: true
- register: result
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-1 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom filename
- network.cli.cli_config:
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
backup: true
backup_options:
filename: backup.cfg
- become: true
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-2 exist
find:
- paths: "{{ role_path }}/backup/backup.cfg"
+ paths: '{{ role_path }}/backup/backup.cfg'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- name: take configuration backup in custom path and default filename
- network.cli.cli_config:
- backup: true
- backup_options:
- dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
become: true
register: result
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: check if the backup file-3 exist
find:
- paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
- pattern: "{{ inventory_hostname_short }}_config*"
+ paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}'
+ pattern: '{{ inventory_hostname_short }}_config*'
register: backup_file
connection: local
- assert:
that:
- - "backup_file.files is defined"
+ - backup_file.files is defined
- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
index e5e3edb..6b71144 100644
--- a/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml
@@ -1,28 +1,30 @@
---
-- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
+- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection
+ }}"
- name: setup - remove interface description
- network.cli.cli_config: &rm
+ ansible.netcommon.cli_config: &id002
config: delete interfaces loopback lo description
- name: configure device with config
- network.cli.cli_config: &conf
- config: set interfaces loopback lo description 'this is a test'
register: result
+ ansible.netcommon.cli_config: &id001
+ config: set interfaces loopback lo description 'this is a test'
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: Idempotence
- network.cli.cli_config: *conf
register: result
+ ansible.netcommon.cli_config: *id001
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: teardown
- network.cli.cli_config: *rm
+ ansible.netcommon.cli_config: *id002
-- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
+- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
index ecc9e8c..030b75d 100644
--- a/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
+++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml
@@ -1,30 +1,32 @@
---
-- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
+- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection
+ }}"
- name: setup
- network.cli.cli_config: &rm
+ ansible.netcommon.cli_config: &id001
config: set system host-name {{ inventory_hostname_short }}
- name: configure using comment
- network.cli.cli_config:
+ register: result
+ ansible.netcommon.cli_config:
config: set system host-name foo
commit_comment: this is a test
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- name: collect system commits
+ register: result
vyos.vyos.vyos_command:
commands: show system commit
- register: result
- assert:
that:
- "'this is a test' in result.stdout_lines[0][1]"
- name: teardown
- network.cli.cli_config: *rm
+ ansible.netcommon.cli_config: *id001
-- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}"
+- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_facts/defaults/main.yaml b/tests/integration/targets/vyos_facts/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_facts/defaults/main.yaml
+++ b/tests/integration/targets/vyos_facts/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_facts/tasks/cli.yaml b/tests/integration/targets/vyos_facts/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_facts/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_facts/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_facts/tasks/main.yaml b/tests/integration/targets/vyos_facts/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_facts/tasks/main.yaml
+++ b/tests/integration/targets/vyos_facts/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml b/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml
index 33382ea..5802f73 100644
--- a/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml
+++ b/tests/integration/targets/vyos_facts/tests/cli/basic_facts.yaml
@@ -1,46 +1,42 @@
---
- name: get host name
+ register: vyos_host
vyos.vyos.vyos_command:
commands:
- show host name
- register: vyos_host
- name: get version info
+ register: vyos_version
vyos.vyos.vyos_command:
commands:
- show version
- register: vyos_version
- name: collect all facts from the device
+ register: result
vyos.vyos.vyos_facts:
gather_subset: all
- register: result
-- name: "check that hostname is present"
+- name: check that hostname is present
assert:
that:
- # hostname
- result.ansible_facts.ansible_net_hostname == vyos_host.stdout[0]
-- name: "check that subsets are present"
+- name: check that subsets are present
assert:
that:
- # subsets
- "'neighbors' in result.ansible_facts.ansible_net_gather_subset"
- "'default' in result.ansible_facts.ansible_net_gather_subset"
- "'config' in result.ansible_facts.ansible_net_gather_subset"
-- name: "check that version info is present"
+- name: check that version info is present
assert:
that:
- # version info
- result.ansible_facts.ansible_net_version in vyos_version.stdout_lines[0][0]
- result.ansible_facts.ansible_net_model in vyos_version.stdout_lines[0][9]
- result.ansible_facts.ansible_net_serialnum in vyos_version.stdout_lines[0][10]
-- name: "check that config info is present"
+- name: check that config info is present
assert:
that:
- # config info
- result.ansible_facts.ansible_net_commits is defined
- result.ansible_facts.ansible_net_config is defined
diff --git a/tests/integration/targets/vyos_interface/defaults/main.yaml b/tests/integration/targets/vyos_interface/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_interface/defaults/main.yaml
+++ b/tests/integration/targets/vyos_interface/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_interface/tasks/cli.yaml b/tests/integration/targets/vyos_interface/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_interface/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_interface/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_interface/tasks/main.yaml b/tests/integration/targets/vyos_interface/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_interface/tasks/main.yaml
+++ b/tests/integration/targets/vyos_interface/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_interface/tests/cli/basic.yaml b/tests/integration/targets/vyos_interface/tests/cli/basic.yaml
index 168d666..b50d7da 100644
--- a/tests/integration/targets/vyos_interface/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_interface/tests/cli/basic.yaml
@@ -2,10 +2,10 @@
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
- name: Run vyos lsmod command
+ register: lsmod_out
vyos.vyos.vyos_command:
commands:
- lsmod
- register: lsmod_out
- name: Set up - delete interface
vyos.vyos.vyos_interface:
@@ -13,19 +13,21 @@
state: absent
- name: Set up - Create interface
+ register: result
vyos.vyos.vyos_interface:
name: eth1
state: present
description: test-interface
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth1" in result.commands'
- - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands'
+ - "\"set interfaces ethernet eth1 description 'test-interface'\" in result.commands"
- name: Configure interface params
+ when: "'virtio_net' not in lsmod_out.stdout[0]"
+ register: result
vyos.vyos.vyos_interface:
name: eth1
state: present
@@ -33,19 +35,19 @@
speed: 100
duplex: half
mtu: 256
- when: "'virtio_net' not in lsmod_out.stdout[0]"
- register: result
- assert:
that:
- - 'result.changed == true'
- - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
+ - result.changed == true
+ - "\"set interfaces ethernet eth1 description 'test-interface-1'\" in result.commands"
- '"set interfaces ethernet eth1 speed 100" in result.commands'
- '"set interfaces ethernet eth1 duplex half" in result.commands'
- '"set interfaces ethernet eth1 mtu 256" in result.commands'
when: "'virtio_net' not in lsmod_out.stdout[0]"
- name: Configure interface params (idempotent)
+ register: result
+ when: "'virtio_net' not in lsmod_out.stdout[0]"
vyos.vyos.vyos_interface:
name: eth1
state: present
@@ -53,15 +55,15 @@
speed: 100
duplex: half
mtu: 256
- register: result
- when: "'virtio_net' not in lsmod_out.stdout[0]"
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
when: "'virtio' not in lsmod_out.stdout[0]"
- name: Change interface params
+ register: result
+ when: "'virtio_net' not in lsmod_out.stdout[0]"
vyos.vyos.vyos_interface:
name: eth1
state: present
@@ -69,152 +71,178 @@
speed: 1000
duplex: full
mtu: 512
- register: result
- when: "'virtio_net' not in lsmod_out.stdout[0]"
- assert:
that:
- - 'result.changed == true'
- - '"set interfaces ethernet eth1 description ''test-interface-2''" in result.commands'
+ - result.changed == true
+ - "\"set interfaces ethernet eth1 description 'test-interface-2'\" in result.commands"
- '"set interfaces ethernet eth1 speed 1000" in result.commands'
- '"set interfaces ethernet eth1 duplex full" in result.commands'
- '"set interfaces ethernet eth1 mtu 512" in result.commands'
when: "'virtio_net' not in lsmod_out.stdout[0]"
- name: Disable interface
+ register: result
vyos.vyos.vyos_interface:
name: eth1
enabled: false
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth1 disable" in result.commands'
- name: Enable interface
+ register: result
vyos.vyos.vyos_interface:
name: eth1
enabled: true
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 disable" in result.commands'
- name: Delete interface
+ register: result
vyos.vyos.vyos_interface:
name: eth1
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1" in result.commands'
- name: Delete interface (idempotent)
+ register: result
vyos.vyos.vyos_interface:
name: eth1
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Aggregate setup- delete interface
+ register: result
vyos.vyos.vyos_interface:
name: eth2
state: absent
- register: result
- name: Set interface on aggregate
- vyos.vyos.vyos_interface:
- aggregate:
- - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512}
- - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256}
register: result
when: "'virtio_net' not in lsmod_out.stdout[0]"
+ vyos.vyos.vyos_interface:
+ aggregate:
+
+ - name: eth1
+ description: test-interface-1
+ speed: 100
+ duplex: half
+ mtu: 512
+
+ - name: eth2
+ description: test-interface-2
+ speed: 1000
+ duplex: full
+ mtu: 256
- assert:
that:
- - 'result.changed == true'
- - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
+ - result.changed == true
+ - "\"set interfaces ethernet eth1 description 'test-interface-1'\" in result.commands"
- '"set interfaces ethernet eth1 speed 100" in result.commands'
- '"set interfaces ethernet eth1 duplex half" in result.commands'
- '"set interfaces ethernet eth1 mtu 512" in result.commands'
- - '"set interfaces ethernet eth2 description ''test-interface-2''" in result.commands'
+ - "\"set interfaces ethernet eth2 description 'test-interface-2'\" in result.commands"
- '"set interfaces ethernet eth2 speed 1000" in result.commands'
- '"set interfaces ethernet eth2 duplex full" in result.commands'
- '"set interfaces ethernet eth2 mtu 256" in result.commands'
when: "'virtio_net' not in lsmod_out.stdout[0]"
- name: Set interface on aggregate (idempotent)
- vyos.vyos.vyos_interface:
- aggregate:
- - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512}
- - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256}
register: result
when: "'virtio_net' not in lsmod_out.stdout[0]"
+ vyos.vyos.vyos_interface:
+ aggregate:
+
+ - name: eth1
+ description: test-interface-1
+ speed: 100
+ duplex: half
+ mtu: 512
+
+ - name: eth2
+ description: test-interface-2
+ speed: 1000
+ duplex: full
+ mtu: 256
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
when: "'virtio_net' not in lsmod_out.stdout[0]"
- name: Disable interface on aggregate
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth1
+
- name: eth2
description: test-interface
enabled: false
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth1 disable" in result.commands'
- '"set interfaces ethernet eth2 disable" in result.commands'
- name: Enable interface on aggregate
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth1
+
- name: eth2
enabled: true
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 disable" in result.commands'
- '"delete interfaces ethernet eth2 disable" in result.commands'
- name: Delete interface aggregate
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth1
+
- name: eth2
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1" in result.commands'
- '"delete interfaces ethernet eth2" in result.commands'
- name: Delete interface aggregate (idempotent)
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth1
+
- name: eth2
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
diff --git a/tests/integration/targets/vyos_interface/tests/cli/intent.yaml b/tests/integration/targets/vyos_interface/tests/cli/intent.yaml
index 1c14a7b..69ab779 100644
--- a/tests/integration/targets/vyos_interface/tests/cli/intent.yaml
+++ b/tests/integration/targets/vyos_interface/tests/cli/intent.yaml
@@ -1,157 +1,160 @@
---
- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}"
-# To be able to run the lldp test we need to have a neighbor configured to talk to
-# In DCI & Zuul we (currently) only spin up a single network VM, so we can't configure a neighbor
-# In the future when we have multi-network-nodes running we can run these tests again
-# https://github.com/ansible/ansible/issues/39667
-
- name: Detect if we have existing lldp neighbors configured
+ register: neighbors_out
vyos.vyos.vyos_command:
commands:
- show lldp neighbors detail
- register: neighbors_out
- name: Should we run lldp tests?
set_fact:
run_lldp_tests: "'PortDescr: eth0' in neighbors_out.stdout[0]"
- name: Enable LLDP service
+ when: run_lldp_tests
vyos.vyos.vyos_lldp:
state: present
- when: run_lldp_tests
- name: Create LLDP configuration
+ when: run_lldp_tests
vyos.vyos.vyos_lldp_interface:
name: eth1
state: present
- when: run_lldp_tests
- name: Setup (interface is up)
+ register: result
vyos.vyos.vyos_interface:
name: eth1
enabled: true
state: present
- register: result
- name: Check intent arguments
+ register: result
vyos.vyos.vyos_interface:
name: eth1
state: up
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
- name: Check lldp neighbors intent arguments
+ when: run_lldp_tests
+ register: result
vyos.vyos.vyos_interface:
name: eth0
neighbors:
+
- port: eth0
- when: run_lldp_tests
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
when: run_lldp_tests
- name: Check intent arguments (failed condition)
+ ignore_errors: true
+ register: result
vyos.vyos.vyos_interface:
name: eth1
state: down
- ignore_errors: true
- register: result
- assert:
that:
- - "result.failed == true"
+ - result.failed == true
- "'state eq(down)' in result.failed_conditions"
- name: Check lldp neighbors intent arguments (failed)
+ ignore_errors: true
+ when: run_lldp_tests
+ register: result
vyos.vyos.vyos_interface:
name: eth0
neighbors:
+
- port: dummy_port
host: dummy_host
- ignore_errors: true
- when: run_lldp_tests
- register: result
- assert:
that:
- - "result.failed == true"
+ - result.failed == true
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: run_lldp_tests
- name: Config + intent
+ register: result
vyos.vyos.vyos_interface:
name: eth1
enabled: false
state: down
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
- name: Config + intent (fail)
+ ignore_errors: true
+ register: result
vyos.vyos.vyos_interface:
name: eth1
enabled: false
state: up
- ignore_errors: true
- register: result
- assert:
that:
- - "result.failed == true"
+ - result.failed == true
- "'state eq(up)' in result.failed_conditions"
- name: Aggregate config + intent (pass)
+ ignore_errors: true
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth1
enabled: true
state: up
- ignore_errors: true
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
- name: Check lldp neighbors intent aggregate arguments
+ when: run_lldp_tests
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth0
neighbors:
+
- port: eth0
- when: run_lldp_tests
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
when: run_lldp_tests
- name: Check lldp neighbors intent aggregate arguments (failed)
+ ignore_errors: true
+ when: run_lldp_tests
+ register: result
vyos.vyos.vyos_interface:
aggregate:
+
- name: eth0
neighbors:
+
- port: eth0
+
- port: dummy_port
host: dummy_host
- ignore_errors: true
- when: run_lldp_tests
- register: result
- assert:
that:
- - "result.failed == true"
+ - result.failed == true
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: run_lldp_tests
diff --git a/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml b/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml
index 4bdb6ec..045daa2 100644
--- a/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml
+++ b/tests/integration/targets/vyos_interface/tests/cli/net_interface.yaml
@@ -1,56 +1,55 @@
---
-- debug: msg="START vyos cli/net_interface.yaml on connection={{ ansible_connection }}"
-
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
+- debug: msg="START vyos cli/net_interface.yaml on connection={{ ansible_connection
+ }}"
- name: Run vyos lsmod command
+ register: lsmod_out
vyos.vyos.vyos_command:
commands:
- lsmod
- register: lsmod_out
- name: Set up - delete interface
- net_interface:
+ ansible.netcommon.net_interface:
name: eth1
state: absent
- name: Create interface using platform agnostic module
- net_interface:
+ register: result
+ ansible.netcommon.net_interface:
name: eth1
state: present
description: test-interface
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth1" in result.commands'
- - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands'
+ - "\"set interfaces ethernet eth1 description 'test-interface'\" in result.commands"
- name: Configure interface params using platform agnostic module
- net_interface:
+ when: "'virtio_net' not in lsmod_out.stdout[0]"
+ register: result
+ ansible.netcommon.net_interface:
name: eth1
state: present
description: test-interface-1
speed: 100
duplex: half
mtu: 256
- when: "'virtio_net' not in lsmod_out.stdout[0]"
- register: result
- assert:
that:
- - 'result.changed == true'
- - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
+ - result.changed == true
+ - "\"set interfaces ethernet eth1 description 'test-interface-1'\" in result.commands"
- '"set interfaces ethernet eth1 speed 100" in result.commands'
- '"set interfaces ethernet eth1 duplex half" in result.commands'
- '"set interfaces ethernet eth1 mtu 256" in result.commands'
when: "'virtio_net' not in lsmod_out.stdout[0]"
- name: teardown - delete interface
- net_interface:
+ ansible.netcommon.net_interface:
name: eth1
state: absent
-- debug: msg="END vyos cli/net_interface.yaml on connection={{ ansible_connection }}"
+- debug: msg="END vyos cli/net_interface.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_interfaces/defaults/main.yaml
index 164afea..852a6be 100644
--- a/tests/integration/targets/vyos_interfaces/defaults/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "[^_].*"
+testcase: '[^_].*'
test_items: []
diff --git a/tests/integration/targets/vyos_interfaces/tasks/cli.yaml b/tests/integration/targets/vyos_interfaces/tasks/cli.yaml
index 655e51e..93eb2fe 100644
--- a/tests/integration/targets/vyos_interfaces/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_interfaces/tasks/cli.yaml
@@ -1,8 +1,8 @@
---
- name: Collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
use_regex: true
register: test_cases
delegate_to: localhost
@@ -10,10 +10,10 @@
- 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 }}"
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
vars:
- ansible_connection: network_cli
- with_items: "{{ test_items }}"
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_interfaces/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_interfaces/tasks/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml
index 4dd5f18..686236f 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/_populate.yaml
@@ -1,17 +1,15 @@
---
- name: Setup
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set interfaces ethernet "{{ intf }}" description 'Configured by Ansible'
- set interfaces ethernet "{{ intf }}" speed 'auto'
- set interfaces ethernet "{{ intf }}" duplex 'auto'
- set interfaces ethernet "{{ intf }}" mtu '1500'
- set interfaces ethernet "{{ intf }}" vif 200
- set interfaces ethernet "{{ intf }}" vif 200 description 'VIF - 200'
+ lines: "set interfaces ethernet \"{{ intf }}\" description 'Configured by Ansible'\n\
+ set interfaces ethernet \"{{ intf }}\" speed 'auto'\nset interfaces ethernet\
+ \ \"{{ intf }}\" duplex 'auto'\nset interfaces ethernet \"{{ intf }}\" mtu\
+ \ '1500'\nset interfaces ethernet \"{{ intf }}\" vif 200\nset interfaces ethernet\
+ \ \"{{ intf }}\" vif 200 description 'VIF - 200'\n"
loop:
- eth1
- eth2
loop_control:
loop_var: intf
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml
index 9157f55..298cf5d 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/_remove_config.yaml
@@ -1,17 +1,15 @@
---
- name: Remove Config
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- delete interfaces ethernet "{{ intf }}" description
- delete interfaces ethernet "{{ intf }}" speed
- delete interfaces ethernet "{{ intf }}" duplex
- delete interfaces ethernet "{{ intf }}" mtu
- delete interfaces ethernet "{{ intf }}" disable
- delete interfaces ethernet "{{ intf }}" vif
+ lines: "delete interfaces ethernet \"{{ intf }}\" description\ndelete interfaces\
+ \ ethernet \"{{ intf }}\" speed\ndelete interfaces ethernet \"{{ intf }}\"\
+ \ duplex\ndelete interfaces ethernet \"{{ intf }}\" mtu\ndelete interfaces\
+ \ ethernet \"{{ intf }}\" disable\ndelete interfaces ethernet \"{{ intf }}\"\
+ \ vif\n"
loop:
- eth1
- eth2
loop_control:
loop_var: intf
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml
index fc86ca7..56e747a 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/deleted.yaml
@@ -1,17 +1,21 @@
---
- debug:
- msg: "Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"
+ msg: Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection
+ }}
- include_tasks: _populate.yaml
- block:
+
- name: Delete attributes of given interfaces
- vyos.vyos.vyos_interfaces: &deleted
+ register: result
+ vyos.vyos.vyos_interfaces: &id001
config:
+
- name: eth1
+
- name: eth2
state: deleted
- register: result
- name: Assert that the before dicts were correctly generated
assert:
@@ -21,26 +25,29 @@
- name: Assert that the correct set of commands were generated
assert:
that:
- - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that the after dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ deleted['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Delete attributes of given interfaces (IDEMPOTENT)
- vyos.vyos.vyos_interfaces: *deleted
register: result
+ vyos.vyos.vyos_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: Assert that the before dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ deleted['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
index 4a72c8a..e1e154d 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
@@ -1,35 +1,36 @@
---
- debug:
- msg: "START vyos_interfaces empty_config integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_interfaces empty_config integration tests on connection={{ ansible_connection
+ }}
- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_interfaces:
config:
state: merged
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state merged'
- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_interfaces:
config:
state: replaced
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state replaced'
- name: Overridden with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_interfaces:
config:
state: overridden
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml
index 50e4936..e0fa0b9 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/merged.yaml
@@ -1,59 +1,69 @@
---
- debug:
- msg: "START vyos_interfaces merged integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_interfaces merged integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- name: Merge the provided configuration with the exisiting running configuration
- vyos.vyos.vyos_interfaces: &merged
+ register: result
+ vyos.vyos.vyos_interfaces: &id001
config:
+
- name: eth1
- description: "Configured by Ansible - Interface 1"
+ description: Configured by Ansible - Interface 1
mtu: 1500
speed: auto
duplex: auto
vifs:
+
- vlan_id: 100
- description: "Eth1 - VIF 100"
+ description: Eth1 - VIF 100
mtu: 400
- vlan_id: 101
- description: "Eth1 - VIF 101"
+ description: Eth1 - VIF 101
- name: eth2
- description: "Configured by Ansible - Interface 2 (ADMIN DOWN)"
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600
enabled: false
state: merged
- register: result
- name: Assert that before dicts were correctly generated
assert:
- that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}"
+ that: "{{ merged['before'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that after dicts was correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ merged['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
- vyos.vyos.vyos_interfaces: *merged
+ - name: Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}"
+ - "{{ merged['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml
index 74669f7..9921e5d 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/overridden.yaml
@@ -1,23 +1,27 @@
---
- debug:
- msg: "START vyos_interfaces overridden integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_interfaces overridden integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate.yaml
- block:
+
- name: Overrides all device configuration with provided configuration
- vyos.vyos.vyos_interfaces: &overridden
+ register: result
+ vyos.vyos.vyos_interfaces: &id001
config:
+
- name: eth0
- speed: "auto"
- duplex: "auto"
+ speed: auto
+ duplex: auto
+
- name: eth2
- description: "Overridden by Ansible"
+ description: Overridden by Ansible
mtu: 1200
state: overridden
- register: result
- name: Assert that before dicts were correctly generated
assert:
@@ -27,26 +31,29 @@
- name: Assert that correct commands were generated
assert:
that:
- - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ overridden['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that after dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ overridden['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Overrides all device configuration with provided configurations (IDEMPOTENT)
- vyos.vyos.vyos_interfaces: *overridden
register: result
+ vyos.vyos.vyos_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ overridden['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml
index 64510d7..8b68c5a 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/replaced.yaml
@@ -1,31 +1,36 @@
---
- debug:
- msg: "START vyos_interfaces replaced integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_interfaces replaced integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate.yaml
- block:
+
- name: Replace device configurations of listed interfaces with provided configurations
- vyos.vyos.vyos_interfaces: &replaced
+ register: result
+ vyos.vyos.vyos_interfaces: &id001
config:
+
- name: eth1
- description: "Replaced by Ansible"
+ description: Replaced by Ansible
vifs:
+
- vlan_id: 100
- description: "VIF 100 - Replaced by Ansible"
+ description: VIF 100 - Replaced by Ansible
- name: eth2
mtu: 1400
- description: "Replaced by Ansible"
+ description: Replaced by Ansible
state: replaced
- register: result
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ replaced['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that before dicts are correctly generated
assert:
@@ -35,21 +40,24 @@
- name: Assert that after dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ replaced['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT)
- vyos.vyos.vyos_interfaces: *replaced
+ - name: Replace device configurations of listed interfaces with provided configurarions
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_interfaces: *id001
- name: Assert that task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ replaced['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml
index f947513..f003c0b 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/rtt.yaml
@@ -1,35 +1,39 @@
---
- debug:
- msg: "START vyos_interfaces round trip integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_interfaces round trip integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- name: Apply the provided configuration (base config)
+ register: base_config
vyos.vyos.vyos_interfaces:
config:
+
- name: eth0
enabled: true
- duplex: "auto"
- speed: "auto"
+ duplex: auto
+ speed: auto
- name: eth1
- description: "Interface - 1"
+ description: Interface - 1
mtu: 1500
vifs:
+
- vlan_id: 100
- description: "Eth1 - VIF 100"
+ description: Eth1 - VIF 100
mtu: 200
- vlan_id: 101
enabled: false
- name: eth2
- description: "Interface - 2"
+ description: Interface - 2
enabled: true
mtu: 900
state: merged
- register: base_config
- name: Gather interfaces facts
vyos.vyos.vyos_facts:
@@ -39,40 +43,44 @@
- interfaces
- name: Apply the provided configuration (config to be reverted)
+ register: result
vyos.vyos.vyos_interfaces:
config:
+
- name: eth1
- description: "Interface 1 - Description (WILL BE REVERTED)"
+ description: Interface 1 - Description (WILL BE REVERTED)
mtu: 1200
vifs:
+
- vlan_id: 100
- description: "Eth1 - VIF 100 (WILL BE REVERTED)"
+ description: Eth1 - VIF 100 (WILL BE REVERTED)
mtu: 400
- vlan_id: 101
- description: "Eth1 - VIF 101 (WILL BE REMOVED)"
+ description: Eth1 - VIF 101 (WILL BE REMOVED)
enabled: true
- name: eth2
- description: "Interface 2 (ADMIN DOWN) (WILL BE REVERTED)"
+ description: Interface 2 (ADMIN DOWN) (WILL BE REVERTED)
mtu: 600
enabled: false
state: merged
- register: result
- name: Assert that changes were applied
assert:
- that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Revert back to base config using facts round trip
+ register: revert
vyos.vyos.vyos_interfaces:
config: "{{ ansible_facts['network_resources']['interfaces'] }}"
state: replaced
- register: revert
- name: Assert that config was reverted
assert:
- that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
-
+ that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml
index b973752..b730080 100644
--- a/tests/integration/targets/vyos_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml
@@ -1,209 +1,184 @@
---
merged:
before:
- - name: "eth0"
+ - name: eth0
enabled: true
- speed: "auto"
- duplex: "auto"
-
- - name: "eth1"
+ speed: auto
+ duplex: auto
+ - name: eth1
enabled: true
-
- - name: "eth2"
+ - name: eth2
enabled: true
-
commands:
- - "set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'"
- - "set interfaces ethernet eth1 mtu '1500'"
- - "set interfaces ethernet eth1 duplex 'auto'"
- - "set interfaces ethernet eth1 speed 'auto'"
- - "set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'"
- - "set interfaces ethernet eth1 vif 100 mtu '400'"
- - "set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'"
- - "set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'"
- - "set interfaces ethernet eth2 mtu '600'"
- - "set interfaces ethernet eth2 disable"
-
+ - set interfaces ethernet eth1 description 'Configured by Ansible - Interface
+ 1'
+ - set interfaces ethernet eth1 mtu '1500'
+ - set interfaces ethernet eth1 duplex 'auto'
+ - set interfaces ethernet eth1 speed 'auto'
+ - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'
+ - set interfaces ethernet eth1 vif 100 mtu '400'
+ - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'
+ - set interfaces ethernet eth2 description 'Configured by Ansible - Interface
+ 2 (ADMIN DOWN)'
+ - set interfaces ethernet eth2 mtu '600'
+ - set interfaces ethernet eth2 disable
after:
- - name: "eth0"
+ - name: eth0
enabled: true
- duplex: "auto"
- speed: "auto"
-
- - name: "eth1"
- description: "Configured by Ansible - Interface 1"
+ duplex: auto
+ speed: auto
+ - name: eth1
+ description: Configured by Ansible - Interface 1
mtu: 1500
- speed: "auto"
- duplex: "auto"
+ speed: auto
+ duplex: auto
enabled: true
vifs:
- vlan_id: 100
- description: "Eth1 - VIF 100"
+ description: Eth1 - VIF 100
mtu: 400
enabled: true
-
- vlan_id: 101
- description: "Eth1 - VIF 101"
+ description: Eth1 - VIF 101
enabled: true
-
- - name: "eth2"
- description: "Configured by Ansible - Interface 2 (ADMIN DOWN)"
+ - name: eth2
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
mtu: 600
enabled: false
-
populate:
- - name: "eth1"
+ - name: eth1
enabled: true
- speed: "auto"
- duplex: "auto"
- description: "Configured by Ansible"
+ speed: auto
+ duplex: auto
+ description: Configured by Ansible
mtu: 1500
vifs:
- vlan_id: 200
enabled: true
- description: "VIF - 200"
-
- - name: "eth2"
+ description: VIF - 200
+ - name: eth2
enabled: true
- speed: "auto"
- duplex: "auto"
- description: "Configured by Ansible"
+ speed: auto
+ duplex: auto
+ description: Configured by Ansible
mtu: 1500
vifs:
- vlan_id: 200
enabled: true
- description: "VIF - 200"
-
- - name: "eth0"
+ description: VIF - 200
+ - name: eth0
enabled: true
- duplex: "auto"
- speed: "auto"
-
+ duplex: auto
+ speed: auto
replaced:
commands:
- - "delete interfaces ethernet eth1 mtu"
- - "delete interfaces ethernet eth1 speed"
- - "delete interfaces ethernet eth1 duplex"
- - "delete interfaces ethernet eth1 vif 200 description"
- - "set interfaces ethernet eth1 description 'Replaced by Ansible'"
- - "set interfaces ethernet eth1 vif 100 description 'VIF 100 - Replaced by Ansible'"
- - "delete interfaces ethernet eth2 speed"
- - "delete interfaces ethernet eth2 duplex"
- - "delete interfaces ethernet eth2 vif 200 description"
- - "set interfaces ethernet eth2 description 'Replaced by Ansible'"
- - "set interfaces ethernet eth2 mtu '1400'"
-
+ - delete interfaces ethernet eth1 mtu
+ - delete interfaces ethernet eth1 speed
+ - delete interfaces ethernet eth1 duplex
+ - delete interfaces ethernet eth1 vif 200 description
+ - set interfaces ethernet eth1 description 'Replaced by Ansible'
+ - set interfaces ethernet eth1 vif 100 description 'VIF 100 - Replaced by Ansible'
+ - delete interfaces ethernet eth2 speed
+ - delete interfaces ethernet eth2 duplex
+ - delete interfaces ethernet eth2 vif 200 description
+ - set interfaces ethernet eth2 description 'Replaced by Ansible'
+ - set interfaces ethernet eth2 mtu '1400'
after:
- - name: "eth1"
- description: "Replaced by Ansible"
+ - name: eth1
+ description: Replaced by Ansible
enabled: true
vifs:
- vlan_id: 100
enabled: true
- description: "VIF 100 - Replaced by Ansible"
-
+ description: VIF 100 - Replaced by Ansible
- vlan_id: 200
enabled: true
-
- - name: "eth2"
+ - name: eth2
mtu: 1400
- description: "Replaced by Ansible"
+ description: Replaced by Ansible
enabled: true
vifs:
- vlan_id: 200
enabled: true
-
- - name: "eth0"
+ - name: eth0
enabled: true
- duplex: "auto"
- speed: "auto"
-
+ duplex: auto
+ speed: auto
overridden:
commands:
- - "delete interfaces ethernet eth1 description"
- - "delete interfaces ethernet eth1 speed"
- - "delete interfaces ethernet eth1 duplex"
- - "delete interfaces ethernet eth1 mtu"
- - "delete interfaces ethernet eth1 vif 200 description"
- - "delete interfaces ethernet eth2 speed"
- - "delete interfaces ethernet eth2 duplex"
- - "delete interfaces ethernet eth2 vif 200 description"
- - "set interfaces ethernet eth2 description 'Overridden by Ansible'"
- - "set interfaces ethernet eth2 mtu '1200'"
-
+ - delete interfaces ethernet eth1 description
+ - delete interfaces ethernet eth1 speed
+ - delete interfaces ethernet eth1 duplex
+ - delete interfaces ethernet eth1 mtu
+ - delete interfaces ethernet eth1 vif 200 description
+ - delete interfaces ethernet eth2 speed
+ - delete interfaces ethernet eth2 duplex
+ - delete interfaces ethernet eth2 vif 200 description
+ - set interfaces ethernet eth2 description 'Overridden by Ansible'
+ - set interfaces ethernet eth2 mtu '1200'
after:
- - name: "eth0"
+ - name: eth0
enabled: true
- speed: "auto"
- duplex: "auto"
-
- - name: "eth1"
+ speed: auto
+ duplex: auto
+ - name: eth1
enabled: true
vifs:
- vlan_id: 200
enabled: true
-
- - name: "eth2"
+ - name: eth2
enabled: true
- description: "Overridden by Ansible"
+ description: Overridden by Ansible
mtu: 1200
vifs:
- vlan_id: 200
enabled: true
-
deleted:
commands:
- - "delete interfaces ethernet eth1 description"
- - "delete interfaces ethernet eth1 speed"
- - "delete interfaces ethernet eth1 duplex"
- - "delete interfaces ethernet eth1 mtu"
- - "delete interfaces ethernet eth1 vif 200 description"
- - "delete interfaces ethernet eth2 description"
- - "delete interfaces ethernet eth2 speed"
- - "delete interfaces ethernet eth2 duplex"
- - "delete interfaces ethernet eth2 mtu"
- - "delete interfaces ethernet eth2 vif 200 description"
-
+ - delete interfaces ethernet eth1 description
+ - delete interfaces ethernet eth1 speed
+ - delete interfaces ethernet eth1 duplex
+ - delete interfaces ethernet eth1 mtu
+ - delete interfaces ethernet eth1 vif 200 description
+ - delete interfaces ethernet eth2 description
+ - delete interfaces ethernet eth2 speed
+ - delete interfaces ethernet eth2 duplex
+ - delete interfaces ethernet eth2 mtu
+ - delete interfaces ethernet eth2 vif 200 description
after:
- - name: "eth0"
+ - name: eth0
enabled: true
- speed: "auto"
- duplex: "auto"
-
- - name: "eth1"
+ speed: auto
+ duplex: auto
+ - name: eth1
enabled: true
vifs:
- vlan_id: 200
enabled: true
-
- - name: "eth2"
+ - name: eth2
enabled: true
vifs:
- vlan_id: 200
enabled: true
-
round_trip:
after:
- - name: "eth0"
+ - name: eth0
enabled: true
- speed: "auto"
- duplex: "auto"
-
- - name: "eth1"
- description: "Interface 1 - Description (WILL BE REVERTED)"
+ speed: auto
+ duplex: auto
+ - name: eth1
+ description: Interface 1 - Description (WILL BE REVERTED)
enabled: true
mtu: 1200
vifs:
- vlan_id: 100
- description: "Eth1 - VIF 100 (WILL BE REVERTED)"
+ description: Eth1 - VIF 100 (WILL BE REVERTED)
mtu: 400
enabled: true
-
- vlan_id: 101
- description: "Eth1 - VIF 101 (WILL BE REMOVED)"
+ description: Eth1 - VIF 101 (WILL BE REMOVED)
enabled: true
-
- - name: "eth2"
- description: "Interface 2 (ADMIN DOWN) (WILL BE REVERTED)"
+ - name: eth2
+ description: Interface 2 (ADMIN DOWN) (WILL BE REVERTED)
mtu: 600
enabled: false
diff --git a/tests/integration/targets/vyos_l3_interface/defaults/main.yaml b/tests/integration/targets/vyos_l3_interface/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_l3_interface/defaults/main.yaml
+++ b/tests/integration/targets/vyos_l3_interface/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+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
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_l3_interface/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_l3_interface/tasks/main.yaml
+++ b/tests/integration/targets/vyos_l3_interface/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- 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
index 3c24b11..2ffb1ab 100644
--- a/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_l3_interface/tests/cli/basic.yaml
@@ -12,192 +12,220 @@
state: absent
- name: Set IPv4 address
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv4: 192.168.2.10/24
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
- name: Set IPv4 address (idempotent)
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv4: 192.168.2.10/24
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Set IPv6 address
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv6: fd5d:12c9:2201:1::1/64
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands'
- name: Set IPv6 address (idempotent)
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv6: fd5d:12c9:2201:1::1/64
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Remove all IP addresses
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 address" in result.commands'
- name: Remove all IP addresses again (idempotent)
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Set IPv4 and IPv6 address
+ register: result
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'
+ - 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)
+ register: result
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'
+ - result.changed == false
- name: Remove IPv4 address
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv4: 192.168.2.10/24
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands'
- name: Remove IPv4 address again (idempotent)
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv4: 192.168.2.10/24
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Remove IPv6 address
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv6: fd5d:12c9:2201:1::1/64
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands'
- name: Remove IPv6 address again (idempotent)
+ register: result
vyos.vyos.vyos_l3_interface:
name: eth1
ipv6: fd5d:12c9:2201:1::1/64
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Set IP addresses on aggregate
+ register: result
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
+
+ - 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
- assert:
that:
- - 'result.changed == true'
+ - 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)
+ register: result
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
+
+ - 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
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Remove IP addresses on aggregate
+ register: result
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}
+
+ - 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'
+ - 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)
+ register: result
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}
+
+ - 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'
+ - result.changed == false
diff --git a/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml
index 164afea..852a6be 100644
--- a/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "[^_].*"
+testcase: '[^_].*'
test_items: []
diff --git a/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml b/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml
index 337e341..f622cf9 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml
@@ -1,8 +1,8 @@
---
- name: Collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
use_regex: true
register: test_cases
delegate_to: localhost
@@ -11,10 +11,10 @@
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
delegate_to: localhost
-- name: Run test case (connection=network_cli)
- include: "{{ test_case_to_run }}"
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
vars:
- ansible_connection: network_cli
- with_items: "{{ test_items }}"
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml
index d598c42..563b1d7 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml
@@ -1,11 +1,9 @@
---
- name: Setup
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set interfaces ethernet eth1 address '192.0.2.14/24'
- set interfaces ethernet eth2 address '192.0.2.10/24'
- set interfaces ethernet eth2 address '192.0.2.11/24'
- set interfaces ethernet eth2 address '2001:db8::10/32'
- set interfaces ethernet eth2 address '2001:db8::12/32'
+ lines: "set interfaces ethernet eth1 address '192.0.2.14/24'\nset interfaces\
+ \ ethernet eth2 address '192.0.2.10/24'\nset interfaces ethernet eth2 address\
+ \ '192.0.2.11/24'\nset interfaces ethernet eth2 address '2001:db8::10/32'\n\
+ set interfaces ethernet eth2 address '2001:db8::12/32'\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml
index 95b2b8c..1fb0dd3 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml
@@ -1,13 +1,12 @@
---
- name: Remove Config
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- delete interfaces ethernet "{{ intf }}" address
- delete interfaces ethernet "{{ intf }}" vif
+ lines: "delete interfaces ethernet \"{{ intf }}\" address\ndelete interfaces\
+ \ ethernet \"{{ intf }}\" vif\n"
loop:
- eth1
- eth2
loop_control:
loop_var: intf
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml
index b95bcdb..ff4aabf 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml
@@ -1,19 +1,23 @@
---
- debug:
- msg: "Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"
+ msg: Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- include_tasks: _populate.yaml
- name: Delete attributes of given interfaces
- vyos.vyos.vyos_l3_interfaces: &deleted
+ register: result
+ vyos.vyos.vyos_l3_interfaces: &id001
config:
+
- name: eth1
+
- name: eth2
state: deleted
- register: result
- name: Assert that the before dicts were correctly generated
assert:
@@ -23,26 +27,29 @@
- name: Assert that the correct set of commands were generated
assert:
that:
- - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that the after dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ deleted['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Delete attributes of given interfaces (IDEMPOTENT)
- vyos.vyos.vyos_l3_interfaces: *deleted
register: result
+ vyos.vyos.vyos_l3_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: Assert that the before dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ deleted['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
index 7b1f100..96d4cda 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
@@ -1,35 +1,36 @@
---
- debug:
- msg: "START vyos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_l3_interfaces empty_config integration tests on connection={{
+ ansible_connection }}
- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_l3_interfaces:
config:
state: merged
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state merged'
- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_l3_interfaces:
config:
state: replaced
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state replaced'
- name: Overridden with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_l3_interfaces:
config:
state: overridden
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml
index 1b3b9ea..99fb552 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml
@@ -1,58 +1,72 @@
---
- debug:
- msg: "START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- name: Merge the provided configuration with the exisiting running configuration
- vyos.vyos.vyos_l3_interfaces: &merged
+ register: result
+ vyos.vyos.vyos_l3_interfaces: &id001
config:
+
- name: eth1
ipv4:
+
- address: 192.0.2.10/24
ipv6:
+
- address: 2001:db8::10/32
- name: eth2
ipv4:
+
- address: 198.51.100.10/24
vifs:
+
- vlan_id: 101
ipv4:
+
- address: 198.51.100.130/25
ipv6:
+
- address: 2001:db8::20/32
state: merged
- register: result
- name: Assert that before dicts were correctly generated
assert:
- that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}"
+ that: "{{ merged['before'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that after dicts was correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ merged['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
- vyos.vyos.vyos_l3_interfaces: *merged
+ - name: Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_l3_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ merged['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml
index 06d6fc7..644fe08 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml
@@ -1,23 +1,29 @@
---
- debug:
- msg: "START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- include_tasks: _populate.yaml
- name: Overrides all device configuration with provided configuration
- vyos.vyos.vyos_l3_interfaces: &overridden
+ register: result
+ vyos.vyos.vyos_l3_interfaces: &id001
config:
+
- name: eth0
ipv4:
+
- address: dhcp
+
- name: eth1
ipv4:
- - address: "192.0.2.15/24"
+
+ - address: 192.0.2.15/24
state: overridden
- register: result
- name: Assert that before dicts were correctly generated
assert:
@@ -27,26 +33,29 @@
- name: Assert that correct commands were generated
assert:
that:
- - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ overridden['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that after dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ overridden['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Overrides all device configuration with provided configurations (IDEMPOTENT)
- vyos.vyos.vyos_l3_interfaces: *overridden
register: result
+ vyos.vyos.vyos_l3_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ overridden['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml
index 6f1228a..2c664bb 100644
--- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml
@@ -1,28 +1,35 @@
---
- debug:
- msg: "START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- include_tasks: _populate.yaml
- name: Replace device configurations of listed interfaces with provided configurations
- vyos.vyos.vyos_l3_interfaces: &replaced
+ register: result
+ vyos.vyos.vyos_l3_interfaces: &id001
config:
+
- name: eth1
ipv4:
+
- address: 192.0.2.19/24
+
- name: eth2
ipv6:
+
- address: 2001:db8::11/32
state: replaced
- register: result
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ replaced['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that before dicts are correctly generated
assert:
@@ -32,21 +39,24 @@
- name: Assert that after dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ replaced['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT)
- vyos.vyos.vyos_l3_interfaces: *replaced
+ - name: Replace device configurations of listed interfaces with provided configurarions
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_l3_interfaces: *id001
- name: Assert that task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ replaced['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
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
index 1241763..ee329d3 100644
--- a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml
@@ -1,82 +1,68 @@
---
merged:
before:
- - name: "eth0"
+ - name: eth0
ipv4:
- - address: "dhcp"
-
- - name: "eth1"
-
- - name: "eth2"
-
+ - address: dhcp
+ - name: eth1
+ - name: eth2
commands:
- - "set interfaces ethernet eth1 address '192.0.2.10/24'"
- - "set interfaces ethernet eth1 address '2001:db8::10/32'"
- - "set interfaces ethernet eth2 address '198.51.100.10/24'"
- - "set interfaces ethernet eth2 vif 101 address '198.51.100.130/25'"
- - "set interfaces ethernet eth2 vif 101 address '2001:db8::20/32'"
-
+ - set interfaces ethernet eth1 address '192.0.2.10/24'
+ - set interfaces ethernet eth1 address '2001:db8::10/32'
+ - set interfaces ethernet eth2 address '198.51.100.10/24'
+ - set interfaces ethernet eth2 vif 101 address '198.51.100.130/25'
+ - set interfaces ethernet eth2 vif 101 address '2001:db8::20/32'
after:
- - name: "eth0"
+ - name: eth0
ipv4:
- - address: "dhcp"
-
- - name: "eth1"
+ - address: dhcp
+ - name: eth1
ipv4:
- - address: "192.0.2.10/24"
+ - address: 192.0.2.10/24
ipv6:
- - address: "2001:db8::10/32"
-
- - name: "eth2"
+ - address: 2001:db8::10/32
+ - name: eth2
ipv4:
- - address: "198.51.100.10/24"
+ - address: 198.51.100.10/24
vifs:
- vlan_id: 101
ipv4:
- - address: "198.51.100.130/25"
+ - address: 198.51.100.130/25
ipv6:
- - address: "2001:db8::20/32"
-
+ - address: 2001:db8::20/32
populate:
- - name: "eth1"
+ - name: eth1
ipv4:
- - address: "192.0.2.14/24"
-
- - name: "eth2"
+ - address: 192.0.2.14/24
+ - name: eth2
ipv4:
- - address: "192.0.2.10/24"
- - address: "192.0.2.11/24"
+ - address: 192.0.2.10/24
+ - address: 192.0.2.11/24
ipv6:
- - address: "2001:db8::10/32"
- - address: "2001:db8::12/32"
-
- - name: "eth0"
+ - address: 2001:db8::10/32
+ - address: 2001:db8::12/32
+ - name: eth0
ipv4:
- - address: "dhcp"
-
+ - address: dhcp
replaced:
commands:
- - "delete interfaces ethernet eth2 address '192.0.2.10/24'"
- - "delete interfaces ethernet eth2 address '192.0.2.11/24'"
- - "delete interfaces ethernet eth2 address '2001:db8::10/32'"
- - "delete interfaces ethernet eth2 address '2001:db8::12/32'"
- - "set interfaces ethernet eth2 address '2001:db8::11/32'"
- - "delete interfaces ethernet eth1 address '192.0.2.14/24'"
- - "set interfaces ethernet eth1 address '192.0.2.19/24'"
-
+ - delete interfaces ethernet eth2 address '192.0.2.10/24'
+ - delete interfaces ethernet eth2 address '192.0.2.11/24'
+ - delete interfaces ethernet eth2 address '2001:db8::10/32'
+ - delete interfaces ethernet eth2 address '2001:db8::12/32'
+ - set interfaces ethernet eth2 address '2001:db8::11/32'
+ - delete interfaces ethernet eth1 address '192.0.2.14/24'
+ - set interfaces ethernet eth1 address '192.0.2.19/24'
after:
- - name: "eth2"
+ - name: eth2
ipv6:
- - address: "2001:db8::11/32"
-
- - name: "eth1"
+ - address: 2001:db8::11/32
+ - name: eth1
ipv4:
- - address: "192.0.2.19/24"
-
- - name: "eth0"
+ - address: 192.0.2.19/24
+ - name: eth0
ipv4:
- - address: "dhcp"
-
+ - address: dhcp
overridden:
commands:
- delete interfaces ethernet eth1 address '192.0.2.14/24'
@@ -85,18 +71,14 @@ overridden:
- delete interfaces ethernet eth2 address '192.0.2.11/24'
- delete interfaces ethernet eth2 address '2001:db8::10/32'
- delete interfaces ethernet eth2 address '2001:db8::12/32'
-
after:
- - name: "eth0"
+ - name: eth0
ipv4:
- - address: "dhcp"
-
- - name: "eth1"
+ - address: dhcp
+ - name: eth1
ipv4:
- - address: "192.0.2.15/24"
-
- - name: "eth2"
-
+ - address: 192.0.2.15/24
+ - name: eth2
deleted:
commands:
- delete interfaces ethernet eth1 address '192.0.2.14/24'
@@ -105,10 +87,8 @@ deleted:
- delete interfaces ethernet eth2 address '2001:db8::10/32'
- delete interfaces ethernet eth2 address '2001:db8::12/32'
after:
- - name: "eth0"
+ - name: eth0
ipv4:
- - address: "dhcp"
-
- - name: "eth1"
-
- - name: "eth2"
+ - address: dhcp
+ - name: eth1
+ - name: eth2
diff --git a/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml
index 164afea..852a6be 100644
--- a/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "[^_].*"
+testcase: '[^_].*'
test_items: []
diff --git a/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml b/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml
index 655e51e..93eb2fe 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tasks/cli.yaml
@@ -1,8 +1,8 @@
---
- name: Collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
use_regex: true
register: test_cases
delegate_to: localhost
@@ -10,10 +10,10 @@
- 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 }}"
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
vars:
- ansible_connection: network_cli
- with_items: "{{ test_items }}"
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml
index adacb0c..927a6ce 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_add_bond.yaml
@@ -1,8 +1,6 @@
---
- name: Add Bond
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set interfaces bonding bond0
- set interfaces bonding bond1
+ lines: "set interfaces bonding bond0\nset interfaces bonding bond1\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml
index 6139508..f646742 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_populate.yaml
@@ -1,16 +1,11 @@
---
- name: Setup
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set interfaces bonding bond0
- set interfaces bonding bond0 hash-policy 'layer2'
- set interfaces bonding bond0 mode 'active-backup'
- set interfaces ethernet eth1 bond-group bond0
- set interfaces bonding bond1
- set interfaces bonding bond0 primary 'eth1'
- set interfaces bonding bond1 hash-policy 'layer2+3'
- set interfaces bonding bond1 mode 'active-backup'
- set interfaces ethernet eth2 bond-group bond1
- set interfaces bonding bond1 primary 'eth2'
+ lines: "set interfaces bonding bond0\nset interfaces bonding bond0 hash-policy\
+ \ 'layer2'\nset interfaces bonding bond0 mode 'active-backup'\nset interfaces\
+ \ ethernet eth1 bond-group bond0\nset interfaces bonding bond1\nset interfaces\
+ \ bonding bond0 primary 'eth1'\nset interfaces bonding bond1 hash-policy 'layer2+3'\n\
+ set interfaces bonding bond1 mode 'active-backup'\nset interfaces ethernet\
+ \ eth2 bond-group bond1\nset interfaces bonding bond1 primary 'eth2'\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml
index 29085bd..6679d6a 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_bond.yaml
@@ -1,8 +1,6 @@
---
- name: Remove Bond
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- delete interfaces bonding bond0
- delete interfaces bonding bond1
+ lines: "delete interfaces bonding bond0\ndelete interfaces bonding bond1\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml
index c5d3657..5469bf5 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_remove_config.yaml
@@ -1,14 +1,10 @@
---
- name: Remove Config
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- delete interfaces bonding bond0 hash-policy
- delete interfaces ethernet eth1 bond-group bond0
- delete interfaces bonding bond0 mode
- delete interfaces bonding bond0 primary
- delete interfaces bonding bond1 hash-policy
- delete interfaces ethernet eth2 bond-group bond1
- delete interfaces bonding bond1 mode
- delete interfaces bonding bond1 primary
+ lines: "delete interfaces bonding bond0 hash-policy\ndelete interfaces ethernet\
+ \ eth1 bond-group bond0\ndelete interfaces bonding bond0 mode\ndelete interfaces\
+ \ bonding bond0 primary\ndelete interfaces bonding bond1 hash-policy\ndelete\
+ \ interfaces ethernet eth2 bond-group bond1\ndelete interfaces bonding bond1\
+ \ mode\ndelete interfaces bonding bond1 primary\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml
index af6e632..ac8204f 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/deleted.yaml
@@ -1,17 +1,21 @@
---
- debug:
- msg: "Start vyos_lag_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"
+ msg: Start vyos_lag_interfaces deleted integration tests ansible_connection={{
+ ansible_connection }}
- include_tasks: _populate.yaml
- block:
+
- name: Delete attributes of given LAG interfaces.
- vyos.vyos.vyos_lag_interfaces: &deleted
+ register: result
+ vyos.vyos.vyos_lag_interfaces: &id001
config:
+
- name: bond0
+
- name: bond1
state: deleted
- register: result
- name: Assert that the before dicts were correctly generated
assert:
@@ -21,26 +25,29 @@
- name: Assert that the correct set of commands were generated
assert:
that:
- - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that the after dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ deleted['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Delete attributes of given interfaces (IDEMPOTENT)
- vyos.vyos.vyos_lag_interfaces: *deleted
register: result
+ vyos.vyos.vyos_lag_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: Assert that the before dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ deleted['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
index 74d3466..3894fb5 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
@@ -1,35 +1,36 @@
---
- debug:
- msg: "START vyos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lag_interfaces empty_config integration tests on connection={{
+ ansible_connection }}
- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lag_interfaces:
config:
state: merged
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state merged'
- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lag_interfaces:
config:
state: replaced
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state replaced'
- name: Overridden with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lag_interfaces:
config:
state: overridden
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml
index 7b1931f..35f1e35 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/merged.yaml
@@ -1,6 +1,7 @@
---
- debug:
- msg: "START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lag_interfaces merged integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
@@ -9,52 +10,61 @@
- include_tasks: _add_bond.yaml
- block:
+
- name: Merge the provided configuration with the exisiting running configuration
- vyos.vyos.vyos_lag_interfaces: &merged
+ register: result
+ vyos.vyos.vyos_lag_interfaces: &id001
config:
+
- name: bond0
- hash_policy: "layer2"
- mode: "active-backup"
+ hash_policy: layer2
+ mode: active-backup
members:
+
- member: eth1
primary: eth1
- name: bond1
- hash_policy: "layer2+3"
- mode: "active-backup"
+ hash_policy: layer2+3
+ mode: active-backup
members:
+
- member: eth2
primary: eth2
state: merged
- register: result
- name: Assert that before dicts were correctly generated
assert:
- that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}"
+ that: "{{ merged['before'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that after dicts was correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ merged['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
- vyos.vyos.vyos_lag_interfaces: *merged
+ - name: Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_lag_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ merged['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml
index c44cc33..aa6e247 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/overridden.yaml
@@ -1,6 +1,7 @@
---
- debug:
- msg: "START vyos_lag_interfaces overridden integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lag_interfaces overridden integration tests on connection={{
+ ansible_connection }}
- include_tasks: _remove_config.yaml
@@ -9,17 +10,20 @@
- include_tasks: _populate.yaml
- block:
+
- name: Overrides all device configuration with provided configuration
- vyos.vyos.vyos_lag_interfaces: &overridden
+ register: result
+ vyos.vyos.vyos_lag_interfaces: &id001
config:
+
- name: bond1
- mode: "active-backup"
+ mode: active-backup
members:
+
- member: eth2
primary: eth2
hash_policy: layer2
state: overridden
- register: result
- name: Assert that before dicts were correctly generated
assert:
@@ -29,26 +33,29 @@
- name: Assert that correct commands were generated
assert:
that:
- - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ overridden['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that after dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ overridden['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Overrides all device configuration with provided configurations (IDEMPOTENT)
- vyos.vyos.vyos_lag_interfaces: *overridden
register: result
+ vyos.vyos.vyos_lag_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ overridden['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml
index 894d505..c080056 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/replaced.yaml
@@ -1,27 +1,33 @@
---
- debug:
- msg: "START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lag_interfaces replaced integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate.yaml
- block:
- - name: Replace device configurations of listed LAG interfaces with provided configurations
- vyos.vyos.vyos_lag_interfaces: &replaced
+
+ - name: Replace device configurations of listed LAG interfaces with provided
+ configurations
+ register: result
+ vyos.vyos.vyos_lag_interfaces: &id001
config:
+
- name: bond1
- mode: "802.3ad"
- hash_policy: "layer2"
+ mode: 802.3ad
+ hash_policy: layer2
members:
+
- member: eth2
state: replaced
- register: result
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ replaced['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that before dicts are correctly generated
assert:
@@ -31,21 +37,24 @@
- name: Assert that after dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ replaced['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Replace device configurations of listed LAG interfaces with provided configurarions (IDEMPOTENT)
- vyos.vyos.vyos_lag_interfaces: *replaced
+ - name: Replace device configurations of listed LAG interfaces with provided
+ configurarions (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_lag_interfaces: *id001
- name: Assert that task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ replaced['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml
index 3095a12..55e2bbf 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rtt.yaml
@@ -1,31 +1,35 @@
---
- debug:
- msg: "START vyos_lag_interfaces round trip integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lag_interfaces round trip integration tests on connection={{
+ ansible_connection }}
- include_tasks: _remove_config.yaml
- include_tasks: _remove_bond.yaml
- block:
+
- name: Apply the provided configuration (base config)
+ register: base_config
vyos.vyos.vyos_lag_interfaces:
config:
+
- name: bond0
- hash_policy: "layer2"
- mode: "active-backup"
+ hash_policy: layer2
+ mode: active-backup
members:
+
- member: eth1
primary: eth1
- name: bond1
- hash_policy: "layer2+3"
- mode: "active-backup"
+ hash_policy: layer2+3
+ mode: active-backup
members:
+
- member: eth2
primary: eth2
-
state: merged
- register: base_config
- name: Gather lag_interfaces facts
vyos.vyos.vyos_facts:
@@ -35,35 +39,40 @@
- lag_interfaces
- name: Apply the provided configuration (config to be reverted)
+ register: result
vyos.vyos.vyos_lag_interfaces:
config:
+
- name: bond0
- hash_policy: "layer2+3"
- mode: "802.3ad"
+ hash_policy: layer2+3
+ mode: 802.3ad
members:
+
- member: eth1
- name: bond1
- hash_policy: "layer2"
- mode: "xor-hash"
+ hash_policy: layer2
+ mode: xor-hash
members:
+
- member: eth2
state: merged
- register: result
- name: Assert that changes were applied
assert:
- that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Revert back to base config using facts round trip
+ register: revert
vyos.vyos.vyos_lag_interfaces:
config: "{{ ansible_facts['network_resources']['lag_interfaces'] }}"
state: overridden
- register: revert
- name: Assert that config was reverted
assert:
- that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
-
+ that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\
+ \ == 0 }}"
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
index 8726e39..5783693 100644
--- a/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
@@ -1,115 +1,99 @@
---
merged:
before:
- - name: "bond0"
-
- - name: "bond1"
-
+ - name: bond0
+ - name: bond1
commands:
- - "set interfaces bonding bond0 hash-policy 'layer2'"
- - "set interfaces bonding bond0 mode 'active-backup'"
- - "set interfaces ethernet eth1 bond-group 'bond0'"
- - "set interfaces bonding bond0 primary 'eth1'"
- - "set interfaces bonding bond1 hash-policy 'layer2+3'"
- - "set interfaces bonding bond1 mode 'active-backup'"
- - "set interfaces ethernet eth2 bond-group 'bond1'"
- - "set interfaces bonding bond1 primary 'eth2'"
-
+ - set interfaces bonding bond0 hash-policy 'layer2'
+ - set interfaces bonding bond0 mode 'active-backup'
+ - set interfaces ethernet eth1 bond-group 'bond0'
+ - set interfaces bonding bond0 primary 'eth1'
+ - set interfaces bonding bond1 hash-policy 'layer2+3'
+ - set interfaces bonding bond1 mode 'active-backup'
+ - set interfaces ethernet eth2 bond-group 'bond1'
+ - set interfaces bonding bond1 primary 'eth2'
after:
- - name: "bond0"
- hash_policy: "layer2"
+ - name: bond0
+ hash_policy: layer2
members:
- member: eth1
- mode: "active-backup"
+ mode: active-backup
primary: eth1
-
- - name: "bond1"
- hash_policy: "layer2+3"
+ - name: bond1
+ hash_policy: layer2+3
members:
- member: eth2
- mode: "active-backup"
+ mode: active-backup
primary: eth2
-
populate:
- - name: "bond0"
- hash_policy: "layer2"
+ - name: bond0
+ hash_policy: layer2
members:
- member: eth1
- mode: "active-backup"
+ mode: active-backup
primary: eth1
-
- - name: "bond1"
- hash_policy: "layer2+3"
+ - name: bond1
+ hash_policy: layer2+3
members:
- member: eth2
- mode: "active-backup"
+ mode: active-backup
primary: eth2
-
replaced:
commands:
- - "delete interfaces bonding bond1 primary"
- - "set interfaces bonding bond1 hash-policy 'layer2'"
- - "set interfaces bonding bond1 mode '802.3ad'"
-
+ - delete interfaces bonding bond1 primary
+ - set interfaces bonding bond1 hash-policy 'layer2'
+ - set interfaces bonding bond1 mode '802.3ad'
after:
- - name: "bond0"
- hash_policy: "layer2"
+ - name: bond0
+ hash_policy: layer2
members:
- member: eth1
- mode: "active-backup"
+ mode: active-backup
primary: eth1
-
- - name: "bond1"
- hash_policy: "layer2"
+ - name: bond1
+ hash_policy: layer2
members:
- member: eth2
- mode: "802.3ad"
-
+ mode: 802.3ad
overridden:
commands:
- - "delete interfaces bonding bond0 hash-policy"
- - "delete interfaces ethernet eth1 bond-group 'bond0'"
- - "delete interfaces bonding bond0 mode"
- - "delete interfaces bonding bond0 primary"
- - "set interfaces bonding bond1 hash-policy 'layer2'"
-
+ - delete interfaces bonding bond0 hash-policy
+ - delete interfaces ethernet eth1 bond-group 'bond0'
+ - delete interfaces bonding bond0 mode
+ - delete interfaces bonding bond0 primary
+ - set interfaces bonding bond1 hash-policy 'layer2'
after:
- - name: "bond0"
- - name: "bond1"
- hash_policy: "layer2"
+ - name: bond0
+ - name: bond1
+ hash_policy: layer2
members:
- member: eth2
- mode: "active-backup"
+ mode: active-backup
primary: eth2
-
deleted:
commands:
- - "delete interfaces bonding bond0 hash-policy"
- - "delete interfaces ethernet eth1 bond-group 'bond0'"
- - "delete interfaces bonding bond0 mode"
- - "delete interfaces bonding bond0 primary"
- - "delete interfaces bonding bond1 hash-policy"
- - "delete interfaces ethernet eth2 bond-group 'bond1'"
- - "delete interfaces bonding bond1 mode"
- - "delete interfaces bonding bond1 primary"
-
+ - delete interfaces bonding bond0 hash-policy
+ - delete interfaces ethernet eth1 bond-group 'bond0'
+ - delete interfaces bonding bond0 mode
+ - delete interfaces bonding bond0 primary
+ - delete interfaces bonding bond1 hash-policy
+ - delete interfaces ethernet eth2 bond-group 'bond1'
+ - delete interfaces bonding bond1 mode
+ - delete interfaces bonding bond1 primary
after:
- - name: "bond0"
-
- - name: "bond1"
-
+ - name: bond0
+ - name: bond1
round_trip:
after:
- - name: "bond0"
- hash_policy: "layer2+3"
+ - name: bond0
+ hash_policy: layer2+3
members:
- member: eth1
- mode: "802.3ad"
+ mode: 802.3ad
primary: eth1
-
- - name: "bond1"
- hash_policy: "layer2"
+ - name: bond1
+ hash_policy: layer2
members:
- member: eth2
- mode: "xor-hash"
+ mode: xor-hash
primary: eth2
diff --git a/tests/integration/targets/vyos_linkagg/defaults/main.yaml b/tests/integration/targets/vyos_linkagg/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_linkagg/defaults/main.yaml
+++ b/tests/integration/targets/vyos_linkagg/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_linkagg/tasks/cli.yaml b/tests/integration/targets/vyos_linkagg/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_linkagg/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_linkagg/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_linkagg/tasks/main.yaml b/tests/integration/targets/vyos_linkagg/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_linkagg/tasks/main.yaml
+++ b/tests/integration/targets/vyos_linkagg/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml b/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml
index fadbbd7..ffe0c42 100644
--- a/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_linkagg/tests/cli/basic.yaml
@@ -12,173 +12,189 @@
state: absent
- name: Create linkagg
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
members:
- eth1
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces bonding bond0 mode 802.3ad" in result.commands'
- '"set interfaces ethernet eth1 bond-group bond0" in result.commands'
- name: Create linkagg again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
members:
- eth1
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Add linkagg member
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
members:
- eth2
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces ethernet eth2 bond-group bond0" in result.commands'
- name: Add linkagg member again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
members:
- eth2
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Disable linkagg
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
state: down
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces bonding bond0 disable" in result.commands'
- name: Disable linkagg again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
state: down
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Enable linkagg
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
state: up
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces bonding bond0 disable" in result.commands[0]'
- name: Enable linkagg again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
state: up
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Remove linkagg
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 bond-group" in result.commands'
- '"delete interfaces ethernet eth2 bond-group" in result.commands'
- '"delete interfaces bonding bond0" in result.commands'
- name: Remove linkagg again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
name: bond0
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Create collection of linkagg definitions
+ register: result
vyos.vyos.vyos_linkagg:
aggregate:
- - {name: bond0, members: [eth1]}
- - {name: bond1, members: [eth2]}
+
+ - name: bond0
+ members:
+ - eth1
+
+ - name: bond1
+ members:
+ - eth2
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces bonding bond0 mode 802.3ad" in result.commands'
- '"set interfaces ethernet eth1 bond-group bond0" in result.commands'
- '"set interfaces bonding bond1 mode 802.3ad" in result.commands'
- '"set interfaces ethernet eth2 bond-group bond1" in result.commands'
- name: Create collection of linkagg definitions again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
aggregate:
- - {name: bond0, members: [eth1]}
- - {name: bond1, members: [eth2]}
+
+ - name: bond0
+ members:
+ - eth1
+
+ - name: bond1
+ members:
+ - eth2
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Remove collection of linkagg definitions
+ register: result
vyos.vyos.vyos_linkagg:
aggregate:
+
- name: bond0
+
- name: bond1
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete interfaces ethernet eth1 bond-group" in result.commands'
- '"delete interfaces bonding bond0" in result.commands'
- '"delete interfaces ethernet eth2 bond-group" in result.commands'
- '"delete interfaces bonding bond1" in result.commands'
- name: Remove collection of linkagg definitions again (idempotent)
+ register: result
vyos.vyos.vyos_linkagg:
aggregate:
+
- name: bond0
+
- name: bond1
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
diff --git a/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml b/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml
index 93f98e7..8178f92 100644
--- a/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml
+++ b/tests/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml
@@ -1,31 +1,30 @@
---
-- debug: msg="START vyos cli/net_linkagg.yaml on connection={{ ansible_connection }}"
-
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
+- debug: msg="START vyos cli/net_linkagg.yaml on connection={{ ansible_connection
+ }}"
- name: Remove linkagg - set
- net_linkagg:
+ ansible.netcommon.net_linkagg:
name: bond0
state: absent
- name: Create linkagg using platform agnostic module
- net_linkagg:
+ register: result
+ ansible.netcommon.net_linkagg:
name: bond0
members:
- eth1
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set interfaces bonding bond0 mode 802.3ad" in result.commands'
- '"set interfaces ethernet eth1 bond-group bond0" in result.commands'
- name: Remove linkagg - teardown
- net_linkagg:
+ ansible.netcommon.net_linkagg:
name: bond0
state: absent
-- debug: msg="END vyos cli/net_linkagg.yaml on connection={{ ansible_connection }}"
+- debug: msg="END vyos cli/net_linkagg.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_lldp/defaults/main.yaml b/tests/integration/targets/vyos_lldp/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_lldp/defaults/main.yaml
+++ b/tests/integration/targets/vyos_lldp/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_lldp/tasks/cli.yaml b/tests/integration/targets/vyos_lldp/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_lldp/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_lldp/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_lldp/tasks/main.yaml b/tests/integration/targets/vyos_lldp/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_lldp/tasks/main.yaml
+++ b/tests/integration/targets/vyos_lldp/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml b/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml
index badd3a9..b108bbf 100644
--- a/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_lldp/tests/cli/basic.yaml
@@ -6,39 +6,39 @@
lines: delete service lldp
- name: Enable LLDP service
+ register: result
vyos.vyos.vyos_lldp:
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp" in result.commands'
- name: Enable LLDP service again (idempotent)
+ register: result
vyos.vyos.vyos_lldp:
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Disable LLDP service
+ register: result
vyos.vyos.vyos_lldp:
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete service lldp" in result.commands'
- name:
+ register: result
vyos.vyos.vyos_lldp:
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
diff --git a/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml b/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml
index e68d5a6..d19b126 100644
--- a/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml
+++ b/tests/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml
@@ -1,21 +1,18 @@
---
- debug: msg="START vyos cli/net_lldp.yaml on connection={{ ansible_connection }}"
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
-
- name: Make sure LLDP is not running - setup
vyos.vyos.vyos_config:
lines: delete service lldp
- name: Enable LLDP service using platform agnostic module
- net_lldp:
- state: present
register: result
+ ansible.netcommon.net_lldp:
+ state: present
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp" in result.commands'
- name: Make sure LLDP is not running - teardown
diff --git a/tests/integration/targets/vyos_lldp_global/defaults/main.yaml b/tests/integration/targets/vyos_lldp_global/defaults/main.yaml
index 164afea..852a6be 100644
--- a/tests/integration/targets/vyos_lldp_global/defaults/main.yaml
+++ b/tests/integration/targets/vyos_lldp_global/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "[^_].*"
+testcase: '[^_].*'
test_items: []
diff --git a/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml b/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml
index 655e51e..93eb2fe 100644
--- a/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tasks/cli.yaml
@@ -1,8 +1,8 @@
---
- name: Collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
use_regex: true
register: test_cases
delegate_to: localhost
@@ -10,10 +10,10 @@
- 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 }}"
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
vars:
- ansible_connection: network_cli
- with_items: "{{ test_items }}"
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_lldp_global/tasks/main.yaml b/tests/integration/targets/vyos_lldp_global/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_lldp_global/tasks/main.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml
index 088aa7b..e439242 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/_populate.yaml
@@ -1,9 +1,7 @@
---
- name: Setup
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set service lldp
- set service lldp legacy-protocols 'cdp'
- set service lldp management-address '192.0.2.17'
+ lines: "set service lldp\nset service lldp legacy-protocols 'cdp'\nset service\
+ \ lldp management-address '192.0.2.17'\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml
index b000a94..b823449 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/_remove_config.yaml
@@ -1,9 +1,7 @@
---
- name: Remove Config
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- delete service lldp legacy-protocols
- delete service lldp management-address
- delete service lldp
+ lines: "delete service lldp legacy-protocols\ndelete service lldp management-address\n\
+ delete service lldp\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml
index 8017e93..f4c6cbc 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/deleted.yaml
@@ -1,15 +1,17 @@
---
- debug:
- msg: "Start vyos_lldp_global deleted integration tests ansible_connection={{ ansible_connection }}"
+ msg: Start vyos_lldp_global deleted integration tests ansible_connection={{
+ ansible_connection }}
- include_tasks: _populate.yaml
- block:
+
- name: Delete attributes of LLDP service.
- vyos.vyos.vyos_lldp_global: &deleted
+ register: result
+ vyos.vyos.vyos_lldp_global: &id001
config:
state: deleted
- register: result
- name: Assert that the before dicts were correctly generated
assert:
@@ -19,7 +21,8 @@
- name: Assert that the correct set of commands were generated
assert:
that:
- - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that the after dicts were correctly generated
assert:
@@ -27,18 +30,18 @@
- "{{ deleted['after'] == result['after']}}"
- name: Delete attributes of given interfaces (IDEMPOTENT)
- vyos.vyos.vyos_lldp_global: *deleted
register: result
+ vyos.vyos.vyos_lldp_global: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: Assert that the before dicts were correctly generated
assert:
that:
- "{{ deleted['after'] == result['before'] }}"
-
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml
index 05609b6..a197c45 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml
@@ -1,24 +1,25 @@
---
- debug:
- msg: "START vyos_lldp_global empty_config integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_global empty_config integration tests on connection={{
+ ansible_connection }}
- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lldp_global:
config:
state: merged
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state merged'
- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lldp_global:
config:
state: replaced
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml
index a17bd61..aeabc9f 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/merged.yaml
@@ -1,21 +1,23 @@
---
- debug:
- msg: "START vyos_lldp_global merged integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_global merged integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate.yaml
- block:
+
- name: Merge the provided configuration with the exisiting running configuration
- vyos.vyos.vyos_lldp_global: &merged
+ register: result
+ vyos.vyos.vyos_lldp_global: &id001
config:
legacy_protocols:
- - 'fdp'
- - 'cdp'
+ - fdp
+ - cdp
address: 192.0.2.11
state: merged
- register: result
- name: Assert that before dicts were correctly generated
assert:
@@ -24,26 +26,28 @@
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that after dicts was correctly generated
assert:
that:
- "{{ merged['after'] == result['after'] }}"
- - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
- vyos.vyos.vyos_lldp_global: *merged
+ - name: Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_lldp_global: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- "{{ merged['after'] == result['before'] }}"
-
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml
index 371e7f3..9a833f5 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/replaced.yaml
@@ -1,27 +1,30 @@
---
- debug:
- msg: "START vyos_lldp_global replaced integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_global replaced integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate.yaml
- block:
+
- name: Replace device configurations of LLDP service with provided configurations
- vyos.vyos.vyos_lldp_global: &replaced
+ register: result
+ vyos.vyos.vyos_lldp_global: &id001
config:
legacy_protocols:
- - 'edp'
- - 'sonmp'
- - 'cdp'
+ - edp
+ - sonmp
+ - cdp
address: 192.0.2.14
state: replaced
- register: result
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ replaced['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that before dicts are correctly generated
assert:
@@ -33,19 +36,20 @@
that:
- "{{ replaced['after'] == result['after'] }}"
- - name: Replace device configurations of LLDP service with provided configurarions (IDEMPOTENT)
- vyos.vyos.vyos_lldp_global: *replaced
+ - name: Replace device configurations of LLDP service with provided configurarions
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_lldp_global: *id001
- name: Assert that task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dict is correctly generated
assert:
that:
- "{{ replaced['after'] == result['before'] }}"
-
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml
index 02902bc..2e8284f 100644
--- a/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/rtt.yaml
@@ -1,19 +1,21 @@
---
- debug:
- msg: "START vyos_lldp_global round trip integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_global round trip integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- name: Apply the provided configuration (base config)
+ register: base_config
vyos.vyos.vyos_lldp_global:
config:
legacy_protocols:
- - 'fdp'
- - 'cdp'
+ - fdp
+ - cdp
address: 192.0.2.11
state: merged
- register: base_config
- name: Gather vyos_lldp_global facts
vyos.vyos.vyos_facts:
@@ -23,29 +25,29 @@
- lldp_global
- name: Apply the provided configuration (config to be reverted)
+ register: result
vyos.vyos.vyos_lldp_global:
config:
legacy_protocols:
- - 'edp'
- - 'sonmp'
- - 'cdp'
+ - edp
+ - sonmp
+ - cdp
address: 192.0.2.14
state: merged
- register: result
- name: Assert that changes were applied
assert:
that: "{{ round_trip['after'] == result['after'] }}"
- name: Revert back to base config using facts round trip
+ register: revert
vyos.vyos.vyos_lldp_global:
config: "{{ ansible_facts['network_resources']['lldp_global'] }}"
state: replaced
- register: revert
- name: Assert that config was reverted
assert:
that: "{{ base_config['after'] == revert['after'] }}"
-
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_global/vars/main.yaml b/tests/integration/targets/vyos_lldp_global/vars/main.yaml
index 420b2b4..81e71be 100644
--- a/tests/integration/targets/vyos_lldp_global/vars/main.yaml
+++ b/tests/integration/targets/vyos_lldp_global/vars/main.yaml
@@ -1,56 +1,48 @@
---
merged:
before:
- address: '192.0.2.17'
+ address: 192.0.2.17
enable: true
legacy_protocols:
- - 'cdp'
-
+ - cdp
commands:
- - "set service lldp management-address '192.0.2.11'"
- - "set service lldp legacy-protocols 'fdp'"
-
+ - set service lldp management-address '192.0.2.11'
+ - set service lldp legacy-protocols 'fdp'
after:
- address: '192.0.2.11'
+ address: 192.0.2.11
enable: true
legacy_protocols:
- - 'cdp'
- - 'fdp'
-
+ - cdp
+ - fdp
populate:
- address: '192.0.2.17'
+ address: 192.0.2.17
enable: true
legacy_protocols:
- - 'cdp'
-
+ - cdp
replaced:
commands:
- - "set service lldp legacy-protocols 'edp'"
- - "set service lldp legacy-protocols 'sonmp'"
- - "set service lldp management-address '192.0.2.14'"
-
+ - set service lldp legacy-protocols 'edp'
+ - set service lldp legacy-protocols 'sonmp'
+ - set service lldp management-address '192.0.2.14'
after:
- address: '192.0.2.14'
+ address: 192.0.2.14
enable: true
legacy_protocols:
- - 'cdp'
- - 'edp'
- - 'sonmp'
-
+ - cdp
+ - edp
+ - sonmp
deleted:
commands:
- - "delete service lldp management-address"
- - "delete service lldp legacy-protocols"
-
+ - delete service lldp management-address
+ - delete service lldp legacy-protocols
after:
- "enable": true
-
+ enable: true
round_trip:
after:
- address: '192.0.2.14'
+ address: 192.0.2.14
enable: true
legacy_protocols:
- - 'cdp'
- - 'edp'
- - 'fdp'
- - 'sonmp'
+ - cdp
+ - edp
+ - fdp
+ - sonmp
diff --git a/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml b/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml
+++ b/tests/integration/targets/vyos_lldp_interface/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml b/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_lldp_interface/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_lldp_interface/tasks/main.yaml b/tests/integration/targets/vyos_lldp_interface/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_lldp_interface/tasks/main.yaml
+++ b/tests/integration/targets/vyos_lldp_interface/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml b/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml
index 0690e9e..2697f48 100644
--- a/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml
@@ -6,162 +6,176 @@
lines: delete service lldp
- name: Create LLDP configuration
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp interface eth1" in result.commands'
- name: Create LLDP configuration again (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Disable LLDP configuration
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: disabled
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp interface eth1 disable" in result.commands'
- name: Disable LLDP configuration again (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: disabled
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Enable LLDP configuration
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: enabled
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete service lldp interface eth1 disable" in result.commands'
- name: Enable LLDP configuration again (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: enabled
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Delete LLDP configuration
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete service lldp interface eth1" in result.commands'
- name: Delete LLDP configuration again (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
name: eth1
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Create aggregate of LLDP interface configurations
+ register: result
vyos.vyos.vyos_lldp_interface:
aggregate:
+
- name: eth1
+
- name: eth2
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp interface eth1" in result.commands'
- '"set service lldp interface eth2" in result.commands'
- name: Create aggregate of LLDP interface configurations again (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
aggregate:
+
- name: eth1
+
- name: eth2
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Override LLDP interface configuration on aggregate
+ register: result
vyos.vyos.vyos_lldp_interface:
aggregate:
+
- name: eth1
- - {name: eth2, state: disabled}
+
+ - name: eth2
+ state: disabled
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp interface eth2 disable" in result.commands'
- name: Override LLDP interface configuration on aggregate again (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
aggregate:
+
- name: eth1
- - {name: eth2, state: disabled}
+
+ - name: eth2
+ state: disabled
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Delete aggregate of LLDP interface configurations
+ register: result
vyos.vyos.vyos_lldp_interface:
aggregate:
+
- name: eth1
+
- name: eth2
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete service lldp interface eth1" in result.commands'
- '"delete service lldp interface eth2" in result.commands'
- name: Delete aggregate of LLDP interface configurations (idempotent)
+ register: result
vyos.vyos.vyos_lldp_interface:
aggregate:
+
- name: eth1
+
- name: eth2
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
diff --git a/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml b/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml
index 1710b7e..98fc93a 100644
--- a/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml
+++ b/tests/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml
@@ -1,26 +1,25 @@
---
-- debug: msg="START vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection }}"
-
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
+- debug: msg="START vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection
+ }}"
- name: Make sure LLDP is not running - setup
vyos.vyos.vyos_config:
lines: delete service lldp
- name: Create LLDP configuration using platform agnostic module
- net_lldp_interface:
+ register: result
+ ansible.netcommon.net_lldp_interface:
name: eth1
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set service lldp interface eth1" in result.commands'
- name: Make sure LLDP is not running - teardown
vyos.vyos.vyos_config:
lines: delete service lldp
-- debug: msg="END vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection }}"
+- debug: msg="END vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
index 164afea..852a6be 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "[^_].*"
+testcase: '[^_].*'
test_items: []
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml b/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml
index 655e51e..93eb2fe 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tasks/cli.yaml
@@ -1,8 +1,8 @@
---
- name: Collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ paths: '{{ role_path }}/tests/cli'
+ patterns: '{{ testcase }}.yaml'
use_regex: true
register: test_cases
delegate_to: localhost
@@ -10,10 +10,10 @@
- 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 }}"
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }}'
vars:
- ansible_connection: network_cli
- with_items: "{{ test_items }}"
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: '{{ test_items }}'
loop_control:
loop_var: test_case_to_run
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml
index 80f7d1a..4353cec 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate.yaml
@@ -1,14 +1,12 @@
---
- name: Setup
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set service lldp interface eth1
- set service lldp interface eth1 location civic-based country-code US
- set service lldp interface eth1 location civic-based ca-type 0 ca-value ENGLISH
- set service lldp interface eth2
- set service lldp interface eth2 location coordinate-based latitude 33.524449N
- set service lldp interface eth2 location coordinate-based altitude 2200
- set service lldp interface eth2 location coordinate-based datum WGS84
- set service lldp interface eth2 location coordinate-based longitude 222.267255W
+ lines: "set service lldp interface eth1\nset service lldp interface eth1 location\
+ \ civic-based country-code US\nset service lldp interface eth1 location civic-based\
+ \ ca-type 0 ca-value ENGLISH\nset service lldp interface eth2\nset service\
+ \ lldp interface eth2 location coordinate-based latitude 33.524449N\nset service\
+ \ lldp interface eth2 location coordinate-based altitude 2200\nset service\
+ \ lldp interface eth2 location coordinate-based datum WGS84\nset service lldp\
+ \ interface eth2 location coordinate-based longitude 222.267255W\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml
index ee9a9bd..11e2940 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_populate_intf.yaml
@@ -1,10 +1,8 @@
---
- name: Setup
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- set service lldp interface eth2
- set service lldp interface eth2 location civic-based country-code US
- set service lldp interface eth2 location civic-based ca-type 0 ca-value ENGLISH
- set service lldp interface eth2 disable
+ lines: "set service lldp interface eth2\nset service lldp interface eth2 location\
+ \ civic-based country-code US\nset service lldp interface eth2 location civic-based\
+ \ ca-type 0 ca-value ENGLISH\nset service lldp interface eth2 disable\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml
index d012f7b..a885f01 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_remove_config.yaml
@@ -1,8 +1,6 @@
---
- name: Remove Config
- network.cli.cli_config:
- config: "{{ lines }}"
vars:
- lines: |
- delete service lldp interface
- delete service lldp
+ lines: "delete service lldp interface\ndelete service lldp\n"
+ ansible.netcommon.cli_config:
+ config: '{{ lines }}'
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml
index 7b2d53a..21bf96d 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/deleted.yaml
@@ -1,17 +1,21 @@
---
- debug:
- msg: "Start vyos_lldp_interfaces deleted integration tests ansible_connection={{ ansible_connection }}"
+ msg: Start vyos_lldp_interfaces deleted integration tests ansible_connection={{
+ ansible_connection }}
- include_tasks: _populate.yaml
- block:
+
- name: Delete attributes of given LLDP interfaces.
- vyos.vyos.vyos_lldp_interfaces: &deleted
+ register: result
+ vyos.vyos.vyos_lldp_interfaces: &id001
config:
- - name: 'eth1'
- - name: 'eth2'
+
+ - name: eth1
+
+ - name: eth2
state: deleted
- register: result
- name: Assert that the before dicts were correctly generated
assert:
@@ -21,26 +25,30 @@
- name: Assert that the correct set of commands were generated
assert:
that:
- - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that the after dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ deleted['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Delete attributes of given interfaces (IDEMPOTENT)
- vyos.vyos.vyos_lldp_interfaces: *deleted
register: result
+ vyos.vyos.vyos_lldp_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result.changed == false"
- - "result.commands|length == 0"
+ - result.changed == false
+ - result.commands|length == 0
- name: Assert that the before dicts were correctly generated
assert:
that:
- - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}"
+ - "{{ deleted['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
index 44c0b89..a5ff0a8 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
@@ -1,35 +1,36 @@
---
- debug:
- msg: "START vyos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_interfaces empty_config integration tests on connection={{
+ ansible_connection }}
- name: Merged with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lldp_interfaces:
config:
state: merged
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state merged'
- name: Replaced with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lldp_interfaces:
config:
state: replaced
- register: result
- ignore_errors: true
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state replaced'
- name: Overridden with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_lldp_interfaces:
config:
state: overridden
- register: result
- ignore_errors: true
- assert:
that:
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml
index bf968b2..657961f 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/merged.yaml
@@ -1,58 +1,67 @@
---
- debug:
- msg: "START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_interfaces merged integration tests on connection={{ ansible_connection
+ }}
- include_tasks: _remove_config.yaml
- block:
+
- name: Merge the provided configuration with the exisiting running configuration
- vyos.vyos.vyos_lldp_interfaces: &merged
+ register: result
+ vyos.vyos.vyos_lldp_interfaces: &id001
config:
- - name: 'eth1'
+
+ - name: eth1
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
+
- ca_type: 0
- ca_value: 'ENGLISH'
+ ca_value: ENGLISH
- - name: 'eth2'
+ - name: eth2
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
state: merged
- register: result
- name: Assert that before dicts were correctly generated
assert:
- that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}"
+ that: "{{ merged['before'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
+ \ == 0 }}"
- name: Assert that after dicts was correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ merged['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
- vyos.vyos.vyos_lldp_interfaces: *merged
+ - name: Merge the provided configuration with the existing running configuration
+ (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_lldp_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ merged['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml
index 8cf038c..3e6ce40 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/overridden.yaml
@@ -1,49 +1,56 @@
---
- debug:
- msg: "START vyos_lldp_interfaces overridden integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_interfaces overridden integration tests on connection={{
+ ansible_connection }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate_intf.yaml
- block:
+
- name: Overrides all device configuration with provided configuration
- vyos.vyos.vyos_lldp_interfaces: &overridden
+ register: result
+ vyos.vyos.vyos_lldp_interfaces: &id001
config:
- - name: 'eth2'
+
+ - name: eth2
location:
- elin: '0000000911'
+ elin: 0000000911
state: overridden
- register: result
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ populate_intf | symmetric_difference(result['before']) |length == 0 }}"
+ - "{{ populate_intf | symmetric_difference(result['before']) |length ==\
+ \ 0 }}"
- name: Assert that correct commands were generated
assert:
that:
- - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ overridden['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that after dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ overridden['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Overrides all device configuration with provided configurations (IDEMPOTENT)
- vyos.vyos.vyos_lldp_interfaces: *overridden
register: result
+ vyos.vyos.vyos_lldp_interfaces: *id001
- name: Assert that the previous task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dicts were correctly generated
assert:
that:
- - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ overridden['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml
index 17acf06..3218e80 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/replaced.yaml
@@ -1,39 +1,45 @@
---
- debug:
- msg: "START vyos_lldp_interfaces replaced integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_interfaces replaced integration tests on connection={{
+ ansible_connection }}
- include_tasks: _remove_config.yaml
- include_tasks: _populate.yaml
- block:
- - name: Replace device configurations of listed LLDP interfaces with provided configurations
- vyos.vyos.vyos_lldp_interfaces: &replaced
+
+ - name: Replace device configurations of listed LLDP interfaces with provided
+ configurations
+ register: result
+ vyos.vyos.vyos_lldp_interfaces: &id001
config:
- - name: 'eth2'
+
+ - name: eth2
enable: false
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
+
- ca_type: 0
- ca_value: 'ENGLISH'
+ ca_value: ENGLISH
- - name: 'eth1'
+ - name: eth1
enable: false
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
state: replaced
- register: result
- name: Assert that correct set of commands were generated
assert:
that:
- - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}"
+ - "{{ replaced['commands'] | symmetric_difference(result['commands'])\
+ \ |length == 0 }}"
- name: Assert that before dicts are correctly generated
assert:
@@ -43,21 +49,24 @@
- name: Assert that after dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ - "{{ replaced['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- - name: Replace device configurations of listed LLDP interfaces with provided configurarions (IDEMPOTENT)
- vyos.vyos.vyos_lldp_interfaces: *replaced
+ - name: Replace device configurations of listed LLDP interfaces with provided
+ configurarions (IDEMPOTENT)
register: result
+ vyos.vyos.vyos_lldp_interfaces: *id001
- name: Assert that task was idempotent
assert:
that:
- - "result['changed'] == false"
+ - result['changed'] == false
- name: Assert that before dict is correctly generated
assert:
that:
- - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}"
-
+ - "{{ replaced['after'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
always:
+
- include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml
index 4d4cf82..e6189a3 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rtt.yaml
@@ -1,23 +1,26 @@
---
- debug:
- msg: "START vyos_lldp_interfaces round trip integration tests on connection={{ ansible_connection }}"
+ msg: START vyos_lldp_interfaces round trip integration tests on connection={{
+ ansible_connection }}
- include_tasks: _remove_config.yaml
- block:
+
- name: Apply the provided configuration (base config)
+ register: base_config
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: 'eth1'
+
+ - name: eth1
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
- - ca_type: 0
- ca_value: 'ENGLISH'
+ - ca_type: 0
+ ca_value: ENGLISH
state: merged
- register: base_config
- name: Gather lldp_interfaces facts
vyos.vyos.vyos_facts:
@@ -27,31 +30,34 @@
- lldp_interfaces
- name: Apply the provided configuration (config to be reverted)
+ register: result
vyos.vyos.vyos_lldp_interfaces:
config:
- - name: 'eth2'
+
+ - name: eth2
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
state: merged
- register: result
- name: Assert that changes were applied
assert:
- that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"
+ that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
- name: Revert back to base config using facts round trip
+ register: revert
vyos.vyos.vyos_lldp_interfaces:
config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}"
state: overridden
- register: revert
- name: Assert that config was reverted
assert:
- that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
-
+ that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length\
+ \ == 0 }}"
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
index 169b0d5..3cb684e 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
@@ -1,130 +1,114 @@
---
merged:
before: []
-
-
commands:
- - "set service lldp interface eth1 location civic-based country-code 'US'"
- - "set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'"
- - "set service lldp interface eth1"
- - "set service lldp interface eth2 location coordinate-based latitude '33.524449N'"
- - "set service lldp interface eth2 location coordinate-based altitude '2200'"
- - "set service lldp interface eth2 location coordinate-based datum 'WGS84'"
- - "set service lldp interface eth2 location coordinate-based longitude '222.267255W'"
- - "set service lldp interface eth2 location coordinate-based latitude '33.524449N'"
- - "set service lldp interface eth2 location coordinate-based altitude '2200'"
- - "set service lldp interface eth2 location coordinate-based datum 'WGS84'"
- - "set service lldp interface eth2 location coordinate-based longitude '222.267255W'"
- - "set service lldp interface eth2"
-
+ - set service lldp interface eth1 location civic-based country-code 'US'
+ - set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'
+ - set service lldp interface eth1
+ - set service lldp interface eth2 location coordinate-based latitude '33.524449N'
+ - set service lldp interface eth2 location coordinate-based altitude '2200'
+ - set service lldp interface eth2 location coordinate-based datum 'WGS84'
+ - set service lldp interface eth2 location coordinate-based longitude '222.267255W'
+ - set service lldp interface eth2 location coordinate-based latitude '33.524449N'
+ - set service lldp interface eth2 location coordinate-based altitude '2200'
+ - set service lldp interface eth2 location coordinate-based datum 'WGS84'
+ - set service lldp interface eth2 location coordinate-based longitude '222.267255W'
+ - set service lldp interface eth2
after:
- - name: 'eth1'
+ - name: eth1
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
- ca_type: 0
- ca_value: 'ENGLISH'
-
- - name: 'eth2'
+ ca_value: ENGLISH
+ - name: eth2
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
-
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
populate:
- - name: 'eth1'
+ - name: eth1
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
- ca_type: 0
- ca_value: 'ENGLISH'
-
- - name: 'eth2'
+ ca_value: ENGLISH
+ - name: eth2
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
-
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
replaced:
commands:
- - "delete service lldp interface eth2 location"
- - "set service lldp interface eth2 'disable'"
- - "set service lldp interface eth2 location civic-based country-code 'US'"
- - "set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'"
- - "delete service lldp interface eth1 location"
- - "set service lldp interface eth1 'disable'"
- - "set service lldp interface eth1 location coordinate-based latitude '33.524449N'"
- - "set service lldp interface eth1 location coordinate-based altitude '2200'"
- - "set service lldp interface eth1 location coordinate-based datum 'WGS84'"
- - "set service lldp interface eth1 location coordinate-based longitude '222.267255W'"
-
+ - delete service lldp interface eth2 location
+ - set service lldp interface eth2 'disable'
+ - set service lldp interface eth2 location civic-based country-code 'US'
+ - set service lldp interface eth2 location civic-based ca-type 0 ca-value 'ENGLISH'
+ - delete service lldp interface eth1 location
+ - set service lldp interface eth1 'disable'
+ - set service lldp interface eth1 location coordinate-based latitude '33.524449N'
+ - set service lldp interface eth1 location coordinate-based altitude '2200'
+ - set service lldp interface eth1 location coordinate-based datum 'WGS84'
+ - set service lldp interface eth1 location coordinate-based longitude '222.267255W'
after:
- - name: 'eth2'
+ - name: eth2
enable: false
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
- ca_type: 0
- ca_value: 'ENGLISH'
-
- - name: 'eth1'
+ ca_value: ENGLISH
+ - name: eth1
enable: false
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
-
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
populate_intf:
- - name: 'eth2'
+ - name: eth2
enable: false
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
- ca_type: 0
- ca_value: 'ENGLISH'
-
+ ca_value: ENGLISH
overridden:
commands:
- - "delete service lldp interface eth2 location"
- - "delete service lldp interface eth2 'disable'"
- - "set service lldp interface eth2 location elin '0000000911'"
-
+ - delete service lldp interface eth2 location
+ - delete service lldp interface eth2 'disable'
+ - set service lldp interface eth2 location elin '0000000911'
after:
- - name: 'eth2'
+ - name: eth2
location:
elin: 0000000911
-
deleted:
commands:
- - "delete service lldp interface eth1"
- - "delete service lldp interface eth2"
-
+ - delete service lldp interface eth1
+ - delete service lldp interface eth2
after: []
-
round_trip:
after:
- - name: 'eth1'
+ - name: eth1
location:
civic_based:
- country_code: 'US'
+ country_code: US
ca_info:
- ca_type: 0
- ca_value: 'ENGLISH'
-
- - name: 'eth2'
+ ca_value: ENGLISH
+ - name: eth2
location:
coordinate_based:
altitude: 2200
- datum: 'WGS84'
- longitude: '222.267255W'
- latitude: '33.524449N'
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
diff --git a/tests/integration/targets/vyos_logging/defaults/main.yaml b/tests/integration/targets/vyos_logging/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_logging/defaults/main.yaml
+++ b/tests/integration/targets/vyos_logging/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_logging/tasks/cli.yaml b/tests/integration/targets/vyos_logging/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_logging/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_logging/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_logging/tasks/main.yaml b/tests/integration/targets/vyos_logging/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_logging/tasks/main.yaml
+++ b/tests/integration/targets/vyos_logging/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_logging/tests/cli/basic.yaml b/tests/integration/targets/vyos_logging/tests/cli/basic.yaml
index d588456..a025047 100644
--- a/tests/integration/targets/vyos_logging/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_logging/tests/cli/basic.yaml
@@ -2,125 +2,154 @@
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
- name: set-up logging
+ register: result
vyos.vyos.vyos_logging:
dest: console
facility: all
level: info
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set system syslog console facility all level info" in result.commands'
- name: set-up logging again (idempotent)
+ register: result
vyos.vyos.vyos_logging:
dest: console
facility: all
level: info
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: file logging
+ register: result
vyos.vyos.vyos_logging:
dest: file
name: test
facility: all
level: notice
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set system syslog file test facility all level notice" in result.commands'
- name: file logging again (idempotent)
+ register: result
vyos.vyos.vyos_logging:
dest: file
name: test
facility: all
level: notice
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: delete logging
+ register: result
vyos.vyos.vyos_logging:
dest: file
name: test
facility: all
level: notice
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete system syslog file test facility all level notice" in result.commands'
- name: delete logging again (idempotent)
+ register: result
vyos.vyos.vyos_logging:
dest: file
name: test
facility: all
level: notice
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Add logging collections
+ register: result
vyos.vyos.vyos_logging:
aggregate:
- - {dest: file, name: test1, facility: all, level: info}
- - {dest: file, name: test2, facility: news, level: debug}
+
+ - dest: file
+ name: test1
+ facility: all
+ level: info
+
+ - dest: file
+ name: test2
+ facility: news
+ level: debug
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set system syslog file test1 facility all level info" in result.commands'
- '"set system syslog file test2 facility news level debug" in result.commands'
- name: Add and remove logging collections with overrides
+ register: result
vyos.vyos.vyos_logging:
aggregate:
- - {dest: console, facility: all, level: info}
- - {dest: file, name: test1, facility: all, level: info, state: absent}
- - {dest: console, facility: daemon, level: warning}
+
+ - dest: console
+ facility: all
+ level: info
+
+ - dest: file
+ name: test1
+ facility: all
+ level: info
+ state: absent
+
+ - dest: console
+ facility: daemon
+ level: warning
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete system syslog file test1 facility all level info" in result.commands'
- '"set system syslog console facility daemon level warning" in result.commands'
- name: Remove logging collections
+ register: result
vyos.vyos.vyos_logging:
aggregate:
- - {dest: console, facility: all, level: info}
- - {dest: console, facility: daemon, level: warning}
- - {dest: file, name: test2, facility: news, level: debug}
+
+ - dest: console
+ facility: all
+ level: info
+
+ - dest: console
+ facility: daemon
+ level: warning
+
+ - dest: file
+ name: test2
+ facility: news
+ level: debug
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete system syslog console facility all level info" in result.commands'
- '"delete system syslog console facility daemon level warning" in result.commands'
- '"delete system syslog file test2 facility news level debug" in result.commands'
diff --git a/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml b/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml
index 7c62d72..f8bda74 100644
--- a/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml
+++ b/tests/integration/targets/vyos_logging/tests/cli/net_logging.yaml
@@ -1,39 +1,38 @@
---
-- debug: msg="START vyos cli/net_logging.yaml on connection={{ ansible_connection }}"
-
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
+- debug: msg="START vyos cli/net_logging.yaml on connection={{ ansible_connection
+ }}"
- name: delete logging - setup
- net_logging:
+ register: result
+ ansible.netcommon.net_logging:
dest: file
name: test
facility: all
level: notice
state: absent
- register: result
- name: file logging using platform agnostic module
- net_logging:
+ register: result
+ ansible.netcommon.net_logging:
dest: file
name: test
facility: all
level: notice
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set system syslog file test facility all level notice" in result.commands'
- name: delete logging - teardown
- net_logging:
+ register: result
+ ansible.netcommon.net_logging:
dest: file
name: test
facility: all
level: notice
state: absent
- register: result
-- debug: msg="END vyos cli/net_logging.yaml on connection={{ ansible_connection }}"
+- debug: msg="END vyos cli/net_logging.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_smoke/defaults/main.yaml b/tests/integration/targets/vyos_smoke/defaults/main.yaml
deleted file mode 100644
index 9ef5ba5..0000000
--- a/tests/integration/targets/vyos_smoke/defaults/main.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-testcase: "*"
-test_items: []
diff --git a/tests/integration/targets/vyos_smoke/tasks/cli.yaml b/tests/integration/targets/vyos_smoke/tasks/cli.yaml
deleted file mode 100644
index 890d3ac..0000000
--- a/tests/integration/targets/vyos_smoke/tasks/cli.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
----
-- 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_smoke/tasks/main.yaml b/tests/integration/targets/vyos_smoke/tasks/main.yaml
deleted file mode 100644
index d4cf26f..0000000
--- a/tests/integration/targets/vyos_smoke/tasks/main.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- {include: cli.yaml, tags: ['cli']}
diff --git a/tests/integration/targets/vyos_smoke/tests/cli/common_config.yaml b/tests/integration/targets/vyos_smoke/tests/cli/common_config.yaml
deleted file mode 100644
index cfac254..0000000
--- a/tests/integration/targets/vyos_smoke/tests/cli/common_config.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
----
-# vyos.py in plugins and module_utils/network covered by these as well
-# hit NetworkConfig
-- name: configure simple config command
- vyos.vyos.vyos_config:
- lines: set system host-name smoke
-
-- name: return host name to inventory_hostname
- vyos.vyos.vyos_config:
- lines: set system host-name {{ inventory_hostname_short }}
- match: none
diff --git a/tests/integration/targets/vyos_smoke/tests/cli/common_utils.yaml b/tests/integration/targets/vyos_smoke/tests/cli/common_utils.yaml
deleted file mode 100644
index fb80c93..0000000
--- a/tests/integration/targets/vyos_smoke/tests/cli/common_utils.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
----
-# vyos.py in plugins and module_utils/network covered by these as well
-# remove_default_spec() hit by multiple plays
-
-# hit ComplexList
-- name: get output for single command
- vyos.vyos.vyos_command:
- commands:
- - show version
- register: result
-
-- assert:
- that:
- - result.changed == false
- - result.stdout is defined
- - result.stdout_lines is defined
-
-# hit conditional() - used for declarative intent
-# Note, this can't be run on AWS because fully testing the vyos_interface dependencies
-# requires the ability to create and remove interfaces other than eth0
-- name: enable eth1
- vyos.vyos.vyos_interface:
- name: eth1
- enabled: true
- state: present
- register: result
-
-- name: Check intent arguments
- vyos.vyos.vyos_interface:
- name: eth1
- state: up
- register: result
-
-- name: Check intent arguments (failed condition)
- vyos.vyos.vyos_interface:
- name: eth1
- state: down
- ignore_errors: true
- register: result
-
-- assert:
- that:
- - "result.failed == true"
- - "'state eq(down)' in result.failed_conditions"
-
-- name: Config + intent
- vyos.vyos.vyos_interface:
- name: eth1
- enabled: false
- state: down
diff --git a/tests/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml b/tests/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml
deleted file mode 100644
index 456effc..0000000
--- a/tests/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-# hit check conditional in module_utils.network.vyos -> load_config()
-- name: configure simple config command
- vyos.vyos.vyos_config:
- lines: set system host-name check-test
- check_mode: true
-
-- name: get host name
- vyos.vyos.vyos_command:
- commands: show host name
- register: result
-
-- assert:
- that: '"check-test" not in result.stdout'
diff --git a/tests/integration/targets/vyos_static_route/defaults/main.yaml b/tests/integration/targets/vyos_static_route/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_static_route/defaults/main.yaml
+++ b/tests/integration/targets/vyos_static_route/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_static_route/tasks/cli.yaml b/tests/integration/targets/vyos_static_route/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_static_route/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_static_route/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_static_route/tasks/main.yaml b/tests/integration/targets/vyos_static_route/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_static_route/tasks/main.yaml
+++ b/tests/integration/targets/vyos_static_route/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml b/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml
index 4b1ef1c..be93e89 100644
--- a/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml
@@ -2,119 +2,136 @@
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
- name: create static route
+ register: result
vyos.vyos.vyos_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands'
- name: create static route again (idempotent)
+ register: result
vyos.vyos.vyos_static_route:
prefix: 172.24.0.0
mask: 24
next_hop: 192.168.42.64
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: modify admin distance of static route
+ register: result
vyos.vyos.vyos_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
admin_distance: 1
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
- - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64 distance 1" in result.commands'
+ - result.changed == true
+ - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64 distance
+ 1" in result.commands'
- name: modify admin distance of static route again (idempotent)
+ register: result
vyos.vyos.vyos_static_route:
prefix: 172.24.0.0
mask: 24
next_hop: 192.168.42.64
admin_distance: 1
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: delete static route
+ register: result
vyos.vyos.vyos_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
admin_distance: 1
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete protocols static route 172.24.0.0/24" in result.commands'
- name: delete static route again (idempotent)
+ register: result
vyos.vyos.vyos_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
admin_distance: 1
state: absent
- register: result
- assert:
that:
- - 'result.changed == false'
+ - result.changed == false
- name: Add static route collections
+ register: result
vyos.vyos.vyos_static_route:
aggregate:
- - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64}
- - {prefix: 172.24.2.0, mask: 24, next_hop: 192.168.42.64}
+
+ - prefix: 172.24.1.0/24
+ next_hop: 192.168.42.64
+
+ - prefix: 172.24.2.0
+ mask: 24
+ next_hop: 192.168.42.64
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set protocols static route 172.24.1.0/24 next-hop 192.168.42.64" in result.commands'
- '"set protocols static route 172.24.2.0/24 next-hop 192.168.42.64" in result.commands'
- name: Add and remove static route collections with overrides
+ register: result
vyos.vyos.vyos_static_route:
aggregate:
- - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64}
- - {prefix: 172.24.2.0/24, next_hop: 192.168.42.64, state: absent}
- - {prefix: 172.24.3.0/24, next_hop: 192.168.42.64}
+
+ - prefix: 172.24.1.0/24
+ next_hop: 192.168.42.64
+
+ - prefix: 172.24.2.0/24
+ next_hop: 192.168.42.64
+ state: absent
+
+ - prefix: 172.24.3.0/24
+ next_hop: 192.168.42.64
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete protocols static route 172.24.2.0/24" in result.commands'
- '"set protocols static route 172.24.3.0/24 next-hop 192.168.42.64" in result.commands'
- name: Remove static route collections
+ register: result
vyos.vyos.vyos_static_route:
aggregate:
- - {prefix: 172.24.1.0/24, next_hop: 192.168.42.64}
- - {prefix: 172.24.3.0/24, next_hop: 192.168.42.64}
+
+ - prefix: 172.24.1.0/24
+ next_hop: 192.168.42.64
+
+ - prefix: 172.24.3.0/24
+ next_hop: 192.168.42.64
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"delete protocols static route 172.24.1.0/24" in result.commands'
- '"delete protocols static route 172.24.3.0/24" in result.commands'
diff --git a/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml b/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml
index e2529eb..c53c838 100644
--- a/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml
+++ b/tests/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml
@@ -1,33 +1,32 @@
---
-- debug: msg="START vyos cli/net_static_route.yaml on connection={{ ansible_connection }}"
-
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
+- debug: msg="START vyos cli/net_static_route.yaml on connection={{ ansible_connection
+ }}"
- name: delete static route - setup
- net_static_route:
+ register: result
+ ansible.netcommon.net_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
state: absent
- register: result
- name: create static route using platform agnostic module
- net_static_route:
+ register: result
+ ansible.netcommon.net_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands'
- name: delete static route - teardown
- net_static_route:
+ register: result
+ ansible.netcommon.net_static_route:
prefix: 172.24.0.0/24
next_hop: 192.168.42.64
state: absent
- register: result
-- debug: msg="END vyos cli/net_static_route.yaml on connection={{ ansible_connection }}"
+- debug: msg="END vyos cli/net_static_route.yaml on connection={{ ansible_connection
+ }}"
diff --git a/tests/integration/targets/vyos_system/defaults/main.yaml b/tests/integration/targets/vyos_system/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_system/defaults/main.yaml
+++ b/tests/integration/targets/vyos_system/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_system/tasks/cli.yaml b/tests/integration/targets/vyos_system/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_system/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_system/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_system/tasks/main.yaml b/tests/integration/targets/vyos_system/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_system/tasks/main.yaml
+++ b/tests/integration/targets/vyos_system/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_system/tests/cli/basic.yaml b/tests/integration/targets/vyos_system/tests/cli/basic.yaml
index 474042f..9c3c09f 100644
--- a/tests/integration/targets/vyos_system/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_system/tests/cli/basic.yaml
@@ -10,12 +10,12 @@
match: none
- name: configure name servers
+ register: result
vyos.vyos.vyos_system:
name_servers:
- 192.0.2.1
- 192.0.2.2
- 192.0.2.3
- register: result
- assert:
that:
@@ -26,23 +26,23 @@
- result.commands[2] is search("set system name-server '192.0.2.3'")
- name: verify name_servers
+ register: result
vyos.vyos.vyos_system:
name_servers:
- 192.0.2.1
- 192.0.2.2
- 192.0.2.3
- register: result
- assert:
that:
- result.changed == false
- name: remove one
+ register: result
vyos.vyos.vyos_system:
name_servers:
- 192.0.2.3
state: absent
- register: result
- assert:
that:
diff --git a/tests/integration/targets/vyos_system/tests/cli/net_system.yaml b/tests/integration/targets/vyos_system/tests/cli/net_system.yaml
index 3688866..3e68d20 100644
--- a/tests/integration/targets/vyos_system/tests/cli/net_system.yaml
+++ b/tests/integration/targets/vyos_system/tests/cli/net_system.yaml
@@ -1,8 +1,6 @@
---
-- debug: msg="START vyos cli/net_system.yaml on connection={{ ansible_connection }}"
-
-# Add minimal testcase to check args are passed correctly to
-# implementation module and module run is successful.
+- debug: msg="START vyos cli/net_system.yaml on connection={{ ansible_connection
+ }}"
- name: setup
vyos.vyos.vyos_config:
@@ -11,10 +9,10 @@
match: none
- name: configure name servers using platform agnostic module
- net_system:
+ register: result
+ ansible.netcommon.net_system:
name_servers:
- 192.0.2.1
- register: result
- assert:
that:
diff --git a/tests/integration/targets/vyos_user/defaults/main.yaml b/tests/integration/targets/vyos_user/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_user/defaults/main.yaml
+++ b/tests/integration/targets/vyos_user/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_user/tasks/cli.yaml b/tests/integration/targets/vyos_user/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_user/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_user/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_user/tasks/main.yaml b/tests/integration/targets/vyos_user/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_user/tasks/main.yaml
+++ b/tests/integration/targets/vyos_user/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_user/tests/cli/auth.yaml b/tests/integration/targets/vyos_user/tests/cli/auth.yaml
index bbd67bc..bc4e788 100644
--- a/tests/integration/targets/vyos_user/tests/cli/auth.yaml
+++ b/tests/integration/targets/vyos_user/tests/cli/auth.yaml
@@ -1,34 +1,39 @@
---
- block:
- - name: Create user with password
- vyos.vyos.vyos_user:
- name: auth_user
- role: admin
- state: present
- configured_password: pass123
- - name: test login via ssh with new user
- expect:
- command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version'"
- responses:
- (?i)password: "pass123"
+ - name: Create user with password
+ vyos.vyos.vyos_user:
+ name: auth_user
+ role: admin
+ state: present
+ configured_password: pass123
- - name: test login via ssh with invalid password (should fail)
- expect:
- command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version'"
- responses:
- (?i)password: "badpass"
- ignore_errors: true
- register: results
+ - name: test login via ssh with new user
+ expect:
+ command: ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22)
+ }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper
+ show version'
+ responses:
+ (?i)password: pass123
- - name: check that attempt failed
- assert:
- that:
- - results.failed
+ - name: test login via ssh with invalid password (should fail)
+ expect:
+ command: ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22)
+ }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper
+ show version'
+ responses:
+ (?i)password: badpass
+ ignore_errors: true
+ register: results
+ - name: check that attempt failed
+ assert:
+ that:
+ - results.failed
always:
+
- name: delete user
+ register: result
vyos.vyos.vyos_user:
name: auth_user
state: absent
- register: result
diff --git a/tests/integration/targets/vyos_user/tests/cli/basic.yaml b/tests/integration/targets/vyos_user/tests/cli/basic.yaml
index a71f9c6..00a7a26 100644
--- a/tests/integration/targets/vyos_user/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_user/tests/cli/basic.yaml
@@ -9,69 +9,78 @@
- delete system login user ansibletest3
- name: Create user
+ register: result
vyos.vyos.vyos_user:
name: ansibletest1
configured_password: test
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
+ - result.changed == true
- '"set system login user" in result.commands[0]'
- '"authentication plaintext-password" in result.commands[0]'
- name: Collection of users (SetUp)
+ register: result
vyos.vyos.vyos_user:
aggregate:
+
- name: ansibletest2
+
- name: ansibletest3
level: operator
state: present
- register: result
- assert:
that:
- - 'result.changed == true'
- - 'result.commands == ["set system login user ansibletest2 level operator", "set system login user ansibletest3 level operator"]'
+ - result.changed == true
+ - result.commands == ["set system login user ansibletest2 level operator",
+ "set system login user ansibletest3 level operator"]
- name: Add user again (Idempotent)
+ register: result
vyos.vyos.vyos_user:
name: ansibletest1
configured_password: test
state: present
update_password: on_create
- register: result
- assert:
that:
- - 'result.changed == false'
- - 'result.commands | length == 0'
+ - result.changed == false
+ - result.commands | length == 0
- name: Add collection of users (Idempotent)
+ register: result
vyos.vyos.vyos_user:
aggregate:
+
- name: ansibletest2
+
- name: ansibletest3
level: operator
state: present
- register: result
- assert:
that:
- - 'result.changed == false'
- - 'result.commands | length == 0'
+ - result.changed == false
+ - result.commands | length == 0
- name: tearDown
+ register: result
vyos.vyos.vyos_user:
users:
+
- name: ansibletest1
+
- name: ansibletest2
+
- name: ansibletest3
state: absent
- register: result
- assert:
that:
- - 'result.changed == true'
- - 'result.commands == ["delete system login user ansibletest1", "delete system login user ansibletest2", "delete system login user ansibletest3"]'
+ - result.changed == true
+ - result.commands == ["delete system login user ansibletest1", "delete system
+ login user ansibletest2", "delete system login user ansibletest3"]
diff --git a/tests/integration/targets/vyos_vlan/defaults/main.yaml b/tests/integration/targets/vyos_vlan/defaults/main.yaml
index 9ef5ba5..a845c24 100644
--- a/tests/integration/targets/vyos_vlan/defaults/main.yaml
+++ b/tests/integration/targets/vyos_vlan/defaults/main.yaml
@@ -1,3 +1,3 @@
---
-testcase: "*"
+testcase: '*'
test_items: []
diff --git a/tests/integration/targets/vyos_vlan/tasks/cli.yaml b/tests/integration/targets/vyos_vlan/tasks/cli.yaml
index 890d3ac..90f265f 100644
--- a/tests/integration/targets/vyos_vlan/tasks/cli.yaml
+++ b/tests/integration/targets/vyos_vlan/tasks/cli.yaml
@@ -1,22 +1,22 @@
---
- name: collect all cli test cases
find:
- paths: "{{ role_path }}/tests/cli"
- patterns: "{{ testcase }}.yaml"
+ 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 }}"
+- name: run test case (connection=ansible.netcommon.network_cli)
+ include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.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 }}"
+ 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_vlan/tasks/main.yaml b/tests/integration/targets/vyos_vlan/tasks/main.yaml
index d4cf26f..a3db933 100644
--- a/tests/integration/targets/vyos_vlan/tasks/main.yaml
+++ b/tests/integration/targets/vyos_vlan/tasks/main.yaml
@@ -1,2 +1,4 @@
---
-- {include: cli.yaml, tags: ['cli']}
+- include: cli.yaml
+ tags:
+ - cli
diff --git a/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml b/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml
index cb0f348..eade5a4 100644
--- a/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_vlan/tests/cli/basic.yaml
@@ -11,86 +11,92 @@
- delete interfaces ethernet eth1 vif 201
- name: set vlan with name
- vyos.vyos.vyos_vlan: &name
+ register: result
+ vyos.vyos.vyos_vlan: &id001
vlan_id: 100
name: vlan-100
interfaces: eth1
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands"
- name: set vlan with name(idempotence)
- vyos.vyos.vyos_vlan: *name
register: result
+ vyos.vyos.vyos_vlan: *id001
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: set vlan with address
- vyos.vyos.vyos_vlan: &address
+ register: result
+ vyos.vyos.vyos_vlan: &id002
vlan_id: 5
address: 192.168.5.12/24
interfaces: eth0
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set interfaces ethernet eth0 vif 5 address 192.168.5.12/24' in result.commands"
- name: set vlan with address(idempotence)
- vyos.vyos.vyos_vlan: *address
register: result
+ vyos.vyos.vyos_vlan: *id002
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: delete
- vyos.vyos.vyos_vlan: &delete
+ register: result
+ vyos.vyos.vyos_vlan: &id003
vlan_id: 100
interfaces: eth1
state: absent
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'delete interfaces ethernet eth1 vif 100' in result.commands"
- name: delete(idempotence)
- vyos.vyos.vyos_vlan: *delete
register: result
+ vyos.vyos.vyos_vlan: *id003
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: Create VLANs using aggregate
- vyos.vyos.vyos_vlan: &agg_vlan
+ register: result
+ vyos.vyos.vyos_vlan: &id004
aggregate:
- - {vlan_id: 101, name: voice, interfaces: "eth0"}
- - {vlan_id: 201, name: mgm, interfaces: "eth1"}
+
+ - vlan_id: 101
+ name: voice
+ interfaces: eth0
+
+ - vlan_id: 201
+ name: mgm
+ interfaces: eth1
state: present
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set interfaces ethernet eth0 vif 101 description voice' in result.commands"
- "'set interfaces ethernet eth1 vif 201 description mgm' in result.commands"
- name: Create VLANs using aggregate (idempotent)
- vyos.vyos.vyos_vlan: *agg_vlan
register: result
+ vyos.vyos.vyos_vlan: *id004
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: teardown
vyos.vyos.vyos_config:
diff --git a/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml b/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml
index 4a12317..f180d17 100644
--- a/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml
+++ b/tests/integration/targets/vyos_vlan/tests/cli/intent.yaml
@@ -2,58 +2,58 @@
- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}"
- name: setup - remove vlan used in test
- vyos.vyos.vyos_config: &delete
+ vyos.vyos.vyos_config:
lines:
- delete interfaces ethernet eth1 vif 100
- delete interfaces ethernet eth0 vif 100
- name: set vlan with name
+ register: result
vyos.vyos.vyos_vlan:
vlan_id: 100
name: vlan-100
interfaces: eth1
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands"
- name: check vlan interface intent
+ register: result
vyos.vyos.vyos_vlan:
vlan_id: 100
name: vlan-100
associated_interfaces: eth1
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
- name: vlan interface config + intent
+ register: result
vyos.vyos.vyos_vlan:
vlan_id: 100
interfaces: eth0
associated_interfaces:
- eth0
- eth1
- register: result
- assert:
that:
- - "result.failed == false"
+ - result.failed == false
- name: vlan intent fail
+ register: result
+ ignore_errors: true
vyos.vyos.vyos_vlan:
vlan_id: 100
associated_interfaces:
- eth3
- eth4
- register: result
- ignore_errors: true
- assert:
that:
- - "result.failed == True"
+ - result.failed == True
- debug: msg="End cli/intent.yaml on connection={{ ansible_connection }}"
diff --git a/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml b/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml
index 53e93fd..2059a43 100644
--- a/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml
+++ b/tests/integration/targets/vyos_vlan/tests/cli/multiple.yaml
@@ -9,49 +9,49 @@
- delete interfaces ethernet eth1 vif 100
- name: Add multiple interfaces to vlan
- vyos.vyos.vyos_vlan: &multiple
+ register: result
+ vyos.vyos.vyos_vlan: &id001
vlan_id: 100
interfaces:
- eth0
- eth1
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'set interfaces ethernet eth0 vif 100' in result.commands"
- "'set interfaces ethernet eth1 vif 100' in result.commands"
- name: Add multiple interfaces to vlan(idempotence)
- vyos.vyos.vyos_vlan: *multiple
register: result
+ vyos.vyos.vyos_vlan: *id001
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: delete vlan with multiple interfaces
- vyos.vyos.vyos_vlan: &delete_multiple
+ register: result
+ vyos.vyos.vyos_vlan: &id002
vlan_id: 100
interfaces:
- eth0
- eth1
state: absent
- register: result
- assert:
that:
- - "result.changed == true"
+ - result.changed == true
- "'delete interfaces ethernet eth0 vif 100' in result.commands"
- "'delete interfaces ethernet eth1 vif 100' in result.commands"
- name: delete vlan with multiple interfaces(idempotence)
- vyos.vyos.vyos_vlan: *delete_multiple
register: result
+ vyos.vyos.vyos_vlan: *id002
- assert:
that:
- - "result.changed == false"
+ - result.changed == false
- name: teardown
vyos.vyos.vyos_config: