From 6b6166151faa3d811ae0ec3010a89e518a26287b Mon Sep 17 00:00:00 2001 From: CaptTrews Date: Thu, 16 Jan 2020 15:50:24 +0000 Subject: Updated from network content collector Signed-off-by: CaptTrews --- .../targets/prepare_vyos_tests/tasks/main.yaml | 14 +- .../targets/vyos_banner/defaults/main.yaml | 2 +- .../integration/targets/vyos_banner/tasks/cli.yaml | 14 +- .../targets/vyos_banner/tasks/main.yaml | 4 +- .../vyos_banner/tests/cli/basic-no-login.yaml | 23 +-- .../vyos_banner/tests/cli/basic-post-login.yaml | 29 +-- .../vyos_banner/tests/cli/basic-pre-login.yaml | 29 +-- .../targets/vyos_command/defaults/main.yaml | 2 +- .../targets/vyos_command/tasks/cli.yaml | 14 +- .../targets/vyos_command/tasks/main.yaml | 4 +- .../vyos_command/tests/cli/bad_operator.yaml | 4 +- .../vyos_command/tests/cli/cli_command.yaml | 30 +-- .../targets/vyos_command/tests/cli/contains.yaml | 2 +- .../targets/vyos_command/tests/cli/invalid.yaml | 14 +- .../targets/vyos_command/tests/cli/output.yaml | 8 +- .../targets/vyos_command/tests/cli/timeout.yaml | 4 +- .../targets/vyos_config/defaults/main.yaml | 2 +- .../integration/targets/vyos_config/tasks/cli.yaml | 14 +- .../targets/vyos_config/tasks/cli_config.yaml | 10 +- .../targets/vyos_config/tasks/main.yaml | 9 +- .../targets/vyos_config/tests/cli/backup.yaml | 60 +++--- .../vyos_config/tests/cli/check_config.yaml | 24 +-- .../targets/vyos_config/tests/cli/comment.yaml | 6 +- .../targets/vyos_config/tests/cli/config.cfg | 3 + .../targets/vyos_config/tests/cli/save.yaml | 16 +- .../targets/vyos_config/tests/cli/simple.yaml | 26 ++- .../vyos_config/tests/cli_config/cli_backup.yaml | 68 +++---- .../vyos_config/tests/cli_config/cli_basic.yaml | 20 +- .../vyos_config/tests/cli_config/cli_comment.yaml | 18 +- .../targets/vyos_facts/defaults/main.yaml | 2 +- .../integration/targets/vyos_facts/tasks/cli.yaml | 14 +- .../integration/targets/vyos_facts/tasks/main.yaml | 4 +- .../targets/vyos_facts/tests/cli/basic_facts.yaml | 18 +- .../targets/vyos_interface/defaults/main.yaml | 2 +- .../targets/vyos_interface/tasks/cli.yaml | 14 +- .../targets/vyos_interface/tasks/main.yaml | 4 +- .../targets/vyos_interface/tests/cli/basic.yaml | 116 +++++++---- .../targets/vyos_interface/tests/cli/intent.yaml | 75 +++---- .../vyos_interface/tests/cli/net_interface.yaml | 33 ++- .../targets/vyos_interfaces/defaults/main.yaml | 2 +- .../targets/vyos_interfaces/tasks/cli.yaml | 12 +- .../targets/vyos_interfaces/tasks/main.yaml | 4 +- .../vyos_interfaces/tests/cli/_populate.yaml | 16 +- .../vyos_interfaces/tests/cli/_remove_config.yaml | 16 +- .../targets/vyos_interfaces/tests/cli/deleted.yaml | 25 ++- .../vyos_interfaces/tests/cli/empty_config.yaml | 15 +- .../targets/vyos_interfaces/tests/cli/merged.yaml | 38 ++-- .../vyos_interfaces/tests/cli/overridden.yaml | 31 +-- .../vyos_interfaces/tests/cli/replaced.yaml | 34 ++-- .../targets/vyos_interfaces/tests/cli/rtt.yaml | 40 ++-- .../targets/vyos_interfaces/vars/main.yaml | 225 +++++++++------------ .../targets/vyos_l3_interface/defaults/main.yaml | 2 +- .../targets/vyos_l3_interface/tasks/cli.yaml | 14 +- .../targets/vyos_l3_interface/tasks/main.yaml | 4 +- .../targets/vyos_l3_interface/tests/cli/basic.yaml | 116 +++++++---- .../targets/vyos_l3_interfaces/defaults/main.yaml | 2 +- .../targets/vyos_l3_interfaces/tasks/cli.yaml | 12 +- .../targets/vyos_l3_interfaces/tasks/main.yaml | 4 +- .../vyos_l3_interfaces/tests/cli/_populate.yaml | 14 +- .../tests/cli/_remove_config.yaml | 9 +- .../vyos_l3_interfaces/tests/cli/deleted.yaml | 25 ++- .../vyos_l3_interfaces/tests/cli/empty_config.yaml | 15 +- .../vyos_l3_interfaces/tests/cli/merged.yaml | 36 +++- .../vyos_l3_interfaces/tests/cli/overridden.yaml | 29 ++- .../vyos_l3_interfaces/tests/cli/replaced.yaml | 30 ++- .../targets/vyos_l3_interfaces/vars/main.yaml | 118 +++++------ .../targets/vyos_lag_interfaces/defaults/main.yaml | 2 +- .../targets/vyos_lag_interfaces/tasks/cli.yaml | 12 +- .../targets/vyos_lag_interfaces/tasks/main.yaml | 4 +- .../vyos_lag_interfaces/tests/cli/_add_bond.yaml | 8 +- .../vyos_lag_interfaces/tests/cli/_populate.yaml | 21 +- .../tests/cli/_remove_bond.yaml | 8 +- .../tests/cli/_remove_config.yaml | 18 +- .../vyos_lag_interfaces/tests/cli/deleted.yaml | 25 ++- .../tests/cli/empty_config.yaml | 15 +- .../vyos_lag_interfaces/tests/cli/merged.yaml | 40 ++-- .../vyos_lag_interfaces/tests/cli/overridden.yaml | 27 ++- .../vyos_lag_interfaces/tests/cli/replaced.yaml | 35 ++-- .../targets/vyos_lag_interfaces/tests/cli/rtt.yaml | 41 ++-- .../targets/vyos_lag_interfaces/vars/main.yaml | 128 +++++------- .../targets/vyos_linkagg/defaults/main.yaml | 2 +- .../targets/vyos_linkagg/tasks/cli.yaml | 14 +- .../targets/vyos_linkagg/tasks/main.yaml | 4 +- .../targets/vyos_linkagg/tests/cli/basic.yaml | 80 +++++--- .../vyos_linkagg/tests/cli/net_linkagg.yaml | 19 +- .../targets/vyos_lldp/defaults/main.yaml | 2 +- tests/integration/targets/vyos_lldp/tasks/cli.yaml | 14 +- .../integration/targets/vyos_lldp/tasks/main.yaml | 4 +- .../targets/vyos_lldp/tests/cli/basic.yaml | 16 +- .../targets/vyos_lldp/tests/cli/net_lldp.yaml | 9 +- .../targets/vyos_lldp_global/defaults/main.yaml | 2 +- .../targets/vyos_lldp_global/tasks/cli.yaml | 12 +- .../targets/vyos_lldp_global/tasks/main.yaml | 4 +- .../vyos_lldp_global/tests/cli/_populate.yaml | 10 +- .../vyos_lldp_global/tests/cli/_remove_config.yaml | 10 +- .../vyos_lldp_global/tests/cli/deleted.yaml | 17 +- .../vyos_lldp_global/tests/cli/empty_config.yaml | 11 +- .../targets/vyos_lldp_global/tests/cli/merged.yaml | 24 ++- .../vyos_lldp_global/tests/cli/replaced.yaml | 26 ++- .../targets/vyos_lldp_global/tests/cli/rtt.yaml | 22 +- .../targets/vyos_lldp_global/vars/main.yaml | 56 +++-- .../targets/vyos_lldp_interface/defaults/main.yaml | 2 +- .../targets/vyos_lldp_interface/tasks/cli.yaml | 14 +- .../targets/vyos_lldp_interface/tasks/main.yaml | 4 +- .../vyos_lldp_interface/tests/cli/basic.yaml | 74 ++++--- .../tests/cli/net_lldp_interface.yaml | 15 +- .../vyos_lldp_interfaces/defaults/main.yaml | 2 +- .../targets/vyos_lldp_interfaces/tasks/cli.yaml | 12 +- .../targets/vyos_lldp_interfaces/tasks/main.yaml | 4 +- .../vyos_lldp_interfaces/tests/cli/_populate.yaml | 20 +- .../tests/cli/_populate_intf.yaml | 12 +- .../tests/cli/_remove_config.yaml | 8 +- .../vyos_lldp_interfaces/tests/cli/deleted.yaml | 30 ++- .../tests/cli/empty_config.yaml | 15 +- .../vyos_lldp_interfaces/tests/cli/merged.yaml | 45 +++-- .../vyos_lldp_interfaces/tests/cli/overridden.yaml | 31 +-- .../vyos_lldp_interfaces/tests/cli/replaced.yaml | 45 +++-- .../vyos_lldp_interfaces/tests/cli/rtt.yaml | 36 ++-- .../targets/vyos_lldp_interfaces/vars/main.yaml | 134 ++++++------ .../targets/vyos_logging/defaults/main.yaml | 2 +- .../targets/vyos_logging/tasks/cli.yaml | 14 +- .../targets/vyos_logging/tasks/main.yaml | 4 +- .../targets/vyos_logging/tests/cli/basic.yaml | 81 +++++--- .../vyos_logging/tests/cli/net_logging.yaml | 23 +-- .../targets/vyos_smoke/defaults/main.yaml | 3 - .../integration/targets/vyos_smoke/tasks/cli.yaml | 22 -- .../integration/targets/vyos_smoke/tasks/main.yaml | 2 - .../vyos_smoke/tests/cli/common_config.yaml | 11 - .../targets/vyos_smoke/tests/cli/common_utils.yaml | 50 ----- .../targets/vyos_smoke/tests/cli/misc_tests.yaml | 14 -- .../targets/vyos_static_route/defaults/main.yaml | 2 +- .../targets/vyos_static_route/tasks/cli.yaml | 14 +- .../targets/vyos_static_route/tasks/main.yaml | 4 +- .../targets/vyos_static_route/tests/cli/basic.yaml | 69 ++++--- .../tests/cli/net_static_route.yaml | 23 +-- .../targets/vyos_system/defaults/main.yaml | 2 +- .../integration/targets/vyos_system/tasks/cli.yaml | 14 +- .../targets/vyos_system/tasks/main.yaml | 4 +- .../targets/vyos_system/tests/cli/basic.yaml | 6 +- .../targets/vyos_system/tests/cli/net_system.yaml | 10 +- .../targets/vyos_user/defaults/main.yaml | 2 +- tests/integration/targets/vyos_user/tasks/cli.yaml | 14 +- .../integration/targets/vyos_user/tasks/main.yaml | 4 +- .../targets/vyos_user/tests/cli/auth.yaml | 51 ++--- .../targets/vyos_user/tests/cli/basic.yaml | 37 ++-- .../targets/vyos_vlan/defaults/main.yaml | 2 +- tests/integration/targets/vyos_vlan/tasks/cli.yaml | 14 +- .../integration/targets/vyos_vlan/tasks/main.yaml | 4 +- .../targets/vyos_vlan/tests/cli/basic.yaml | 50 +++-- .../targets/vyos_vlan/tests/cli/intent.yaml | 20 +- .../targets/vyos_vlan/tests/cli/multiple.yaml | 20 +- 151 files changed, 1807 insertions(+), 1673 deletions(-) create mode 100644 tests/integration/targets/vyos_config/tests/cli/config.cfg delete mode 100644 tests/integration/targets/vyos_smoke/defaults/main.yaml delete mode 100644 tests/integration/targets/vyos_smoke/tasks/cli.yaml delete mode 100644 tests/integration/targets/vyos_smoke/tasks/main.yaml delete mode 100644 tests/integration/targets/vyos_smoke/tests/cli/common_config.yaml delete mode 100644 tests/integration/targets/vyos_smoke/tests/cli/common_utils.yaml delete mode 100644 tests/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml (limited to 'tests/integration') 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 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: -- cgit v1.2.3