From a330106b2e2c811db49477d71b8a472c964d2aeb Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Thu, 8 Aug 2019 12:29:41 -0700 Subject: fixed --- test/integration/targets/vyos_banner/aliases | 1 + .../targets/vyos_banner/defaults/main.yaml | 3 + .../integration/targets/vyos_banner/tasks/cli.yaml | 22 +++ .../targets/vyos_banner/tasks/main.yaml | 2 + .../vyos_banner/tests/cli/basic-no-login.yaml | 41 ++++ .../vyos_banner/tests/cli/basic-post-login.yaml | 47 +++++ .../vyos_banner/tests/cli/basic-pre-login.yaml | 47 +++++ .../targets/vyos_banner/vyos_banner/aliases | 1 - .../vyos_banner/vyos_banner/defaults/main.yaml | 3 - .../targets/vyos_banner/vyos_banner/tasks/cli.yaml | 22 --- .../vyos_banner/vyos_banner/tasks/main.yaml | 2 - .../vyos_banner/tests/cli/basic-no-login.yaml | 41 ---- .../vyos_banner/tests/cli/basic-post-login.yaml | 47 ----- .../vyos_banner/tests/cli/basic-pre-login.yaml | 47 ----- test/integration/targets/vyos_command/aliases | 1 + .../targets/vyos_command/defaults/main.yaml | 3 + .../targets/vyos_command/tasks/cli.yaml | 22 +++ .../targets/vyos_command/tasks/main.yaml | 2 + .../vyos_command/tests/cli/bad_operator.yaml | 19 ++ .../vyos_command/tests/cli/cli_command.yaml | 41 ++++ .../targets/vyos_command/tests/cli/contains.yaml | 20 ++ .../targets/vyos_command/tests/cli/invalid.yaml | 22 +++ .../targets/vyos_command/tests/cli/output.yaml | 44 +++++ .../targets/vyos_command/tests/cli/timeout.yaml | 18 ++ .../targets/vyos_command/vyos_command/aliases | 1 - .../vyos_command/vyos_command/defaults/main.yaml | 3 - .../vyos_command/vyos_command/tasks/cli.yaml | 22 --- .../vyos_command/vyos_command/tasks/main.yaml | 2 - .../vyos_command/tests/cli/bad_operator.yaml | 19 -- .../vyos_command/tests/cli/cli_command.yaml | 41 ---- .../vyos_command/tests/cli/contains.yaml | 20 -- .../vyos_command/tests/cli/invalid.yaml | 22 --- .../vyos_command/tests/cli/output.yaml | 44 ----- .../vyos_command/tests/cli/timeout.yaml | 18 -- test/integration/targets/vyos_config/aliases | 1 + .../targets/vyos_config/defaults/main.yaml | 3 + .../integration/targets/vyos_config/tasks/cli.yaml | 22 +++ .../targets/vyos_config/tasks/cli_config.yaml | 16 ++ .../targets/vyos_config/tasks/main.yaml | 3 + .../targets/vyos_config/tests/cli/backup.yaml | 113 +++++++++++ .../vyos_config/tests/cli/check_config.yaml | 63 ++++++ .../targets/vyos_config/tests/cli/comment.yaml | 34 ++++ .../targets/vyos_config/tests/cli/save.yaml | 54 +++++ .../targets/vyos_config/tests/cli/simple.yaml | 33 ++++ .../vyos_config/tests/cli_config/cli_backup.yaml | 113 +++++++++++ .../vyos_config/tests/cli_config/cli_basic.yaml | 28 +++ .../vyos_config/tests/cli_config/cli_comment.yaml | 30 +++ .../targets/vyos_config/vyos_config/aliases | 1 - .../vyos_config/vyos_config/defaults/main.yaml | 3 - .../targets/vyos_config/vyos_config/tasks/cli.yaml | 22 --- .../vyos_config/vyos_config/tasks/cli_config.yaml | 16 -- .../vyos_config/vyos_config/tasks/main.yaml | 3 - .../vyos_config/vyos_config/tests/cli/backup.yaml | 113 ----------- .../vyos_config/tests/cli/check_config.yaml | 63 ------ .../vyos_config/vyos_config/tests/cli/comment.yaml | 34 ---- .../vyos_config/vyos_config/tests/cli/save.yaml | 54 ----- .../vyos_config/vyos_config/tests/cli/simple.yaml | 33 ---- .../vyos_config/tests/cli_config/cli_backup.yaml | 113 ----------- .../vyos_config/tests/cli_config/cli_basic.yaml | 28 --- .../vyos_config/tests/cli_config/cli_comment.yaml | 30 --- test/integration/targets/vyos_facts/aliases | 1 + .../targets/vyos_facts/defaults/main.yaml | 3 + test/integration/targets/vyos_facts/tasks/cli.yaml | 22 +++ .../integration/targets/vyos_facts/tasks/main.yaml | 2 + .../targets/vyos_facts/tests/cli/basic_facts.yaml | 45 +++++ .../targets/vyos_facts/vyos_facts/aliases | 1 - .../vyos_facts/vyos_facts/defaults/main.yaml | 3 - .../targets/vyos_facts/vyos_facts/tasks/cli.yaml | 22 --- .../targets/vyos_facts/vyos_facts/tasks/main.yaml | 2 - .../vyos_facts/tests/cli/basic_facts.yaml | 45 ----- test/integration/targets/vyos_interface/aliases | 0 .../targets/vyos_interface/defaults/main.yaml | 3 + .../targets/vyos_interface/tasks/cli.yaml | 22 +++ .../targets/vyos_interface/tasks/main.yaml | 2 + .../targets/vyos_interface/tests/cli/basic.yaml | 220 +++++++++++++++++++++ .../targets/vyos_interface/tests/cli/intent.yaml | 157 +++++++++++++++ .../vyos_interface/tests/cli/net_interface.yaml | 56 ++++++ .../targets/vyos_interface/vyos_interface/aliases | 0 .../vyos_interface/defaults/main.yaml | 3 - .../vyos_interface/vyos_interface/tasks/cli.yaml | 22 --- .../vyos_interface/vyos_interface/tasks/main.yaml | 2 - .../vyos_interface/tests/cli/basic.yaml | 220 --------------------- .../vyos_interface/tests/cli/intent.yaml | 157 --------------- .../vyos_interface/tests/cli/net_interface.yaml | 56 ------ test/integration/targets/vyos_l3_interface/aliases | 0 .../targets/vyos_l3_interface/defaults/main.yaml | 3 + .../targets/vyos_l3_interface/tasks/cli.yaml | 22 +++ .../targets/vyos_l3_interface/tasks/main.yaml | 2 + .../targets/vyos_l3_interface/tests/cli/basic.yaml | 203 +++++++++++++++++++ .../vyos_l3_interface/vyos_l3_interface/aliases | 0 .../vyos_l3_interface/defaults/main.yaml | 3 - .../vyos_l3_interface/tasks/cli.yaml | 22 --- .../vyos_l3_interface/tasks/main.yaml | 2 - .../vyos_l3_interface/tests/cli/basic.yaml | 203 ------------------- test/integration/targets/vyos_linkagg/aliases | 0 .../targets/vyos_linkagg/defaults/main.yaml | 3 + .../targets/vyos_linkagg/tasks/cli.yaml | 22 +++ .../targets/vyos_linkagg/tasks/main.yaml | 2 + .../targets/vyos_linkagg/tests/cli/basic.yaml | 184 +++++++++++++++++ .../vyos_linkagg/tests/cli/net_linkagg.yaml | 31 +++ .../targets/vyos_linkagg/vyos_linkagg/aliases | 0 .../vyos_linkagg/vyos_linkagg/defaults/main.yaml | 3 - .../vyos_linkagg/vyos_linkagg/tasks/cli.yaml | 22 --- .../vyos_linkagg/vyos_linkagg/tasks/main.yaml | 2 - .../vyos_linkagg/vyos_linkagg/tests/cli/basic.yaml | 184 ----------------- .../vyos_linkagg/tests/cli/net_linkagg.yaml | 31 --- test/integration/targets/vyos_lldp/aliases | 1 + .../targets/vyos_lldp/defaults/main.yaml | 3 + test/integration/targets/vyos_lldp/tasks/cli.yaml | 22 +++ test/integration/targets/vyos_lldp/tasks/main.yaml | 2 + .../targets/vyos_lldp/tests/cli/basic.yaml | 44 +++++ .../targets/vyos_lldp/tests/cli/net_lldp.yaml | 25 +++ .../targets/vyos_lldp/vyos_lldp/aliases | 1 - .../targets/vyos_lldp/vyos_lldp/defaults/main.yaml | 3 - .../targets/vyos_lldp/vyos_lldp/tasks/cli.yaml | 22 --- .../targets/vyos_lldp/vyos_lldp/tasks/main.yaml | 2 - .../vyos_lldp/vyos_lldp/tests/cli/basic.yaml | 44 ----- .../vyos_lldp/vyos_lldp/tests/cli/net_lldp.yaml | 25 --- .../targets/vyos_lldp_interface/aliases | 0 .../targets/vyos_lldp_interface/defaults/main.yaml | 3 + .../targets/vyos_lldp_interface/tasks/cli.yaml | 22 +++ .../targets/vyos_lldp_interface/tasks/main.yaml | 2 + .../vyos_lldp_interface/tests/cli/basic.yaml | 167 ++++++++++++++++ .../tests/cli/net_lldp_interface.yaml | 26 +++ .../vyos_lldp_interface/aliases | 0 .../vyos_lldp_interface/defaults/main.yaml | 3 - .../vyos_lldp_interface/tasks/cli.yaml | 22 --- .../vyos_lldp_interface/tasks/main.yaml | 2 - .../vyos_lldp_interface/tests/cli/basic.yaml | 167 ---------------- .../tests/cli/net_lldp_interface.yaml | 26 --- test/integration/targets/vyos_logging/aliases | 0 .../targets/vyos_logging/defaults/main.yaml | 3 + .../targets/vyos_logging/tasks/cli.yaml | 22 +++ .../targets/vyos_logging/tasks/main.yaml | 2 + .../targets/vyos_logging/tests/cli/basic.yaml | 126 ++++++++++++ .../vyos_logging/tests/cli/net_logging.yaml | 39 ++++ .../targets/vyos_logging/vyos_logging/aliases | 0 .../vyos_logging/vyos_logging/defaults/main.yaml | 3 - .../vyos_logging/vyos_logging/tasks/cli.yaml | 22 --- .../vyos_logging/vyos_logging/tasks/main.yaml | 2 - .../vyos_logging/vyos_logging/tests/cli/basic.yaml | 126 ------------ .../vyos_logging/tests/cli/net_logging.yaml | 39 ---- .../targets/vyos_smoke/defaults/main.yaml | 3 + test/integration/targets/vyos_smoke/tasks/cli.yaml | 22 +++ .../integration/targets/vyos_smoke/tasks/main.yaml | 2 + .../vyos_smoke/tests/cli/common_config.yaml | 10 + .../targets/vyos_smoke/tests/cli/common_utils.yaml | 49 +++++ .../targets/vyos_smoke/tests/cli/misc_tests.yaml | 13 ++ .../vyos_smoke/vyos_smoke/defaults/main.yaml | 3 - .../targets/vyos_smoke/vyos_smoke/tasks/cli.yaml | 22 --- .../targets/vyos_smoke/vyos_smoke/tasks/main.yaml | 2 - .../vyos_smoke/tests/cli/common_config.yaml | 10 - .../vyos_smoke/tests/cli/common_utils.yaml | 49 ----- .../vyos_smoke/tests/cli/misc_tests.yaml | 13 -- test/integration/targets/vyos_static_route/aliases | 1 + .../targets/vyos_static_route/defaults/main.yaml | 3 + .../targets/vyos_static_route/tasks/cli.yaml | 22 +++ .../targets/vyos_static_route/tasks/main.yaml | 2 + .../targets/vyos_static_route/tests/cli/basic.yaml | 120 +++++++++++ .../tests/cli/net_static_route.yaml | 33 ++++ .../vyos_static_route/vyos_static_route/aliases | 1 - .../vyos_static_route/defaults/main.yaml | 3 - .../vyos_static_route/tasks/cli.yaml | 22 --- .../vyos_static_route/tasks/main.yaml | 2 - .../vyos_static_route/tests/cli/basic.yaml | 120 ----------- .../tests/cli/net_static_route.yaml | 33 ---- .../targets/vyos_system/defaults/main.yaml | 3 + .../integration/targets/vyos_system/tasks/cli.yaml | 22 +++ .../targets/vyos_system/tasks/main.yaml | 2 + .../targets/vyos_system/tests/cli/basic.yaml | 61 ++++++ .../targets/vyos_system/tests/cli/net_system.yaml | 30 +++ .../vyos_system/vyos_system/defaults/main.yaml | 3 - .../targets/vyos_system/vyos_system/tasks/cli.yaml | 22 --- .../vyos_system/vyos_system/tasks/main.yaml | 2 - .../vyos_system/vyos_system/tests/cli/basic.yaml | 61 ------ .../vyos_system/tests/cli/net_system.yaml | 30 --- test/integration/targets/vyos_user/aliases | 0 .../targets/vyos_user/defaults/main.yaml | 3 + test/integration/targets/vyos_user/tasks/cli.yaml | 22 +++ test/integration/targets/vyos_user/tasks/main.yaml | 2 + .../targets/vyos_user/tests/cli/auth.yaml | 34 ++++ .../targets/vyos_user/tests/cli/basic.yaml | 77 ++++++++ .../targets/vyos_user/vyos_user/aliases | 0 .../targets/vyos_user/vyos_user/defaults/main.yaml | 3 - .../targets/vyos_user/vyos_user/tasks/cli.yaml | 22 --- .../targets/vyos_user/vyos_user/tasks/main.yaml | 2 - .../vyos_user/vyos_user/tests/cli/auth.yaml | 34 ---- .../vyos_user/vyos_user/tests/cli/basic.yaml | 77 -------- test/integration/targets/vyos_vlan/aliases | 0 .../targets/vyos_vlan/defaults/main.yaml | 3 + test/integration/targets/vyos_vlan/tasks/cli.yaml | 22 +++ test/integration/targets/vyos_vlan/tasks/main.yaml | 2 + .../targets/vyos_vlan/tests/cli/basic.yaml | 101 ++++++++++ .../targets/vyos_vlan/tests/cli/intent.yaml | 59 ++++++ .../targets/vyos_vlan/tests/cli/multiple.yaml | 60 ++++++ .../targets/vyos_vlan/vyos_vlan/aliases | 0 .../targets/vyos_vlan/vyos_vlan/defaults/main.yaml | 3 - .../targets/vyos_vlan/vyos_vlan/tasks/cli.yaml | 22 --- .../targets/vyos_vlan/vyos_vlan/tasks/main.yaml | 2 - .../vyos_vlan/vyos_vlan/tests/cli/basic.yaml | 101 ---------- .../vyos_vlan/vyos_vlan/tests/cli/intent.yaml | 59 ------ .../vyos_vlan/vyos_vlan/tests/cli/multiple.yaml | 60 ------ 202 files changed, 3165 insertions(+), 3165 deletions(-) create mode 100644 test/integration/targets/vyos_banner/aliases create mode 100644 test/integration/targets/vyos_banner/defaults/main.yaml create mode 100644 test/integration/targets/vyos_banner/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_banner/tasks/main.yaml create mode 100644 test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml create mode 100644 test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml create mode 100644 test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/aliases delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-no-login.yaml delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-post-login.yaml delete mode 100644 test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-pre-login.yaml create mode 100644 test/integration/targets/vyos_command/aliases create mode 100644 test/integration/targets/vyos_command/defaults/main.yaml create mode 100644 test/integration/targets/vyos_command/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_command/tasks/main.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/bad_operator.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/cli_command.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/contains.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/invalid.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/output.yaml create mode 100644 test/integration/targets/vyos_command/tests/cli/timeout.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/aliases delete mode 100644 test/integration/targets/vyos_command/vyos_command/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml delete mode 100644 test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml create mode 100644 test/integration/targets/vyos_config/aliases create mode 100644 test/integration/targets/vyos_config/defaults/main.yaml create mode 100644 test/integration/targets/vyos_config/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_config/tasks/cli_config.yaml create mode 100644 test/integration/targets/vyos_config/tasks/main.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli/backup.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli/check_config.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli/comment.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli/save.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli/simple.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml create mode 100644 test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/aliases delete mode 100644 test/integration/targets/vyos_config/vyos_config/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tasks/cli_config.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli/backup.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli/check_config.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli/comment.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli/save.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli/simple.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_backup.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_basic.yaml delete mode 100644 test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_comment.yaml create mode 100644 test/integration/targets/vyos_facts/aliases create mode 100644 test/integration/targets/vyos_facts/defaults/main.yaml create mode 100644 test/integration/targets/vyos_facts/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_facts/tasks/main.yaml create mode 100644 test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml delete mode 100644 test/integration/targets/vyos_facts/vyos_facts/aliases delete mode 100644 test/integration/targets/vyos_facts/vyos_facts/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_facts/vyos_facts/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_facts/vyos_facts/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_facts/vyos_facts/tests/cli/basic_facts.yaml create mode 100644 test/integration/targets/vyos_interface/aliases create mode 100644 test/integration/targets/vyos_interface/defaults/main.yaml create mode 100644 test/integration/targets/vyos_interface/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_interface/tasks/main.yaml create mode 100644 test/integration/targets/vyos_interface/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_interface/tests/cli/intent.yaml create mode 100644 test/integration/targets/vyos_interface/tests/cli/net_interface.yaml delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/aliases delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/tests/cli/intent.yaml delete mode 100644 test/integration/targets/vyos_interface/vyos_interface/tests/cli/net_interface.yaml create mode 100644 test/integration/targets/vyos_l3_interface/aliases create mode 100644 test/integration/targets/vyos_l3_interface/defaults/main.yaml create mode 100644 test/integration/targets/vyos_l3_interface/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_l3_interface/tasks/main.yaml create mode 100644 test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_l3_interface/vyos_l3_interface/aliases delete mode 100644 test/integration/targets/vyos_l3_interface/vyos_l3_interface/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_l3_interface/vyos_l3_interface/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_linkagg/aliases create mode 100644 test/integration/targets/vyos_linkagg/defaults/main.yaml create mode 100644 test/integration/targets/vyos_linkagg/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_linkagg/tasks/main.yaml create mode 100644 test/integration/targets/vyos_linkagg/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml delete mode 100644 test/integration/targets/vyos_linkagg/vyos_linkagg/aliases delete mode 100644 test/integration/targets/vyos_linkagg/vyos_linkagg/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/net_linkagg.yaml create mode 100644 test/integration/targets/vyos_lldp/aliases create mode 100644 test/integration/targets/vyos_lldp/defaults/main.yaml create mode 100644 test/integration/targets/vyos_lldp/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_lldp/tasks/main.yaml create mode 100644 test/integration/targets/vyos_lldp/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml delete mode 100644 test/integration/targets/vyos_lldp/vyos_lldp/aliases delete mode 100644 test/integration/targets/vyos_lldp/vyos_lldp/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_lldp/vyos_lldp/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_lldp/vyos_lldp/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/net_lldp.yaml create mode 100644 test/integration/targets/vyos_lldp_interface/aliases create mode 100644 test/integration/targets/vyos_lldp_interface/defaults/main.yaml create mode 100644 test/integration/targets/vyos_lldp_interface/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_lldp_interface/tasks/main.yaml create mode 100644 test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml delete mode 100644 test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/aliases delete mode 100644 test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml create mode 100644 test/integration/targets/vyos_logging/aliases create mode 100644 test/integration/targets/vyos_logging/defaults/main.yaml create mode 100644 test/integration/targets/vyos_logging/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_logging/tasks/main.yaml create mode 100644 test/integration/targets/vyos_logging/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_logging/tests/cli/net_logging.yaml delete mode 100644 test/integration/targets/vyos_logging/vyos_logging/aliases delete mode 100644 test/integration/targets/vyos_logging/vyos_logging/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_logging/vyos_logging/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_logging/vyos_logging/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_logging/vyos_logging/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_logging/vyos_logging/tests/cli/net_logging.yaml create mode 100644 test/integration/targets/vyos_smoke/defaults/main.yaml create mode 100644 test/integration/targets/vyos_smoke/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_smoke/tasks/main.yaml create mode 100644 test/integration/targets/vyos_smoke/tests/cli/common_config.yaml create mode 100644 test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml create mode 100644 test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml delete mode 100644 test/integration/targets/vyos_smoke/vyos_smoke/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_smoke/vyos_smoke/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_smoke/vyos_smoke/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_config.yaml delete mode 100644 test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_utils.yaml delete mode 100644 test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/misc_tests.yaml create mode 100644 test/integration/targets/vyos_static_route/aliases create mode 100644 test/integration/targets/vyos_static_route/defaults/main.yaml create mode 100644 test/integration/targets/vyos_static_route/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_static_route/tasks/main.yaml create mode 100644 test/integration/targets/vyos_static_route/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml delete mode 100644 test/integration/targets/vyos_static_route/vyos_static_route/aliases delete mode 100644 test/integration/targets/vyos_static_route/vyos_static_route/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_static_route/vyos_static_route/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_static_route/vyos_static_route/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/net_static_route.yaml create mode 100644 test/integration/targets/vyos_system/defaults/main.yaml create mode 100644 test/integration/targets/vyos_system/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_system/tasks/main.yaml create mode 100644 test/integration/targets/vyos_system/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_system/tests/cli/net_system.yaml delete mode 100644 test/integration/targets/vyos_system/vyos_system/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_system/vyos_system/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_system/vyos_system/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_system/vyos_system/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_system/vyos_system/tests/cli/net_system.yaml create mode 100644 test/integration/targets/vyos_user/aliases create mode 100644 test/integration/targets/vyos_user/defaults/main.yaml create mode 100644 test/integration/targets/vyos_user/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_user/tasks/main.yaml create mode 100644 test/integration/targets/vyos_user/tests/cli/auth.yaml create mode 100644 test/integration/targets/vyos_user/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_user/vyos_user/aliases delete mode 100644 test/integration/targets/vyos_user/vyos_user/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_user/vyos_user/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_user/vyos_user/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_user/vyos_user/tests/cli/auth.yaml delete mode 100644 test/integration/targets/vyos_user/vyos_user/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_vlan/aliases create mode 100644 test/integration/targets/vyos_vlan/defaults/main.yaml create mode 100644 test/integration/targets/vyos_vlan/tasks/cli.yaml create mode 100644 test/integration/targets/vyos_vlan/tasks/main.yaml create mode 100644 test/integration/targets/vyos_vlan/tests/cli/basic.yaml create mode 100644 test/integration/targets/vyos_vlan/tests/cli/intent.yaml create mode 100644 test/integration/targets/vyos_vlan/tests/cli/multiple.yaml delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/aliases delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/defaults/main.yaml delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/tasks/cli.yaml delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/tasks/main.yaml delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/basic.yaml delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/intent.yaml delete mode 100644 test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/multiple.yaml diff --git a/test/integration/targets/vyos_banner/aliases b/test/integration/targets/vyos_banner/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_banner/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_banner/defaults/main.yaml b/test/integration/targets/vyos_banner/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_banner/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_banner/tasks/cli.yaml b/test/integration/targets/vyos_banner/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_banner/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_banner/tasks/main.yaml b/test/integration/targets/vyos_banner/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_banner/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml new file mode 100644 index 00000000..5efdf8ed --- /dev/null +++ b/test/integration/targets/vyos_banner/tests/cli/basic-no-login.yaml @@ -0,0 +1,41 @@ +--- +- debug: + 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 + state: present + +- name: remove pre-login + vyos.vyos.vyos_banner: + banner: pre-login + state: absent + register: result + +- debug: + msg: "{{ result }}" + +- assert: + that: + - "result.changed == true" + - "'delete system login banner pre-login' in result.commands" + +- name: remove pre-login (idempotent) + 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" diff --git a/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml new file mode 100644 index 00000000..ff6cbad0 --- /dev/null +++ b/test/integration/targets/vyos_banner/tests/cli/basic-post-login.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: "cli/basic-post-login.yaml on connection={{ ansible_connection }}" + +- name: setup - remove post-login + vyos.vyos.vyos_banner: + banner: post-login + state: absent + +- name: Set post-login + vyos.vyos.vyos_banner: + banner: post-login + text: | + this is my post-login banner + that has a multiline + string + state: present + register: result + +- debug: + msg: "{{ result }}" + +- assert: + that: + - "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) + vyos.vyos.vyos_banner: + banner: post-login + text: | + this is my post-login banner + that has a multiline + string + 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" diff --git a/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml b/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml new file mode 100644 index 00000000..8489d87b --- /dev/null +++ b/test/integration/targets/vyos_banner/tests/cli/basic-pre-login.yaml @@ -0,0 +1,47 @@ +--- +- debug: + msg: "cli/basic-pre-login.yaml on connection={{ ansible_connection }}" + +- name: setup - remove pre-login + vyos.vyos.vyos_banner: + banner: pre-login + state: absent + +- name: Set pre-login + vyos.vyos.vyos_banner: + banner: pre-login + text: | + this is my pre-login banner + that has a multiline + string + state: present + register: result + +- debug: + msg: "{{ result }}" + +- assert: + that: + - "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) + vyos.vyos.vyos_banner: + banner: pre-login + text: | + this is my pre-login banner + that has a multiline + string + 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" diff --git a/test/integration/targets/vyos_banner/vyos_banner/aliases b/test/integration/targets/vyos_banner/vyos_banner/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_banner/vyos_banner/defaults/main.yaml b/test/integration/targets/vyos_banner/vyos_banner/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_banner/vyos_banner/tasks/cli.yaml b/test/integration/targets/vyos_banner/vyos_banner/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/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/test/integration/targets/vyos_banner/vyos_banner/tasks/main.yaml b/test/integration/targets/vyos_banner/vyos_banner/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-no-login.yaml b/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-no-login.yaml deleted file mode 100644 index d513d2e1..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-no-login.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- debug: - msg: "cli/basic-no-login.yaml on connection={{ ansible_connection }}" - -- name: Setup - vyos_banner: - banner: pre-login - text: | - Junk pre-login banner - over multiple lines - state: present - -- name: remove pre-login - vyos_banner: - banner: pre-login - state: absent - register: result - -- debug: - msg: "{{ result }}" - -- assert: - that: - - "result.changed == true" - - "'delete system login banner pre-login' in result.commands" - -- name: remove pre-login (idempotent) - 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" diff --git a/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-post-login.yaml b/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-post-login.yaml deleted file mode 100644 index bda84a8c..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-post-login.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- debug: - msg: "cli/basic-post-login.yaml on connection={{ ansible_connection }}" - -- name: setup - remove post-login - vyos_banner: - banner: post-login - state: absent - -- name: Set post-login - vyos_banner: - banner: post-login - text: | - this is my post-login banner - that has a multiline - string - state: present - register: result - -- debug: - msg: "{{ result }}" - -- assert: - that: - - "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) - vyos_banner: - banner: post-login - text: | - this is my post-login banner - that has a multiline - string - 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" diff --git a/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-pre-login.yaml b/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-pre-login.yaml deleted file mode 100644 index eb66a73b..00000000 --- a/test/integration/targets/vyos_banner/vyos_banner/tests/cli/basic-pre-login.yaml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- debug: - msg: "cli/basic-pre-login.yaml on connection={{ ansible_connection }}" - -- name: setup - remove pre-login - vyos_banner: - banner: pre-login - state: absent - -- name: Set pre-login - vyos_banner: - banner: pre-login - text: | - this is my pre-login banner - that has a multiline - string - state: present - register: result - -- debug: - msg: "{{ result }}" - -- assert: - that: - - "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) - vyos_banner: - banner: pre-login - text: | - this is my pre-login banner - that has a multiline - string - 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" diff --git a/test/integration/targets/vyos_command/aliases b/test/integration/targets/vyos_command/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_command/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_command/defaults/main.yaml b/test/integration/targets/vyos_command/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_command/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_command/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_command/tasks/main.yaml b/test/integration/targets/vyos_command/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_command/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml new file mode 100644 index 00000000..bf3334f2 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/bad_operator.yaml @@ -0,0 +1,19 @@ +--- +- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" + +- name: test bad operator + vyos.vyos.vyos_command: + commands: + - show version + - show interfaces + wait_for: + - result[0] is 'VyOS' + register: result + ignore_errors: yes + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml new file mode 100644 index 00000000..caeb2021 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/cli_command.yaml @@ -0,0 +1,41 @@ +--- +- debug: + msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}" + +- block: + - name: get output for single command + cli_command: + command: show version + register: result + + - assert: + that: + - "result.changed == false" + - "result.stdout is defined" + + - name: send invalid command + cli_command: + command: 'show foo' + register: result + ignore_errors: yes + + - assert: + that: + - "result.failed == true" + - "result.msg is defined" + when: "ansible_connection == 'network_cli'" + +- block: + - name: test failure for local connection + cli_command: + command: show version + register: result + ignore_errors: yes + + - assert: + that: + - 'result.failed == true' + - "'Connection type local is not valid for this module' in result.msg" + when: "ansible_connection == 'local'" + +- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/tests/cli/contains.yaml new file mode 100644 index 00000000..b8665fa7 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/contains.yaml @@ -0,0 +1,20 @@ +--- +- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" + +- name: test contains operator + vyos.vyos.vyos_command: + commands: + - show version + - show interface + wait_for: + - result[0] contains VyOS + - result[1] contains eth0 + register: result + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/tests/cli/invalid.yaml new file mode 100644 index 00000000..672f6e81 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/invalid.yaml @@ -0,0 +1,22 @@ +--- +- 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: yes + +- assert: { that: result.failed } + +- name: run commands that include invalid command + vyos.vyos.vyos_command: + commands: + - show version + - show foo + register: result + ignore_errors: yes + +- assert: { that: result.failed } + +- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/tests/cli/output.yaml new file mode 100644 index 00000000..bdc8b2a8 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/output.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" + +- 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 + +- name: get output for multiple commands + vyos.vyos.vyos_command: + commands: + - show version + - show interfaces + register: result + +- assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout | length == 2 + +- name: Get output for multiple commands that call less explicitly + vyos.vyos.vyos_command: + commands: + # NOTE: We only test show commands that will output = 20 + +- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/tests/cli/timeout.yaml new file mode 100644 index 00000000..e4716ed6 --- /dev/null +++ b/test/integration/targets/vyos_command/tests/cli/timeout.yaml @@ -0,0 +1,18 @@ +--- +- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" + +- name: test bad condition + vyos.vyos.vyos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + register: result + ignore_errors: yes + +- assert: + that: + - result.failed == true + - result.msg is defined + +- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/aliases b/test/integration/targets/vyos_command/vyos_command/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_command/vyos_command/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_command/vyos_command/defaults/main.yaml b/test/integration/targets/vyos_command/vyos_command/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_command/vyos_command/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml b/test/integration/targets/vyos_command/vyos_command/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_command/vyos_command/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/test/integration/targets/vyos_command/vyos_command/tasks/main.yaml b/test/integration/targets/vyos_command/vyos_command/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml deleted file mode 100644 index 9e9de9f7..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/bad_operator.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}" - -- name: test bad operator - vyos_command: - commands: - - show version - - show interfaces - wait_for: - - result[0] is 'VyOS' - register: result - ignore_errors: yes - -- assert: - that: - - result.failed == true - - result.msg is defined - -- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml deleted file mode 100644 index caeb2021..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/cli_command.yaml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- debug: - msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}" - -- block: - - name: get output for single command - cli_command: - command: show version - register: result - - - assert: - that: - - "result.changed == false" - - "result.stdout is defined" - - - name: send invalid command - cli_command: - command: 'show foo' - register: result - ignore_errors: yes - - - assert: - that: - - "result.failed == true" - - "result.msg is defined" - when: "ansible_connection == 'network_cli'" - -- block: - - name: test failure for local connection - cli_command: - command: show version - register: result - ignore_errors: yes - - - assert: - that: - - 'result.failed == true' - - "'Connection type local is not valid for this module' in result.msg" - when: "ansible_connection == 'local'" - -- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml deleted file mode 100644 index 85c6e86a..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/contains.yaml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}" - -- name: test contains operator - vyos_command: - commands: - - show version - - show interface - wait_for: - - result[0] contains VyOS - - result[1] contains eth0 - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml deleted file mode 100644 index e6d25e41..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/invalid.yaml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}" - -- name: run invalid command - vyos_command: - commands: show foo - register: result - ignore_errors: yes - -- assert: { that: result.failed } - -- name: run commands that include invalid command - vyos_command: - commands: - - show version - - show foo - register: result - ignore_errors: yes - -- assert: { that: result.failed } - -- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml deleted file mode 100644 index 294f62f7..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/output.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}" - -- name: get output for single command - vyos_command: - commands: show version - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout_lines is defined - -- name: get output for multiple commands - vyos_command: - commands: - - show version - - show interfaces - register: result - -- assert: - that: - - result.changed == false - - result.stdout is defined - - result.stdout | length == 2 - -- name: Get output for multiple commands that call less explicitly - vyos_command: - commands: - # NOTE: We only test show commands that will output = 20 - -- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml b/test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml deleted file mode 100644 index 4994ebff..00000000 --- a/test/integration/targets/vyos_command/vyos_command/tests/cli/timeout.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}" - -- name: test bad condition - vyos_command: - commands: - - show version - wait_for: - - result[0] contains bad_value_string - register: result - ignore_errors: yes - -- assert: - that: - - result.failed == true - - result.msg is defined - -- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/aliases b/test/integration/targets/vyos_config/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_config/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_config/defaults/main.yaml b/test/integration/targets/vyos_config/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_config/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_config/tasks/cli.yaml b/test/integration/targets/vyos_config/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_config/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_config/tasks/cli_config.yaml b/test/integration/targets/vyos_config/tasks/cli_config.yaml new file mode 100644 index 00000000..f5d5b551 --- /dev/null +++ b/test/integration/targets/vyos_config/tasks/cli_config.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli_config test cases + find: + 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 }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_config/tasks/main.yaml b/test/integration/targets/vyos_config/tasks/main.yaml new file mode 100644 index 00000000..5e327e8d --- /dev/null +++ b/test/integration/targets/vyos_config/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: cli_config.yaml, tags: ['cli_config'] } diff --git a/test/integration/targets/vyos_config/tests/cli/backup.yaml b/test/integration/targets/vyos_config/tests/cli/backup.yaml new file mode 100644 index 00000000..0ef0986d --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli/backup.yaml @@ -0,0 +1,113 @@ +--- +- debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" + +- name: collect any backup files + find: + paths: "{{ role_path }}/backup" + pattern: "{{ inventory_hostname_short }}_config*" + register: backup_files + connection: local + +- name: delete backup files + file: + path: "{{ item.path }}" + state: absent + with_items: "{{backup_files.files|default([])}}" + +- name: take configure backup + vyos.vyos.vyos_config: + backup: yes + register: result + +- assert: + that: + - "result.changed == true" + +- name: collect any backup files + find: + paths: "{{ role_path }}/backup" + pattern: "{{ inventory_hostname_short }}_config*" + register: backup_files + connection: local + +- assert: + that: + - "backup_files.files is defined" + +- name: delete configurable backup file path + file: + path: "{{ item }}" + state: absent + with_items: + - "{{ role_path }}/backup_test_dir/" + - "{{ role_path }}/backup/backup.cfg" + +- name: take configuration backup in custom filename and directory path + vyos.vyos.vyos_config: + backup: yes + backup_options: + filename: backup.cfg + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + become: yes + register: result + +- assert: + that: + - "result.changed == true" + +- name: check if the backup file-1 exist + find: + paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" + register: backup_file + connection: local + +- assert: + that: + - "backup_file.files is defined" + +- name: take configuration backup in custom filename + vyos.vyos.vyos_config: + backup: yes + backup_options: + filename: backup.cfg + become: yes + register: result + +- assert: + that: + - "result.changed == true" + +- name: check if the backup file-2 exist + find: + paths: "{{ role_path }}/backup/backup.cfg" + register: backup_file + connection: local + +- assert: + that: + - "backup_file.files is defined" + +- name: take configuration backup in custom path and default filename + vyos.vyos.vyos_config: + backup: yes + backup_options: + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + become: yes + register: result + +- assert: + that: + - "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*" + register: backup_file + connection: local + +- assert: + that: + - "backup_file.files is defined" + +- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/check_config.yaml b/test/integration/targets/vyos_config/tests/cli/check_config.yaml new file mode 100644 index 00000000..b90ec7b6 --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli/check_config.yaml @@ -0,0 +1,63 @@ +--- +- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}" + +- name: setup- ensure interface is not present + vyos.vyos.vyos_config: + lines: delete interfaces loopback lo + +- name: setup- create interface + 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" + +- name: Check that set is correctly prepended + assert: + that: + - "result.commands[0] == 'set interfaces loopback lo description test'" + +- name: configure config_check config command + vyos.vyos.vyos_config: + lines: delete interfaces loopback lo + register: result + +- assert: + that: + - "result.changed == true" + +- name: check config_check config command idempontent + vyos.vyos.vyos_config: + lines: delete interfaces loopback lo + register: result + +- assert: + that: + - "result.changed == false" + +- name: check multiple line config filter is working + 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" + +- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/comment.yaml b/test/integration/targets/vyos_config/tests/cli/comment.yaml new file mode 100644 index 00000000..2cd13509 --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli/comment.yaml @@ -0,0 +1,34 @@ +--- +- debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- name: configure using comment + vyos.vyos.vyos_config: + lines: set system host-name foo + comment: this is a test + register: result + +- assert: + that: + - "result.changed == true" + - "'set system host-name foo' in result.commands" + +- name: collect system commits + vyos.vyos.vyos_command: + commands: show system commit + register: result + +- assert: + that: + - "'this is a test' in result.stdout_lines[0][1]" + +- name: teardown + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/save.yaml b/test/integration/targets/vyos_config/tests/cli/save.yaml new file mode 100644 index 00000000..d8e45e25 --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli/save.yaml @@ -0,0 +1,54 @@ +--- +- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- name: configure hostaname and save + vyos.vyos.vyos_config: + lines: set system host-name foo + save: true + register: result + +- assert: + that: + - "result.changed == true" + - "'set system host-name foo' in result.commands" + +- name: configure hostaname and don't save + vyos.vyos.vyos_config: + lines: set system host-name bar + register: result + +- assert: + that: + - "result.changed == true" + - "'set system host-name bar' in result.commands" + +- name: save config + vyos.vyos.vyos_config: + save: true + register: result + +- assert: + that: + - "result.changed == true" + +- name: save config again + vyos.vyos.vyos_config: + save: true + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + save: true + +- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli/simple.yaml b/test/integration/targets/vyos_config/tests/cli/simple.yaml new file mode 100644 index 00000000..af211f59 --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli/simple.yaml @@ -0,0 +1,33 @@ +--- +- debug: msg="START cli/simple.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- name: configure simple config command + vyos.vyos.vyos_config: + lines: set system host-name foo + register: result + +- assert: + that: + - "result.changed == true" + - "'set system host-name foo' in result.commands" + +- name: check simple config command idempontent + vyos.vyos.vyos_config: + lines: set system host-name foo + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos.vyos.vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + match: none + +- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml new file mode 100644 index 00000000..a431c01f --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml @@ -0,0 +1,113 @@ +- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" + +- name: delete configurable backup file path + file: + path: "{{ item }}" + state: absent + with_items: + - "{{ 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*" + register: backup_files + connection: local + +- name: delete backup files + file: + path: "{{ item.path }}" + state: absent + with_items: "{{backup_files.files|default([])}}" + +- name: take config backup + cli_config: + backup: yes + become: yes + register: result + +- assert: + that: + - "result.changed == true" + +- name: collect any backup files + find: + paths: "{{ role_path }}/backup" + pattern: "{{ inventory_hostname_short }}_config*" + register: backup_files + connection: local + +- assert: + that: + - "backup_files.files is defined" + +- name: take configuration backup in custom filename and directory path + cli_config: + backup: yes + backup_options: + filename: backup.cfg + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + become: yes + register: result + +- assert: + that: + - "result.changed == true" + +- name: check if the backup file-1 exist + find: + paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" + register: backup_file + connection: local + +- assert: + that: + - "backup_file.files is defined" + +- name: take configuration backup in custom filename + cli_config: + backup: yes + backup_options: + filename: backup.cfg + become: yes + register: result + +- assert: + that: + - "result.changed == true" + +- name: check if the backup file-2 exist + find: + paths: "{{ role_path }}/backup/backup.cfg" + register: backup_file + connection: local + +- assert: + that: + - "backup_file.files is defined" + +- name: take configuration backup in custom path and default filename + cli_config: + backup: yes + backup_options: + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + become: yes + register: result + +- assert: + that: + - "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*" + register: backup_file + connection: local + +- assert: + that: + - "backup_file.files is defined" + +- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml new file mode 100644 index 00000000..e83db1ea --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli_config/cli_basic.yaml @@ -0,0 +1,28 @@ +--- +- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}" + +- name: setup - remove interface description + cli_config: &rm + config: delete interfaces loopback lo description + +- name: configure device with config + cli_config: &conf + config: set interfaces loopback lo description 'this is a test' + register: result + +- assert: + that: + - "result.changed == true" + +- name: Idempotence + cli_config: *conf + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + cli_config: *rm + +- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml b/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml new file mode 100644 index 00000000..4f9a048d --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli_config/cli_comment.yaml @@ -0,0 +1,30 @@ +--- +- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}" + +- name: setup + cli_config: &rm + config: set system host-name {{ inventory_hostname_short }} + +- name: configure using comment + cli_config: + config: set system host-name foo + commit_comment: this is a test + register: result + +- assert: + that: + - "result.changed == true" + +- name: collect system commits + vyos.vyos.vyos_command: + commands: show system commit + register: result + +- assert: + that: + - "'this is a test' in result.stdout_lines[0][1]" + +- name: teardown + cli_config: *rm + +- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/aliases b/test/integration/targets/vyos_config/vyos_config/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_config/vyos_config/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_config/vyos_config/defaults/main.yaml b/test/integration/targets/vyos_config/vyos_config/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_config/vyos_config/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_config/vyos_config/tasks/cli.yaml b/test/integration/targets/vyos_config/vyos_config/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_config/vyos_config/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/test/integration/targets/vyos_config/vyos_config/tasks/cli_config.yaml b/test/integration/targets/vyos_config/vyos_config/tasks/cli_config.yaml deleted file mode 100644 index f5d5b551..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tasks/cli_config.yaml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: collect all cli_config test cases - find: - 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 }}" - loop_control: - loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_config/vyos_config/tasks/main.yaml b/test/integration/targets/vyos_config/vyos_config/tasks/main.yaml deleted file mode 100644 index 5e327e8d..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tasks/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } -- { include: cli_config.yaml, tags: ['cli_config'] } diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli/backup.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli/backup.yaml deleted file mode 100644 index 9f57c445..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli/backup.yaml +++ /dev/null @@ -1,113 +0,0 @@ ---- -- debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- name: delete backup files - file: - path: "{{ item.path }}" - state: absent - with_items: "{{backup_files.files|default([])}}" - -- name: take configure backup - vyos_config: - backup: yes - register: result - -- assert: - that: - - "result.changed == true" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- assert: - that: - - "backup_files.files is defined" - -- name: delete configurable backup file path - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ role_path }}/backup_test_dir/" - - "{{ role_path }}/backup/backup.cfg" - -- name: take configuration backup in custom filename and directory path - vyos_config: - backup: yes - backup_options: - filename: backup.cfg - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: yes - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-1 exist - find: - paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom filename - vyos_config: - backup: yes - backup_options: - filename: backup.cfg - become: yes - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-2 exist - find: - paths: "{{ role_path }}/backup/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom path and default filename - vyos_config: - backup: yes - backup_options: - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: yes - register: result - -- assert: - that: - - "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*" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli/check_config.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli/check_config.yaml deleted file mode 100644 index 65076b3c..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli/check_config.yaml +++ /dev/null @@ -1,63 +0,0 @@ ---- -- debug: msg="START cli/config_check.yaml on connection={{ ansible_connection }}" - -- name: setup- ensure interface is not present - vyos_config: - lines: delete interfaces loopback lo - -- name: setup- create interface - 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" - -- name: Check that set is correctly prepended - assert: - that: - - "result.commands[0] == 'set interfaces loopback lo description test'" - -- name: configure config_check config command - vyos_config: - lines: delete interfaces loopback lo - register: result - -- assert: - that: - - "result.changed == true" - -- name: check config_check config command idempontent - vyos_config: - lines: delete interfaces loopback lo - register: result - -- assert: - that: - - "result.changed == false" - -- name: check multiple line config filter is working - 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" - -- debug: msg="END cli/config_check.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli/comment.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli/comment.yaml deleted file mode 100644 index 3c71dfc6..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli/comment.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- name: configure using comment - vyos_config: - lines: set system host-name foo - comment: this is a test - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name foo' in result.commands" - -- name: collect system commits - vyos_command: - commands: show system commit - register: result - -- assert: - that: - - "'this is a test' in result.stdout_lines[0][1]" - -- name: teardown - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- debug: msg="END cli/comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli/save.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli/save.yaml deleted file mode 100644 index 7b058a7b..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli/save.yaml +++ /dev/null @@ -1,54 +0,0 @@ ---- -- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- name: configure hostaname and save - vyos_config: - lines: set system host-name foo - save: true - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name foo' in result.commands" - -- name: configure hostaname and don't save - vyos_config: - lines: set system host-name bar - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name bar' in result.commands" - -- name: save config - vyos_config: - save: true - register: result - -- assert: - that: - - "result.changed == true" - -- name: save config again - vyos_config: - save: true - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - save: true - -- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli/simple.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli/simple.yaml deleted file mode 100644 index a4a87995..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli/simple.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- debug: msg="START cli/simple.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- name: configure simple config command - vyos_config: - lines: set system host-name foo - register: result - -- assert: - that: - - "result.changed == true" - - "'set system host-name foo' in result.commands" - -- name: check simple config command idempontent - vyos_config: - lines: set system host-name foo - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none - -- debug: msg="END cli/simple.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_backup.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_backup.yaml deleted file mode 100644 index a431c01f..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_backup.yaml +++ /dev/null @@ -1,113 +0,0 @@ -- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" - -- name: delete configurable backup file path - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ 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*" - register: backup_files - connection: local - -- name: delete backup files - file: - path: "{{ item.path }}" - state: absent - with_items: "{{backup_files.files|default([])}}" - -- name: take config backup - cli_config: - backup: yes - become: yes - register: result - -- assert: - that: - - "result.changed == true" - -- name: collect any backup files - find: - paths: "{{ role_path }}/backup" - pattern: "{{ inventory_hostname_short }}_config*" - register: backup_files - connection: local - -- assert: - that: - - "backup_files.files is defined" - -- name: take configuration backup in custom filename and directory path - cli_config: - backup: yes - backup_options: - filename: backup.cfg - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: yes - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-1 exist - find: - paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom filename - cli_config: - backup: yes - backup_options: - filename: backup.cfg - become: yes - register: result - -- assert: - that: - - "result.changed == true" - -- name: check if the backup file-2 exist - find: - paths: "{{ role_path }}/backup/backup.cfg" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- name: take configuration backup in custom path and default filename - cli_config: - backup: yes - backup_options: - dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" - become: yes - register: result - -- assert: - that: - - "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*" - register: backup_file - connection: local - -- assert: - that: - - "backup_file.files is defined" - -- debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_basic.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_basic.yaml deleted file mode 100644 index e83db1ea..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_basic.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}" - -- name: setup - remove interface description - cli_config: &rm - config: delete interfaces loopback lo description - -- name: configure device with config - cli_config: &conf - config: set interfaces loopback lo description 'this is a test' - register: result - -- assert: - that: - - "result.changed == true" - -- name: Idempotence - cli_config: *conf - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - cli_config: *rm - -- debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_comment.yaml b/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_comment.yaml deleted file mode 100644 index 163f05ee..00000000 --- a/test/integration/targets/vyos_config/vyos_config/tests/cli_config/cli_comment.yaml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- debug: msg="START cli_config/cli_comment.yaml on connection={{ ansible_connection }}" - -- name: setup - cli_config: &rm - config: set system host-name {{ inventory_hostname_short }} - -- name: configure using comment - cli_config: - config: set system host-name foo - commit_comment: this is a test - register: result - -- assert: - that: - - "result.changed == true" - -- name: collect system commits - vyos_command: - commands: show system commit - register: result - -- assert: - that: - - "'this is a test' in result.stdout_lines[0][1]" - -- name: teardown - cli_config: *rm - -- debug: msg="END cli_config/cli_comment.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_facts/aliases b/test/integration/targets/vyos_facts/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_facts/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_facts/defaults/main.yaml b/test/integration/targets/vyos_facts/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_facts/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_facts/tasks/cli.yaml b/test/integration/targets/vyos_facts/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_facts/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_facts/tasks/main.yaml b/test/integration/targets/vyos_facts/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_facts/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml b/test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml new file mode 100644 index 00000000..e0a3bcae --- /dev/null +++ b/test/integration/targets/vyos_facts/tests/cli/basic_facts.yaml @@ -0,0 +1,45 @@ +- name: get host name + vyos.vyos.vyos_command: + commands: + - show host name + register: vyos_host + +- name: get version info + vyos.vyos.vyos_command: + commands: + - show version + register: vyos_version + +- name: collect all facts from the device + vyos.vyos.vyos_facts: + gather_subset: all + register: result + +- 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" + 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" + 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" + assert: + that: + # config info + - result.ansible_facts.ansible_net_commits is defined + - result.ansible_facts.ansible_net_config is defined diff --git a/test/integration/targets/vyos_facts/vyos_facts/aliases b/test/integration/targets/vyos_facts/vyos_facts/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_facts/vyos_facts/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_facts/vyos_facts/defaults/main.yaml b/test/integration/targets/vyos_facts/vyos_facts/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_facts/vyos_facts/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_facts/vyos_facts/tasks/cli.yaml b/test/integration/targets/vyos_facts/vyos_facts/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_facts/vyos_facts/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/test/integration/targets/vyos_facts/vyos_facts/tasks/main.yaml b/test/integration/targets/vyos_facts/vyos_facts/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_facts/vyos_facts/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_facts/vyos_facts/tests/cli/basic_facts.yaml b/test/integration/targets/vyos_facts/vyos_facts/tests/cli/basic_facts.yaml deleted file mode 100644 index 16850cbf..00000000 --- a/test/integration/targets/vyos_facts/vyos_facts/tests/cli/basic_facts.yaml +++ /dev/null @@ -1,45 +0,0 @@ -- name: get host name - vyos_command: - commands: - - show host name - register: vyos_host - -- name: get version info - vyos_command: - commands: - - show version - register: vyos_version - -- name: collect all facts from the device - vyos_facts: - gather_subset: all - register: result - -- 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" - 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" - 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" - assert: - that: - # config info - - result.ansible_facts.ansible_net_commits is defined - - result.ansible_facts.ansible_net_config is defined diff --git a/test/integration/targets/vyos_interface/aliases b/test/integration/targets/vyos_interface/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_interface/defaults/main.yaml b/test/integration/targets/vyos_interface/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_interface/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_interface/tasks/cli.yaml b/test/integration/targets/vyos_interface/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_interface/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_interface/tasks/main.yaml b/test/integration/targets/vyos_interface/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_interface/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..22957e14 --- /dev/null +++ b/test/integration/targets/vyos_interface/tests/cli/basic.yaml @@ -0,0 +1,220 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Run vyos lsmod command + vyos.vyos.vyos_command: + commands: + - lsmod + register: lsmod_out + +- name: Set up - delete interface + vyos.vyos.vyos_interface: + name: eth1 + state: absent + +- name: Set up - Create interface + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1" in result.commands' + - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands' + +- name: Configure interface params + vyos.vyos.vyos_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' + - '"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) + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface-1 + speed: 100 + duplex: half + mtu: 256 + register: result + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- assert: + that: + - 'result.changed == false' + when: "'virtio' not in lsmod_out.stdout[0]" + +- name: Change interface params + vyos.vyos.vyos_interface: + name: eth1 + state: present + description: test-interface-2 + 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' + - '"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 + vyos.vyos.vyos_interface: + name: eth1 + enabled: False + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1 disable" in result.commands' + +- name: Enable interface + vyos.vyos.vyos_interface: + name: eth1 + enabled: True + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 disable" in result.commands' + +- name: Delete interface + vyos.vyos.vyos_interface: + name: eth1 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1" in result.commands' + +- name: Delete interface (idempotent) + vyos.vyos.vyos_interface: + name: eth1 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Aggregate setup- delete interface + 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]" + +- assert: + that: + - '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 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]" + +- assert: + that: + - 'result.changed == false' + when: "'virtio_net' not in lsmod_out.stdout[0]" + +- name: Disable interface on aggregate + vyos.vyos.vyos_interface: + aggregate: + - name: eth1 + - name: eth2 + description: test-interface + enabled: False + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1 disable" in result.commands' + - '"set interfaces ethernet eth2 disable" in result.commands' + +- name: Enable interface on aggregate + vyos.vyos.vyos_interface: + aggregate: + - name: eth1 + - name: eth2 + enabled: True + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 disable" in result.commands' + - '"delete interfaces ethernet eth2 disable" in result.commands' + +- name: Delete interface aggregate + vyos.vyos.vyos_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1" in result.commands' + - '"delete interfaces ethernet eth2" in result.commands' + +- name: Delete interface aggregate (idempotent) + vyos.vyos.vyos_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' diff --git a/test/integration/targets/vyos_interface/tests/cli/intent.yaml b/test/integration/targets/vyos_interface/tests/cli/intent.yaml new file mode 100644 index 00000000..946728db --- /dev/null +++ b/test/integration/targets/vyos_interface/tests/cli/intent.yaml @@ -0,0 +1,157 @@ +--- +- 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 + 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 + vyos.vyos.vyos_lldp: + state: present + when: run_lldp_tests + +- name: Create LLDP configuration + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: present + when: run_lldp_tests + +- name: Setup (interface is up) + 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 + +- assert: + that: + - "result.failed == false" + +- name: Check lldp neighbors intent arguments + vyos.vyos.vyos_interface: + name: eth0 + neighbors: + - port: eth0 + when: run_lldp_tests + register: result + +- assert: + that: + - "result.failed == false" + when: run_lldp_tests + +- name: Check intent arguments (failed condition) + vyos.vyos.vyos_interface: + name: eth1 + state: down + ignore_errors: yes + register: result + +- assert: + that: + - "result.failed == true" + - "'state eq(down)' in result.failed_conditions" + +- name: Check lldp neighbors intent arguments (failed) + vyos.vyos.vyos_interface: + name: eth0 + neighbors: + - port: dummy_port + host: dummy_host + ignore_errors: yes + when: run_lldp_tests + register: result + +- assert: + that: + - "result.failed == true" + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: run_lldp_tests + +- name: Config + intent + vyos.vyos.vyos_interface: + name: eth1 + enabled: False + state: down + register: result + +- assert: + that: + - "result.failed == false" + +- name: Config + intent (fail) + vyos.vyos.vyos_interface: + name: eth1 + enabled: False + state: up + ignore_errors: yes + register: result + +- assert: + that: + - "result.failed == true" + - "'state eq(up)' in result.failed_conditions" + +- name: Aggregate config + intent (pass) + vyos.vyos.vyos_interface: + aggregate: + - name: eth1 + enabled: True + state: up + ignore_errors: yes + register: result + +- assert: + that: + - "result.failed == false" + +- name: Check lldp neighbors intent aggregate arguments + vyos.vyos.vyos_interface: + aggregate: + - name: eth0 + neighbors: + - port: eth0 + when: run_lldp_tests + register: result + +- assert: + that: + - "result.failed == false" + when: run_lldp_tests + +- name: Check lldp neighbors intent aggregate arguments (failed) + vyos.vyos.vyos_interface: + aggregate: + - name: eth0 + neighbors: + - port: eth0 + - port: dummy_port + host: dummy_host + ignore_errors: yes + when: run_lldp_tests + register: result + +- assert: + that: + - "result.failed == true" + - "'host dummy_host' in result.failed_conditions" + - "'port dummy_port' in result.failed_conditions" + when: run_lldp_tests diff --git a/test/integration/targets/vyos_interface/tests/cli/net_interface.yaml b/test/integration/targets/vyos_interface/tests/cli/net_interface.yaml new file mode 100644 index 00000000..4bdb6ecc --- /dev/null +++ b/test/integration/targets/vyos_interface/tests/cli/net_interface.yaml @@ -0,0 +1,56 @@ +--- +- 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. + +- name: Run vyos lsmod command + vyos.vyos.vyos_command: + commands: + - lsmod + register: lsmod_out + +- name: Set up - delete interface + net_interface: + name: eth1 + state: absent + +- name: Create interface using platform agnostic module + net_interface: + name: eth1 + state: present + description: test-interface + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1" in result.commands' + - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands' + +- name: Configure interface params using platform agnostic module + 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' + - '"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: + name: eth1 + state: absent + +- debug: msg="END vyos cli/net_interface.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_interface/vyos_interface/aliases b/test/integration/targets/vyos_interface/vyos_interface/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_interface/vyos_interface/defaults/main.yaml b/test/integration/targets/vyos_interface/vyos_interface/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_interface/vyos_interface/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_interface/vyos_interface/tasks/cli.yaml b/test/integration/targets/vyos_interface/vyos_interface/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_interface/vyos_interface/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/test/integration/targets/vyos_interface/vyos_interface/tasks/main.yaml b/test/integration/targets/vyos_interface/vyos_interface/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_interface/vyos_interface/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_interface/vyos_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_interface/vyos_interface/tests/cli/basic.yaml deleted file mode 100644 index 2b9ce129..00000000 --- a/test/integration/targets/vyos_interface/vyos_interface/tests/cli/basic.yaml +++ /dev/null @@ -1,220 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Run vyos lsmod command - vyos_command: - commands: - - lsmod - register: lsmod_out - -- name: Set up - delete interface - vyos_interface: - name: eth1 - state: absent - -- name: Set up - Create interface - vyos_interface: - name: eth1 - state: present - description: test-interface - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1" in result.commands' - - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands' - -- name: Configure interface params - vyos_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' - - '"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) - vyos_interface: - name: eth1 - state: present - description: test-interface-1 - speed: 100 - duplex: half - mtu: 256 - register: result - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- assert: - that: - - 'result.changed == false' - when: "'virtio' not in lsmod_out.stdout[0]" - -- name: Change interface params - vyos_interface: - name: eth1 - state: present - description: test-interface-2 - 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' - - '"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 - vyos_interface: - name: eth1 - enabled: False - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 disable" in result.commands' - -- name: Enable interface - vyos_interface: - name: eth1 - enabled: True - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 disable" in result.commands' - -- name: Delete interface - vyos_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1" in result.commands' - -- name: Delete interface (idempotent) - vyos_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Aggregate setup- delete interface - vyos_interface: - name: eth2 - state: absent - register: result - -- name: Set interface on aggregate - 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]" - -- assert: - that: - - '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 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_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]" - -- assert: - that: - - 'result.changed == false' - when: "'virtio_net' not in lsmod_out.stdout[0]" - -- name: Disable interface on aggregate - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - description: test-interface - enabled: False - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 disable" in result.commands' - - '"set interfaces ethernet eth2 disable" in result.commands' - -- name: Enable interface on aggregate - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - enabled: True - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 disable" in result.commands' - - '"delete interfaces ethernet eth2 disable" in result.commands' - -- name: Delete interface aggregate - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1" in result.commands' - - '"delete interfaces ethernet eth2" in result.commands' - -- name: Delete interface aggregate (idempotent) - vyos_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_interface/vyos_interface/tests/cli/intent.yaml b/test/integration/targets/vyos_interface/vyos_interface/tests/cli/intent.yaml deleted file mode 100644 index 008dd56b..00000000 --- a/test/integration/targets/vyos_interface/vyos_interface/tests/cli/intent.yaml +++ /dev/null @@ -1,157 +0,0 @@ ---- -- 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 - 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 - vyos_lldp: - state: present - when: run_lldp_tests - -- name: Create LLDP configuration - vyos_lldp_interface: - name: eth1 - state: present - when: run_lldp_tests - -- name: Setup (interface is up) - vyos_interface: - name: eth1 - enabled: True - state: present - register: result - -- name: Check intent arguments - vyos_interface: - name: eth1 - state: up - register: result - -- assert: - that: - - "result.failed == false" - -- name: Check lldp neighbors intent arguments - vyos_interface: - name: eth0 - neighbors: - - port: eth0 - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == false" - when: run_lldp_tests - -- name: Check intent arguments (failed condition) - vyos_interface: - name: eth1 - state: down - ignore_errors: yes - register: result - -- assert: - that: - - "result.failed == true" - - "'state eq(down)' in result.failed_conditions" - -- name: Check lldp neighbors intent arguments (failed) - vyos_interface: - name: eth0 - neighbors: - - port: dummy_port - host: dummy_host - ignore_errors: yes - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == true" - - "'host dummy_host' in result.failed_conditions" - - "'port dummy_port' in result.failed_conditions" - when: run_lldp_tests - -- name: Config + intent - vyos_interface: - name: eth1 - enabled: False - state: down - register: result - -- assert: - that: - - "result.failed == false" - -- name: Config + intent (fail) - vyos_interface: - name: eth1 - enabled: False - state: up - ignore_errors: yes - register: result - -- assert: - that: - - "result.failed == true" - - "'state eq(up)' in result.failed_conditions" - -- name: Aggregate config + intent (pass) - vyos_interface: - aggregate: - - name: eth1 - enabled: True - state: up - ignore_errors: yes - register: result - -- assert: - that: - - "result.failed == false" - -- name: Check lldp neighbors intent aggregate arguments - vyos_interface: - aggregate: - - name: eth0 - neighbors: - - port: eth0 - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == false" - when: run_lldp_tests - -- name: Check lldp neighbors intent aggregate arguments (failed) - vyos_interface: - aggregate: - - name: eth0 - neighbors: - - port: eth0 - - port: dummy_port - host: dummy_host - ignore_errors: yes - when: run_lldp_tests - register: result - -- assert: - that: - - "result.failed == true" - - "'host dummy_host' in result.failed_conditions" - - "'port dummy_port' in result.failed_conditions" - when: run_lldp_tests diff --git a/test/integration/targets/vyos_interface/vyos_interface/tests/cli/net_interface.yaml b/test/integration/targets/vyos_interface/vyos_interface/tests/cli/net_interface.yaml deleted file mode 100644 index ced273d5..00000000 --- a/test/integration/targets/vyos_interface/vyos_interface/tests/cli/net_interface.yaml +++ /dev/null @@ -1,56 +0,0 @@ ---- -- 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. - -- name: Run vyos lsmod command - vyos_command: - commands: - - lsmod - register: lsmod_out - -- name: Set up - delete interface - net_interface: - name: eth1 - state: absent - -- name: Create interface using platform agnostic module - net_interface: - name: eth1 - state: present - description: test-interface - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1" in result.commands' - - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands' - -- name: Configure interface params using platform agnostic module - 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' - - '"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: - name: eth1 - state: absent - -- debug: msg="END vyos cli/net_interface.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_l3_interface/aliases b/test/integration/targets/vyos_l3_interface/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_l3_interface/defaults/main.yaml b/test/integration/targets/vyos_l3_interface/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_l3_interface/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_l3_interface/tasks/cli.yaml b/test/integration/targets/vyos_l3_interface/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_l3_interface/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_l3_interface/tasks/main.yaml b/test/integration/targets/vyos_l3_interface/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_l3_interface/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..9ad69554 --- /dev/null +++ b/test/integration/targets/vyos_l3_interface/tests/cli/basic.yaml @@ -0,0 +1,203 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Remove IP address + vyos.vyos.vyos_l3_interface: + name: eth1 + state: absent + +- name: Remove IP address + vyos.vyos.vyos_l3_interface: + name: eth2 + state: absent + +- name: Set IPv4 address + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + +- name: Set IPv4 address (idempotent) + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Set IPv6 address + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' + +- name: Set IPv6 address (idempotent) + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove all IP addresses + vyos.vyos.vyos_l3_interface: + name: eth1 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 address" in result.commands' + +- name: Remove all IP addresses again (idempotent) + vyos.vyos.vyos_l3_interface: + name: eth1 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Set IPv4 and IPv6 address + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' + +- name: Set IPv4 and IPv6 address again (idempotent) + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + ipv6: fd5d:12c9:2201:1::1/64 + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove IPv4 address + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + +- name: Remove IPv4 address again (idempotent) + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv4: 192.168.2.10/24 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove IPv6 address + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' + +- name: Remove IPv6 address again (idempotent) + vyos.vyos.vyos_l3_interface: + name: eth1 + ipv6: fd5d:12c9:2201:1::1/64 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Set IP addresses on aggregate + vyos.vyos.vyos_l3_interface: + aggregate: + - { name: eth1, ipv4: 192.168.2.10/24 } + - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } + - { name: eth2, ipv4: 192.168.4.10/24 } + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + - '"set interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' + - '"set interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' + - '"set interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' + +- name: Set IP addresses on aggregate (idempotent) + vyos.vyos.vyos_l3_interface: + aggregate: + - { name: eth1, ipv4: 192.168.2.10/24 } + - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } + - { name: eth2, ipv4: 192.168.4.10/24 } + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove IP addresses on aggregate + vyos.vyos.vyos_l3_interface: + aggregate: + - { name: eth1, ipv4: 192.168.2.10/24 } + - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } + - { name: eth2, ipv4: 192.168.4.10/24 } + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' + - '"delete interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' + - '"delete interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' + - '"delete interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' + +- name: Remove IP addresses on aggregate (idempotent) + vyos.vyos.vyos_l3_interface: + aggregate: + - { name: eth1, ipv4: 192.168.2.10/24 } + - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } + - { name: eth2, ipv4: 192.168.4.10/24 } + state: absent + register: result + +- assert: + that: + - 'result.changed == false' diff --git a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/aliases b/test/integration/targets/vyos_l3_interface/vyos_l3_interface/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/defaults/main.yaml b/test/integration/targets/vyos_l3_interface/vyos_l3_interface/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/cli.yaml b/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/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/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/main.yaml b/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tests/cli/basic.yaml deleted file mode 100644 index 73feadc3..00000000 --- a/test/integration/targets/vyos_l3_interface/vyos_l3_interface/tests/cli/basic.yaml +++ /dev/null @@ -1,203 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Remove IP address - vyos_l3_interface: - name: eth1 - state: absent - -- name: Remove IP address - vyos_l3_interface: - name: eth2 - state: absent - -- name: Set IPv4 address - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - -- name: Set IPv4 address (idempotent) - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Set IPv6 address - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' - -- name: Set IPv6 address (idempotent) - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove all IP addresses - vyos_l3_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address" in result.commands' - -- name: Remove all IP addresses again (idempotent) - vyos_l3_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Set IPv4 and IPv6 address - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - - '"set interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' - -- name: Set IPv4 and IPv6 address again (idempotent) - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - ipv6: fd5d:12c9:2201:1::1/64 - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove IPv4 address - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - -- name: Remove IPv4 address again (idempotent) - vyos_l3_interface: - name: eth1 - ipv4: 192.168.2.10/24 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove IPv6 address - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address fd5d:12c9:2201:1::1/64" in result.commands' - -- name: Remove IPv6 address again (idempotent) - vyos_l3_interface: - name: eth1 - ipv6: fd5d:12c9:2201:1::1/64 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Set IP addresses on aggregate - vyos_l3_interface: - aggregate: - - { name: eth1, ipv4: 192.168.2.10/24 } - - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } - - { name: eth2, ipv4: 192.168.4.10/24 } - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - - '"set interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' - - '"set interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' - - '"set interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' - -- name: Set IP addresses on aggregate (idempotent) - vyos_l3_interface: - aggregate: - - { name: eth1, ipv4: 192.168.2.10/24 } - - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } - - { name: eth2, ipv4: 192.168.4.10/24 } - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove IP addresses on aggregate - vyos_l3_interface: - aggregate: - - { name: eth1, ipv4: 192.168.2.10/24 } - - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } - - { name: eth2, ipv4: 192.168.4.10/24 } - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces ethernet eth1 address 192.168.2.10/24" in result.commands' - - '"delete interfaces ethernet eth2 address 192.168.3.10/24" in result.commands' - - '"delete interfaces ethernet eth2 address fd5d:12c9:2201:1::1/64" in result.commands' - - '"delete interfaces ethernet eth2 address 192.168.4.10/24" in result.commands' - -- name: Remove IP addresses on aggregate (idempotent) - vyos_l3_interface: - aggregate: - - { name: eth1, ipv4: 192.168.2.10/24 } - - { name: eth2, ipv4: 192.168.3.10/24, ipv6: "fd5d:12c9:2201:1::1/64" } - - { name: eth2, ipv4: 192.168.4.10/24 } - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_linkagg/aliases b/test/integration/targets/vyos_linkagg/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_linkagg/defaults/main.yaml b/test/integration/targets/vyos_linkagg/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_linkagg/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_linkagg/tasks/cli.yaml b/test/integration/targets/vyos_linkagg/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_linkagg/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_linkagg/tasks/main.yaml b/test/integration/targets/vyos_linkagg/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_linkagg/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml b/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml new file mode 100644 index 00000000..5a022550 --- /dev/null +++ b/test/integration/targets/vyos_linkagg/tests/cli/basic.yaml @@ -0,0 +1,184 @@ +--- +- debug: msg="cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Remove linkagg + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + +- name: Remove linkagg + vyos.vyos.vyos_linkagg: + name: bond1 + state: absent + +- name: Create linkagg + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth1 + state: present + register: result + +- assert: + that: + - '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) + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth1 + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Add linkagg member + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth2 + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' + +- name: Add linkagg member again (idempotent) + vyos.vyos.vyos_linkagg: + name: bond0 + members: + - eth2 + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Disable linkagg + vyos.vyos.vyos_linkagg: + name: bond0 + state: down + register: result + +- assert: + that: + - 'result.changed == true' + - '"set interfaces bonding bond0 disable" in result.commands' + +- name: Disable linkagg again (idempotent) + vyos.vyos.vyos_linkagg: + name: bond0 + state: down + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Enable linkagg + vyos.vyos.vyos_linkagg: + name: bond0 + state: up + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete interfaces bonding bond0 disable" in result.commands[0]' + +- name: Enable linkagg again (idempotent) + vyos.vyos.vyos_linkagg: + name: bond0 + state: up + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove linkagg + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + register: result + +- assert: + that: + - '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) + vyos.vyos.vyos_linkagg: + name: bond0 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Create collection of linkagg definitions + vyos.vyos.vyos_linkagg: + aggregate: + - { name: bond0, members: [eth1] } + - { name: bond1, members: [eth2] } + state: present + register: result + +- assert: + that: + - '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) + vyos.vyos.vyos_linkagg: + aggregate: + - { name: bond0, members: [eth1] } + - { name: bond1, members: [eth2] } + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Remove collection of linkagg definitions + vyos.vyos.vyos_linkagg: + aggregate: + - name: bond0 + - name: bond1 + state: absent + register: result + +- assert: + that: + - '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) + vyos.vyos.vyos_linkagg: + aggregate: + - name: bond0 + - name: bond1 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' diff --git a/test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml b/test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml new file mode 100644 index 00000000..93f98e7a --- /dev/null +++ b/test/integration/targets/vyos_linkagg/tests/cli/net_linkagg.yaml @@ -0,0 +1,31 @@ +--- +- 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. + +- name: Remove linkagg - set + net_linkagg: + name: bond0 + state: absent + +- name: Create linkagg using platform agnostic module + net_linkagg: + name: bond0 + members: + - eth1 + state: present + register: result + +- assert: + that: + - '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: + name: bond0 + state: absent + +- debug: msg="END vyos cli/net_linkagg.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_linkagg/vyos_linkagg/aliases b/test/integration/targets/vyos_linkagg/vyos_linkagg/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_linkagg/vyos_linkagg/defaults/main.yaml b/test/integration/targets/vyos_linkagg/vyos_linkagg/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_linkagg/vyos_linkagg/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/cli.yaml b/test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_linkagg/vyos_linkagg/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/test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/main.yaml b/test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_linkagg/vyos_linkagg/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/basic.yaml b/test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/basic.yaml deleted file mode 100644 index 1a171a70..00000000 --- a/test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/basic.yaml +++ /dev/null @@ -1,184 +0,0 @@ ---- -- debug: msg="cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Remove linkagg - vyos_linkagg: - name: bond0 - state: absent - -- name: Remove linkagg - vyos_linkagg: - name: bond1 - state: absent - -- name: Create linkagg - vyos_linkagg: - name: bond0 - members: - - eth1 - state: present - register: result - -- assert: - that: - - '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) - vyos_linkagg: - name: bond0 - members: - - eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Add linkagg member - vyos_linkagg: - name: bond0 - members: - - eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces ethernet eth2 bond-group bond0" in result.commands' - -- name: Add linkagg member again (idempotent) - vyos_linkagg: - name: bond0 - members: - - eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Disable linkagg - vyos_linkagg: - name: bond0 - state: down - register: result - -- assert: - that: - - 'result.changed == true' - - '"set interfaces bonding bond0 disable" in result.commands' - -- name: Disable linkagg again (idempotent) - vyos_linkagg: - name: bond0 - state: down - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Enable linkagg - vyos_linkagg: - name: bond0 - state: up - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete interfaces bonding bond0 disable" in result.commands[0]' - -- name: Enable linkagg again (idempotent) - vyos_linkagg: - name: bond0 - state: up - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove linkagg - vyos_linkagg: - name: bond0 - state: absent - register: result - -- assert: - that: - - '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) - vyos_linkagg: - name: bond0 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Create collection of linkagg definitions - vyos_linkagg: - aggregate: - - { name: bond0, members: [eth1] } - - { name: bond1, members: [eth2] } - state: present - register: result - -- assert: - that: - - '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) - vyos_linkagg: - aggregate: - - { name: bond0, members: [eth1] } - - { name: bond1, members: [eth2] } - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Remove collection of linkagg definitions - vyos_linkagg: - aggregate: - - name: bond0 - - name: bond1 - state: absent - register: result - -- assert: - that: - - '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) - vyos_linkagg: - aggregate: - - name: bond0 - - name: bond1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/net_linkagg.yaml b/test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/net_linkagg.yaml deleted file mode 100644 index 93f98e7a..00000000 --- a/test/integration/targets/vyos_linkagg/vyos_linkagg/tests/cli/net_linkagg.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- 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. - -- name: Remove linkagg - set - net_linkagg: - name: bond0 - state: absent - -- name: Create linkagg using platform agnostic module - net_linkagg: - name: bond0 - members: - - eth1 - state: present - register: result - -- assert: - that: - - '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: - name: bond0 - state: absent - -- debug: msg="END vyos cli/net_linkagg.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_lldp/aliases b/test/integration/targets/vyos_lldp/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_lldp/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_lldp/defaults/main.yaml b/test/integration/targets/vyos_lldp/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_lldp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_lldp/tasks/cli.yaml b/test/integration/targets/vyos_lldp/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_lldp/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lldp/tasks/main.yaml b/test/integration/targets/vyos_lldp/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_lldp/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_lldp/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp/tests/cli/basic.yaml new file mode 100644 index 00000000..badd3a97 --- /dev/null +++ b/test/integration/targets/vyos_lldp/tests/cli/basic.yaml @@ -0,0 +1,44 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Make sure LLDP is not running before tests + vyos.vyos.vyos_config: + lines: delete service lldp + +- name: Enable LLDP service + vyos.vyos.vyos_lldp: + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set service lldp" in result.commands' + +- name: Enable LLDP service again (idempotent) + vyos.vyos.vyos_lldp: + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Disable LLDP service + vyos.vyos.vyos_lldp: + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete service lldp" in result.commands' + +- name: + vyos.vyos.vyos_lldp: + state: absent + register: result + +- assert: + that: + - 'result.changed == false' diff --git a/test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml b/test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml new file mode 100644 index 00000000..e68d5a62 --- /dev/null +++ b/test/integration/targets/vyos_lldp/tests/cli/net_lldp.yaml @@ -0,0 +1,25 @@ +--- +- 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 + +- assert: + that: + - 'result.changed == true' + - '"set service lldp" 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.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_lldp/vyos_lldp/aliases b/test/integration/targets/vyos_lldp/vyos_lldp/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_lldp/vyos_lldp/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_lldp/vyos_lldp/defaults/main.yaml b/test/integration/targets/vyos_lldp/vyos_lldp/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_lldp/vyos_lldp/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_lldp/vyos_lldp/tasks/cli.yaml b/test/integration/targets/vyos_lldp/vyos_lldp/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_lldp/vyos_lldp/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/test/integration/targets/vyos_lldp/vyos_lldp/tasks/main.yaml b/test/integration/targets/vyos_lldp/vyos_lldp/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_lldp/vyos_lldp/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/basic.yaml deleted file mode 100644 index bc7774f0..00000000 --- a/test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/basic.yaml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Make sure LLDP is not running before tests - vyos_config: - lines: delete service lldp - -- name: Enable LLDP service - vyos_lldp: - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp" in result.commands' - -- name: Enable LLDP service again (idempotent) - vyos_lldp: - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Disable LLDP service - vyos_lldp: - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp" in result.commands' - -- name: - vyos_lldp: - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/net_lldp.yaml b/test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/net_lldp.yaml deleted file mode 100644 index cf8f97cb..00000000 --- a/test/integration/targets/vyos_lldp/vyos_lldp/tests/cli/net_lldp.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -- 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_config: - lines: delete service lldp - -- name: Enable LLDP service using platform agnostic module - net_lldp: - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp" in result.commands' - -- name: Make sure LLDP is not running - teardown - vyos_config: - lines: delete service lldp - -- debug: msg="END vyos cli/net_lldp.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_lldp_interface/aliases b/test/integration/targets/vyos_lldp_interface/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_lldp_interface/defaults/main.yaml b/test/integration/targets/vyos_lldp_interface/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_lldp_interface/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml b/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_lldp_interface/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_lldp_interface/tasks/main.yaml b/test/integration/targets/vyos_lldp_interface/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_lldp_interface/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml new file mode 100644 index 00000000..e91091b4 --- /dev/null +++ b/test/integration/targets/vyos_lldp_interface/tests/cli/basic.yaml @@ -0,0 +1,167 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Make sure LLDP is not running before tests + vyos.vyos.vyos_config: + lines: delete service lldp + +- name: Create LLDP configuration + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set service lldp interface eth1" in result.commands' + +- name: Create LLDP configuration again (idempotent) + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Disable LLDP configuration + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: disabled + register: result + +- assert: + that: + - 'result.changed == true' + - '"set service lldp interface eth1 disable" in result.commands' + +- name: Disable LLDP configuration again (idempotent) + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: disabled + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Enable LLDP configuration + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: enabled + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete service lldp interface eth1 disable" in result.commands' + +- name: Enable LLDP configuration again (idempotent) + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: enabled + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Delete LLDP configuration + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete service lldp interface eth1" in result.commands' + +- name: Delete LLDP configuration again (idempotent) + vyos.vyos.vyos_lldp_interface: + name: eth1 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Create aggregate of LLDP interface configurations + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: present + register: result + +- assert: + that: + - '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) + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Override LLDP interface configuration on aggregate + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - { name: eth2, state: disabled } + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set service lldp interface eth2 disable" in result.commands' + +- name: Override LLDP interface configuration on aggregate again (idempotent) + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - { name: eth2, state: disabled } + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Delete aggregate of LLDP interface configurations + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + register: result + +- assert: + that: + - '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) + vyos.vyos.vyos_lldp_interface: + aggregate: + - name: eth1 + - name: eth2 + state: absent + register: result + +- assert: + that: + - 'result.changed == false' diff --git a/test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml b/test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml new file mode 100644 index 00000000..1710b7e2 --- /dev/null +++ b/test/integration/targets/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml @@ -0,0 +1,26 @@ +--- +- 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. + +- 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: + name: eth1 + state: present + register: result + +- assert: + that: + - '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 }}" diff --git a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/aliases b/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/defaults/main.yaml b/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/cli.yaml b/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/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/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/main.yaml b/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/basic.yaml b/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/basic.yaml deleted file mode 100644 index 362d1817..00000000 --- a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/basic.yaml +++ /dev/null @@ -1,167 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Make sure LLDP is not running before tests - vyos_config: - lines: delete service lldp - -- name: Create LLDP configuration - vyos_lldp_interface: - name: eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1" in result.commands' - -- name: Create LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Disable LLDP configuration - vyos_lldp_interface: - name: eth1 - state: disabled - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1 disable" in result.commands' - -- name: Disable LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: disabled - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Enable LLDP configuration - vyos_lldp_interface: - name: eth1 - state: enabled - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp interface eth1 disable" in result.commands' - -- name: Enable LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: enabled - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Delete LLDP configuration - vyos_lldp_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete service lldp interface eth1" in result.commands' - -- name: Delete LLDP configuration again (idempotent) - vyos_lldp_interface: - name: eth1 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Create aggregate of LLDP interface configurations - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: present - register: result - -- assert: - that: - - '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) - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Override LLDP interface configuration on aggregate - vyos_lldp_interface: - aggregate: - - name: eth1 - - { name: eth2, state: disabled } - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth2 disable" in result.commands' - -- name: Override LLDP interface configuration on aggregate again (idempotent) - vyos_lldp_interface: - aggregate: - - name: eth1 - - { name: eth2, state: disabled } - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Delete aggregate of LLDP interface configurations - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - '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) - vyos_lldp_interface: - aggregate: - - name: eth1 - - name: eth2 - state: absent - register: result - -- assert: - that: - - 'result.changed == false' diff --git a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml b/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml deleted file mode 100644 index 49cd8b00..00000000 --- a/test/integration/targets/vyos_lldp_interface/vyos_lldp_interface/tests/cli/net_lldp_interface.yaml +++ /dev/null @@ -1,26 +0,0 @@ ---- -- 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. - -- name: Make sure LLDP is not running - setup - vyos_config: - lines: delete service lldp - -- name: Create LLDP configuration using platform agnostic module - net_lldp_interface: - name: eth1 - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set service lldp interface eth1" in result.commands' - -- name: Make sure LLDP is not running - teardown - vyos_config: - lines: delete service lldp - -- debug: msg="END vyos cli/net_lldp_interface.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_logging/aliases b/test/integration/targets/vyos_logging/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_logging/defaults/main.yaml b/test/integration/targets/vyos_logging/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_logging/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_logging/tasks/cli.yaml b/test/integration/targets/vyos_logging/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_logging/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_logging/tasks/main.yaml b/test/integration/targets/vyos_logging/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_logging/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_logging/tests/cli/basic.yaml b/test/integration/targets/vyos_logging/tests/cli/basic.yaml new file mode 100644 index 00000000..144f8d38 --- /dev/null +++ b/test/integration/targets/vyos_logging/tests/cli/basic.yaml @@ -0,0 +1,126 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: set-up logging + vyos.vyos.vyos_logging: + dest: console + facility: all + level: info + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set system syslog console facility all level info" in result.commands' + +- name: set-up logging again (idempotent) + vyos.vyos.vyos_logging: + dest: console + facility: all + level: info + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: file logging + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set system syslog file test facility all level notice" in result.commands' + +- name: file logging again (idempotent) + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: present + register: result + +- assert: + that: + - 'result.changed == false' + +- name: delete logging + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: absent + register: result + +- assert: + that: + - 'result.changed == true' + - '"delete system syslog file test facility all level notice" in result.commands' + +- name: delete logging again (idempotent) + vyos.vyos.vyos_logging: + dest: file + name: test + facility: all + level: notice + state: absent + register: result + +- assert: + that: + - 'result.changed == false' + +- name: Add logging collections + vyos.vyos.vyos_logging: + aggregate: + - { 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' + - '"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 + 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 } + state: present + register: result + +- assert: + that: + - '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 + 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 } + state: absent + register: result + +- assert: + that: + - '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/test/integration/targets/vyos_logging/tests/cli/net_logging.yaml b/test/integration/targets/vyos_logging/tests/cli/net_logging.yaml new file mode 100644 index 00000000..7c62d72f --- /dev/null +++ b/test/integration/targets/vyos_logging/tests/cli/net_logging.yaml @@ -0,0 +1,39 @@ +--- +- 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. + +- name: delete logging - setup + net_logging: + dest: file + name: test + facility: all + level: notice + state: absent + register: result + +- name: file logging using platform agnostic module + net_logging: + dest: file + name: test + facility: all + level: notice + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set system syslog file test facility all level notice" in result.commands' + +- name: delete logging - teardown + 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 }}" diff --git a/test/integration/targets/vyos_logging/vyos_logging/aliases b/test/integration/targets/vyos_logging/vyos_logging/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_logging/vyos_logging/defaults/main.yaml b/test/integration/targets/vyos_logging/vyos_logging/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_logging/vyos_logging/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_logging/vyos_logging/tasks/cli.yaml b/test/integration/targets/vyos_logging/vyos_logging/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_logging/vyos_logging/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/test/integration/targets/vyos_logging/vyos_logging/tasks/main.yaml b/test/integration/targets/vyos_logging/vyos_logging/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_logging/vyos_logging/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_logging/vyos_logging/tests/cli/basic.yaml b/test/integration/targets/vyos_logging/vyos_logging/tests/cli/basic.yaml deleted file mode 100644 index 6b133342..00000000 --- a/test/integration/targets/vyos_logging/vyos_logging/tests/cli/basic.yaml +++ /dev/null @@ -1,126 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: set-up logging - vyos_logging: - dest: console - facility: all - level: info - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog console facility all level info" in result.commands' - -- name: set-up logging again (idempotent) - vyos_logging: - dest: console - facility: all - level: info - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: file logging - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog file test facility all level notice" in result.commands' - -- name: file logging again (idempotent) - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: present - register: result - -- assert: - that: - - 'result.changed == false' - -- name: delete logging - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- assert: - that: - - 'result.changed == true' - - '"delete system syslog file test facility all level notice" in result.commands' - -- name: delete logging again (idempotent) - vyos_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- assert: - that: - - 'result.changed == false' - -- name: Add logging collections - vyos_logging: - aggregate: - - { 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' - - '"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 - 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 } - state: present - register: result - -- assert: - that: - - '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 - vyos_logging: - aggregate: - - { 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' - - '"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/test/integration/targets/vyos_logging/vyos_logging/tests/cli/net_logging.yaml b/test/integration/targets/vyos_logging/vyos_logging/tests/cli/net_logging.yaml deleted file mode 100644 index 7c62d72f..00000000 --- a/test/integration/targets/vyos_logging/vyos_logging/tests/cli/net_logging.yaml +++ /dev/null @@ -1,39 +0,0 @@ ---- -- 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. - -- name: delete logging - setup - net_logging: - dest: file - name: test - facility: all - level: notice - state: absent - register: result - -- name: file logging using platform agnostic module - net_logging: - dest: file - name: test - facility: all - level: notice - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system syslog file test facility all level notice" in result.commands' - -- name: delete logging - teardown - 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 }}" diff --git a/test/integration/targets/vyos_smoke/defaults/main.yaml b/test/integration/targets/vyos_smoke/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_smoke/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_smoke/tasks/cli.yaml b/test/integration/targets/vyos_smoke/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_smoke/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_smoke/tasks/main.yaml b/test/integration/targets/vyos_smoke/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_smoke/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_smoke/tests/cli/common_config.yaml b/test/integration/targets/vyos_smoke/tests/cli/common_config.yaml new file mode 100644 index 00000000..1c07980d --- /dev/null +++ b/test/integration/targets/vyos_smoke/tests/cli/common_config.yaml @@ -0,0 +1,10 @@ +# 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/test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml b/test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml new file mode 100644 index 00000000..db837c50 --- /dev/null +++ b/test/integration/targets/vyos_smoke/tests/cli/common_utils.yaml @@ -0,0 +1,49 @@ +# 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: yes + 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/test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml b/test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml new file mode 100644 index 00000000..720f95ea --- /dev/null +++ b/test/integration/targets/vyos_smoke/tests/cli/misc_tests.yaml @@ -0,0 +1,13 @@ +# 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: yes + +- 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/test/integration/targets/vyos_smoke/vyos_smoke/defaults/main.yaml b/test/integration/targets/vyos_smoke/vyos_smoke/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_smoke/vyos_smoke/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_smoke/vyos_smoke/tasks/cli.yaml b/test/integration/targets/vyos_smoke/vyos_smoke/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_smoke/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/test/integration/targets/vyos_smoke/vyos_smoke/tasks/main.yaml b/test/integration/targets/vyos_smoke/vyos_smoke/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_smoke/vyos_smoke/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_config.yaml b/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_config.yaml deleted file mode 100644 index bad66f57..00000000 --- a/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# vyos.py in plugins and module_utils/network covered by these as well -# hit NetworkConfig -- name: configure simple config command - vyos_config: - lines: set system host-name smoke - -- name: return host name to inventory_hostname - vyos_config: - lines: set system host-name {{ inventory_hostname_short }} - match: none diff --git a/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_utils.yaml b/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_utils.yaml deleted file mode 100644 index 7dfbb41e..00000000 --- a/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/common_utils.yaml +++ /dev/null @@ -1,49 +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_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_interface: - name: eth1 - enabled: True - state: present - register: result - -- name: Check intent arguments - vyos_interface: - name: eth1 - state: up - register: result - -- name: Check intent arguments (failed condition) - vyos_interface: - name: eth1 - state: down - ignore_errors: yes - register: result - -- assert: - that: - - "result.failed == true" - - "'state eq(down)' in result.failed_conditions" - -- name: Config + intent - vyos_interface: - name: eth1 - enabled: False - state: down diff --git a/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/misc_tests.yaml b/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/misc_tests.yaml deleted file mode 100644 index a56d057c..00000000 --- a/test/integration/targets/vyos_smoke/vyos_smoke/tests/cli/misc_tests.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# hit check conditional in module_utils.network.vyos -> load_config() -- name: configure simple config command - vyos_config: - lines: set system host-name check-test - check_mode: yes - -- name: get host name - vyos_command: - commands: show host name - register: result - -- assert: - that: '"check-test" not in result.stdout' diff --git a/test/integration/targets/vyos_static_route/aliases b/test/integration/targets/vyos_static_route/aliases new file mode 100644 index 00000000..539d9574 --- /dev/null +++ b/test/integration/targets/vyos_static_route/aliases @@ -0,0 +1 @@ +shippable/network diff --git a/test/integration/targets/vyos_static_route/defaults/main.yaml b/test/integration/targets/vyos_static_route/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_static_route/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_static_route/tasks/cli.yaml b/test/integration/targets/vyos_static_route/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_static_route/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_static_route/tasks/main.yaml b/test/integration/targets/vyos_static_route/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_static_route/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_static_route/tests/cli/basic.yaml b/test/integration/targets/vyos_static_route/tests/cli/basic.yaml new file mode 100644 index 00000000..122e49a6 --- /dev/null +++ b/test/integration/targets/vyos_static_route/tests/cli/basic.yaml @@ -0,0 +1,120 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: create static route + 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' + - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands' + +- name: create static route again (idempotent) + 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' + +- name: modify admin distance of static route + 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' + +- name: modify admin distance of static route again (idempotent) + 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' + +- name: delete static route + 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' + - '"delete protocols static route 172.24.0.0/24" in result.commands' + +- name: delete static route again (idempotent) + 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' + +- name: Add static route collections + 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 } + state: present + register: result + +- assert: + that: + - '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 + 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 } + state: present + register: result + +- assert: + that: + - '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 + 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 } + state: absent + register: result + +- assert: + that: + - '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/test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml b/test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml new file mode 100644 index 00000000..e2529ebc --- /dev/null +++ b/test/integration/targets/vyos_static_route/tests/cli/net_static_route.yaml @@ -0,0 +1,33 @@ +--- +- 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. + +- name: delete static route - setup + 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: + prefix: 172.24.0.0/24 + next_hop: 192.168.42.64 + state: present + register: result + +- assert: + that: + - '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: + 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 }}" diff --git a/test/integration/targets/vyos_static_route/vyos_static_route/aliases b/test/integration/targets/vyos_static_route/vyos_static_route/aliases deleted file mode 100644 index 539d9574..00000000 --- a/test/integration/targets/vyos_static_route/vyos_static_route/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/network diff --git a/test/integration/targets/vyos_static_route/vyos_static_route/defaults/main.yaml b/test/integration/targets/vyos_static_route/vyos_static_route/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_static_route/vyos_static_route/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_static_route/vyos_static_route/tasks/cli.yaml b/test/integration/targets/vyos_static_route/vyos_static_route/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_static_route/vyos_static_route/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/test/integration/targets/vyos_static_route/vyos_static_route/tasks/main.yaml b/test/integration/targets/vyos_static_route/vyos_static_route/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_static_route/vyos_static_route/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/basic.yaml b/test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/basic.yaml deleted file mode 100644 index f8fa87d9..00000000 --- a/test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/basic.yaml +++ /dev/null @@ -1,120 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: create static route - vyos_static_route: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - state: present - register: result - -- assert: - that: - - '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) - 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' - -- name: modify admin distance of static route - 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' - -- name: modify admin distance of static route again (idempotent) - 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' - -- name: delete static route - 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' - - '"delete protocols static route 172.24.0.0/24" in result.commands' - -- name: delete static route again (idempotent) - 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' - -- name: Add static route collections - 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 } - state: present - register: result - -- assert: - that: - - '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 - 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 } - state: present - register: result - -- assert: - that: - - '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 - 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 } - state: absent - register: result - -- assert: - that: - - '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/test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/net_static_route.yaml b/test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/net_static_route.yaml deleted file mode 100644 index e2529ebc..00000000 --- a/test/integration/targets/vyos_static_route/vyos_static_route/tests/cli/net_static_route.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- 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. - -- name: delete static route - setup - 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: - prefix: 172.24.0.0/24 - next_hop: 192.168.42.64 - state: present - register: result - -- assert: - that: - - '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: - 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 }}" diff --git a/test/integration/targets/vyos_system/defaults/main.yaml b/test/integration/targets/vyos_system/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_system/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_system/tasks/cli.yaml b/test/integration/targets/vyos_system/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_system/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_system/tasks/main.yaml b/test/integration/targets/vyos_system/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_system/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_system/tests/cli/basic.yaml b/test/integration/targets/vyos_system/tests/cli/basic.yaml new file mode 100644 index 00000000..474042fc --- /dev/null +++ b/test/integration/targets/vyos_system/tests/cli/basic.yaml @@ -0,0 +1,61 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup + vyos.vyos.vyos_config: + lines: + - delete system name-server 192.0.2.1 + - delete system name-server 192.0.2.2 + - delete system name-server 192.0.2.3 + match: none + +- name: configure name servers + vyos.vyos.vyos_system: + name_servers: + - 192.0.2.1 + - 192.0.2.2 + - 192.0.2.3 + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - result.commands[0] is search("set system name-server '192.0.2.1'") + - result.commands[1] is search("set system name-server '192.0.2.2'") + - result.commands[2] is search("set system name-server '192.0.2.3'") + +- name: verify name_servers + 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 + vyos.vyos.vyos_system: + name_servers: + - 192.0.2.3 + state: absent + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - result.commands[0] is search("delete system name-server '192.0.2.3'") + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete system name-server name-server 192.0.2.1 + - delete system name-server name-server 192.0.2.2 + - delete system name-server name-server 192.0.2.3 + match: none + +- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_system/tests/cli/net_system.yaml b/test/integration/targets/vyos_system/tests/cli/net_system.yaml new file mode 100644 index 00000000..36888669 --- /dev/null +++ b/test/integration/targets/vyos_system/tests/cli/net_system.yaml @@ -0,0 +1,30 @@ +--- +- 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. + +- name: setup + vyos.vyos.vyos_config: + lines: + - delete system name-server 192.0.2.1 + match: none + +- name: configure name servers using platform agnostic module + net_system: + name_servers: + - 192.0.2.1 + register: result + +- assert: + that: + - result.changed == true + - result.commands[0] is search("set system name-server '192.0.2.1'") + +- name: setup + vyos.vyos.vyos_config: + lines: + - delete system name-server 192.0.2.1 + match: none + +- debug: msg="END vyos cli/net_system.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_system/vyos_system/defaults/main.yaml b/test/integration/targets/vyos_system/vyos_system/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_system/vyos_system/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_system/vyos_system/tasks/cli.yaml b/test/integration/targets/vyos_system/vyos_system/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_system/vyos_system/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/test/integration/targets/vyos_system/vyos_system/tasks/main.yaml b/test/integration/targets/vyos_system/vyos_system/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_system/vyos_system/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_system/vyos_system/tests/cli/basic.yaml b/test/integration/targets/vyos_system/vyos_system/tests/cli/basic.yaml deleted file mode 100644 index c42eddea..00000000 --- a/test/integration/targets/vyos_system/vyos_system/tests/cli/basic.yaml +++ /dev/null @@ -1,61 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: setup - vyos_config: - lines: - - delete system name-server 192.0.2.1 - - delete system name-server 192.0.2.2 - - delete system name-server 192.0.2.3 - match: none - -- name: configure name servers - vyos_system: - name_servers: - - 192.0.2.1 - - 192.0.2.2 - - 192.0.2.3 - register: result - -- assert: - that: - - result.changed == true - - result.commands|length == 3 - - result.commands[0] is search("set system name-server '192.0.2.1'") - - result.commands[1] is search("set system name-server '192.0.2.2'") - - result.commands[2] is search("set system name-server '192.0.2.3'") - -- name: verify name_servers - 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 - vyos_system: - name_servers: - - 192.0.2.3 - state: absent - register: result - -- assert: - that: - - result.changed == true - - result.commands|length == 1 - - result.commands[0] is search("delete system name-server '192.0.2.3'") - -- name: teardown - vyos_config: - lines: - - delete system name-server name-server 192.0.2.1 - - delete system name-server name-server 192.0.2.2 - - delete system name-server name-server 192.0.2.3 - match: none - -- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_system/vyos_system/tests/cli/net_system.yaml b/test/integration/targets/vyos_system/vyos_system/tests/cli/net_system.yaml deleted file mode 100644 index b7813c09..00000000 --- a/test/integration/targets/vyos_system/vyos_system/tests/cli/net_system.yaml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- 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. - -- name: setup - vyos_config: - lines: - - delete system name-server 192.0.2.1 - match: none - -- name: configure name servers using platform agnostic module - net_system: - name_servers: - - 192.0.2.1 - register: result - -- assert: - that: - - result.changed == true - - result.commands[0] is search("set system name-server '192.0.2.1'") - -- name: setup - vyos_config: - lines: - - delete system name-server 192.0.2.1 - match: none - -- debug: msg="END vyos cli/net_system.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_user/aliases b/test/integration/targets/vyos_user/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_user/defaults/main.yaml b/test/integration/targets/vyos_user/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_user/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_user/tasks/cli.yaml b/test/integration/targets/vyos_user/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_user/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_user/tasks/main.yaml b/test/integration/targets/vyos_user/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_user/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_user/tests/cli/auth.yaml b/test/integration/targets/vyos_user/tests/cli/auth.yaml new file mode 100644 index 00000000..566191ee --- /dev/null +++ b/test/integration/targets/vyos_user/tests/cli/auth.yaml @@ -0,0 +1,34 @@ +--- +- 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: 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: yes + register: results + + - name: check that attempt failed + assert: + that: + - results.failed + + always: + - name: delete user + vyos.vyos.vyos_user: + name: auth_user + state: absent + register: result diff --git a/test/integration/targets/vyos_user/tests/cli/basic.yaml b/test/integration/targets/vyos_user/tests/cli/basic.yaml new file mode 100644 index 00000000..a71f9c6f --- /dev/null +++ b/test/integration/targets/vyos_user/tests/cli/basic.yaml @@ -0,0 +1,77 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: Setup + vyos.vyos.vyos_config: + lines: + - delete system login user ansibletest1 + - delete system login user ansibletest2 + - delete system login user ansibletest3 + +- name: Create user + vyos.vyos.vyos_user: + name: ansibletest1 + configured_password: test + state: present + register: result + +- assert: + that: + - 'result.changed == true' + - '"set system login user" in result.commands[0]' + - '"authentication plaintext-password" in result.commands[0]' + +- name: Collection of users (SetUp) + 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"]' + +- name: Add user again (Idempotent) + 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' + +- name: Add collection of users (Idempotent) + vyos.vyos.vyos_user: + aggregate: + - name: ansibletest2 + - name: ansibletest3 + level: operator + state: present + register: result + +- assert: + that: + - 'result.changed == false' + - 'result.commands | length == 0' + +- name: tearDown + 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"]' diff --git a/test/integration/targets/vyos_user/vyos_user/aliases b/test/integration/targets/vyos_user/vyos_user/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_user/vyos_user/defaults/main.yaml b/test/integration/targets/vyos_user/vyos_user/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_user/vyos_user/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_user/vyos_user/tasks/cli.yaml b/test/integration/targets/vyos_user/vyos_user/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_user/vyos_user/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/test/integration/targets/vyos_user/vyos_user/tasks/main.yaml b/test/integration/targets/vyos_user/vyos_user/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_user/vyos_user/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_user/vyos_user/tests/cli/auth.yaml b/test/integration/targets/vyos_user/vyos_user/tests/cli/auth.yaml deleted file mode 100644 index ff14bd75..00000000 --- a/test/integration/targets/vyos_user/vyos_user/tests/cli/auth.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- block: - - name: Create user with password - 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: 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: yes - register: results - - - name: check that attempt failed - assert: - that: - - results.failed - - always: - - name: delete user - vyos_user: - name: auth_user - state: absent - register: result diff --git a/test/integration/targets/vyos_user/vyos_user/tests/cli/basic.yaml b/test/integration/targets/vyos_user/vyos_user/tests/cli/basic.yaml deleted file mode 100644 index 346ecda3..00000000 --- a/test/integration/targets/vyos_user/vyos_user/tests/cli/basic.yaml +++ /dev/null @@ -1,77 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: Setup - vyos_config: - lines: - - delete system login user ansibletest1 - - delete system login user ansibletest2 - - delete system login user ansibletest3 - -- name: Create user - vyos_user: - name: ansibletest1 - configured_password: test - state: present - register: result - -- assert: - that: - - 'result.changed == true' - - '"set system login user" in result.commands[0]' - - '"authentication plaintext-password" in result.commands[0]' - -- name: Collection of users (SetUp) - 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"]' - -- name: Add user again (Idempotent) - vyos_user: - name: ansibletest1 - configured_password: test - state: present - update_password: on_create - register: result - -- assert: - that: - - 'result.changed == false' - - 'result.commands | length == 0' - -- name: Add collection of users (Idempotent) - vyos_user: - aggregate: - - name: ansibletest2 - - name: ansibletest3 - level: operator - state: present - register: result - -- assert: - that: - - 'result.changed == false' - - 'result.commands | length == 0' - -- name: tearDown - 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"]' diff --git a/test/integration/targets/vyos_vlan/aliases b/test/integration/targets/vyos_vlan/aliases new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/targets/vyos_vlan/defaults/main.yaml b/test/integration/targets/vyos_vlan/defaults/main.yaml new file mode 100644 index 00000000..9ef5ba51 --- /dev/null +++ b/test/integration/targets/vyos_vlan/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/test/integration/targets/vyos_vlan/tasks/cli.yaml b/test/integration/targets/vyos_vlan/tasks/cli.yaml new file mode 100644 index 00000000..890d3acf --- /dev/null +++ b/test/integration/targets/vyos_vlan/tasks/cli.yaml @@ -0,0 +1,22 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case (connection=network_cli) + include: "{{ test_case_to_run }} ansible_connection=network_cli" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: run test case (connection=local) + include: "{{ test_case_to_run }} ansible_connection=local" + with_first_found: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/vyos_vlan/tasks/main.yaml b/test/integration/targets/vyos_vlan/tasks/main.yaml new file mode 100644 index 00000000..415c99d8 --- /dev/null +++ b/test/integration/targets/vyos_vlan/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_vlan/tests/cli/basic.yaml b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml new file mode 100644 index 00000000..6e4417ed --- /dev/null +++ b/test/integration/targets/vyos_vlan/tests/cli/basic.yaml @@ -0,0 +1,101 @@ +--- +- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth0 vif 101 + - delete interfaces ethernet eth1 vif 201 + +- name: set vlan with name + vyos.vyos.vyos_vlan: &name + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + register: result + +- assert: + that: + - "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 + +- assert: + that: + - "result.changed == false" + +- name: set vlan with address + vyos.vyos.vyos_vlan: &address + vlan_id: 5 + address: 192.168.5.12/24 + interfaces: eth0 + register: result + +- assert: + that: + - "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 + +- assert: + that: + - "result.changed == false" + +- name: delete + vyos.vyos.vyos_vlan: &delete + vlan_id: 100 + interfaces: eth1 + state: absent + register: result + +- assert: + that: + - "result.changed == true" + - "'delete interfaces ethernet eth1 vif 100' in result.commands" + +- name: delete(idempotence) + vyos.vyos.vyos_vlan: *delete + register: result + +- assert: + that: + - "result.changed == false" + +- name: Create VLANs using aggregate + vyos.vyos.vyos_vlan: &agg_vlan + aggregate: + - { vlan_id: 101, name: voice, interfaces: "eth0" } + - { vlan_id: 201, name: mgm, interfaces: "eth1" } + state: present + register: result + +- assert: + that: + - "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 + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 101 + - delete interfaces ethernet eth1 vif 201 diff --git a/test/integration/targets/vyos_vlan/tests/cli/intent.yaml b/test/integration/targets/vyos_vlan/tests/cli/intent.yaml new file mode 100644 index 00000000..7c789376 --- /dev/null +++ b/test/integration/targets/vyos_vlan/tests/cli/intent.yaml @@ -0,0 +1,59 @@ +--- +- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: &delete + lines: + - delete interfaces ethernet eth1 vif 100 + - delete interfaces ethernet eth0 vif 100 + +- name: set vlan with name + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + interfaces: eth1 + register: result + +- assert: + that: + - "result.changed == true" + - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" + +- name: check vlan interface intent + vyos.vyos.vyos_vlan: + vlan_id: 100 + name: vlan-100 + associated_interfaces: eth1 + register: result + +- assert: + that: + - "result.failed == false" + +- name: vlan interface config + intent + vyos.vyos.vyos_vlan: + vlan_id: 100 + interfaces: eth0 + associated_interfaces: + - eth0 + - eth1 + register: result + +- assert: + that: + - "result.failed == false" + +- name: vlan intent fail + vyos.vyos.vyos_vlan: + vlan_id: 100 + associated_interfaces: + - eth3 + - eth4 + register: result + ignore_errors: yes + +- assert: + that: + - "result.failed == True" + +- debug: msg="End cli/intent.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml b/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml new file mode 100644 index 00000000..53e93fde --- /dev/null +++ b/test/integration/targets/vyos_vlan/tests/cli/multiple.yaml @@ -0,0 +1,60 @@ +--- +- debug: msg="START cli/multiple.yaml on connection={{ ansible_connection }}" + +- name: setup - remove vlan used in test + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 vif 5 + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth1 vif 100 + +- name: Add multiple interfaces to vlan + vyos.vyos.vyos_vlan: &multiple + vlan_id: 100 + interfaces: + - eth0 + - eth1 + register: result + +- assert: + that: + - "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 + +- assert: + that: + - "result.changed == false" + +- name: delete vlan with multiple interfaces + vyos.vyos.vyos_vlan: &delete_multiple + vlan_id: 100 + interfaces: + - eth0 + - eth1 + state: absent + register: result + +- assert: + that: + - "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 + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos.vyos.vyos_config: + lines: + - delete interfaces ethernet eth0 vif 100 + - delete interfaces ethernet eth1 vif 100 diff --git a/test/integration/targets/vyos_vlan/vyos_vlan/aliases b/test/integration/targets/vyos_vlan/vyos_vlan/aliases deleted file mode 100644 index e69de29b..00000000 diff --git a/test/integration/targets/vyos_vlan/vyos_vlan/defaults/main.yaml b/test/integration/targets/vyos_vlan/vyos_vlan/defaults/main.yaml deleted file mode 100644 index 9ef5ba51..00000000 --- a/test/integration/targets/vyos_vlan/vyos_vlan/defaults/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -testcase: "*" -test_items: [] diff --git a/test/integration/targets/vyos_vlan/vyos_vlan/tasks/cli.yaml b/test/integration/targets/vyos_vlan/vyos_vlan/tasks/cli.yaml deleted file mode 100644 index 890d3acf..00000000 --- a/test/integration/targets/vyos_vlan/vyos_vlan/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/test/integration/targets/vyos_vlan/vyos_vlan/tasks/main.yaml b/test/integration/targets/vyos_vlan/vyos_vlan/tasks/main.yaml deleted file mode 100644 index 415c99d8..00000000 --- a/test/integration/targets/vyos_vlan/vyos_vlan/tasks/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/basic.yaml b/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/basic.yaml deleted file mode 100644 index a47f6b9c..00000000 --- a/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/basic.yaml +++ /dev/null @@ -1,101 +0,0 @@ ---- -- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}" - -- name: setup - remove vlan used in test - vyos_config: - lines: - - delete interfaces ethernet eth1 vif 100 - - delete interfaces ethernet eth0 vif 5 - - delete interfaces ethernet eth0 vif 100 - - delete interfaces ethernet eth0 vif 101 - - delete interfaces ethernet eth1 vif 201 - -- name: set vlan with name - vyos_vlan: &name - vlan_id: 100 - name: vlan-100 - interfaces: eth1 - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" - -- name: set vlan with name(idempotence) - vyos_vlan: *name - register: result - -- assert: - that: - - "result.changed == false" - -- name: set vlan with address - vyos_vlan: &address - vlan_id: 5 - address: 192.168.5.12/24 - interfaces: eth0 - register: result - -- assert: - that: - - "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_vlan: *address - register: result - -- assert: - that: - - "result.changed == false" - -- name: delete - vyos_vlan: &delete - vlan_id: 100 - interfaces: eth1 - state: absent - register: result - -- assert: - that: - - "result.changed == true" - - "'delete interfaces ethernet eth1 vif 100' in result.commands" - -- name: delete(idempotence) - vyos_vlan: *delete - register: result - -- assert: - that: - - "result.changed == false" - -- name: Create VLANs using aggregate - vyos_vlan: &agg_vlan - aggregate: - - { vlan_id: 101, name: voice, interfaces: "eth0" } - - { vlan_id: 201, name: mgm, interfaces: "eth1" } - state: present - register: result - -- assert: - that: - - "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_vlan: *agg_vlan - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: - - delete interfaces ethernet eth1 vif 100 - - delete interfaces ethernet eth0 vif 5 - - delete interfaces ethernet eth0 vif 101 - - delete interfaces ethernet eth1 vif 201 diff --git a/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/intent.yaml b/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/intent.yaml deleted file mode 100644 index 98c8697d..00000000 --- a/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/intent.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- -- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" - -- name: setup - remove vlan used in test - vyos_config: &delete - lines: - - delete interfaces ethernet eth1 vif 100 - - delete interfaces ethernet eth0 vif 100 - -- name: set vlan with name - vyos_vlan: - vlan_id: 100 - name: vlan-100 - interfaces: eth1 - register: result - -- assert: - that: - - "result.changed == true" - - "'set interfaces ethernet eth1 vif 100 description vlan-100' in result.commands" - -- name: check vlan interface intent - vyos_vlan: - vlan_id: 100 - name: vlan-100 - associated_interfaces: eth1 - register: result - -- assert: - that: - - "result.failed == false" - -- name: vlan interface config + intent - vyos_vlan: - vlan_id: 100 - interfaces: eth0 - associated_interfaces: - - eth0 - - eth1 - register: result - -- assert: - that: - - "result.failed == false" - -- name: vlan intent fail - vyos_vlan: - vlan_id: 100 - associated_interfaces: - - eth3 - - eth4 - register: result - ignore_errors: yes - -- assert: - that: - - "result.failed == True" - -- debug: msg="End cli/intent.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/multiple.yaml b/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/multiple.yaml deleted file mode 100644 index 25bc1af0..00000000 --- a/test/integration/targets/vyos_vlan/vyos_vlan/tests/cli/multiple.yaml +++ /dev/null @@ -1,60 +0,0 @@ ---- -- debug: msg="START cli/multiple.yaml on connection={{ ansible_connection }}" - -- name: setup - remove vlan used in test - vyos_config: - lines: - - delete interfaces ethernet eth0 vif 5 - - delete interfaces ethernet eth0 vif 100 - - delete interfaces ethernet eth1 vif 100 - -- name: Add multiple interfaces to vlan - vyos_vlan: &multiple - vlan_id: 100 - interfaces: - - eth0 - - eth1 - register: result - -- assert: - that: - - "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_vlan: *multiple - register: result - -- assert: - that: - - "result.changed == false" - -- name: delete vlan with multiple interfaces - vyos_vlan: &delete_multiple - vlan_id: 100 - interfaces: - - eth0 - - eth1 - state: absent - register: result - -- assert: - that: - - "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_vlan: *delete_multiple - register: result - -- assert: - that: - - "result.changed == false" - -- name: teardown - vyos_config: - lines: - - delete interfaces ethernet eth0 vif 100 - - delete interfaces ethernet eth1 vif 100 -- cgit v1.2.3