From 975f66f2eebe9dadba04f275774d4ab83f74cf25 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:04:41 +0200 Subject: Adding upstream version 7.7.0+dfsg. Signed-off-by: Daniel Baumann --- .../tests/integration/target-prefixes.network | 1 + .../junos_acl_interfaces/defaults/main.yaml | 3 + .../targets/junos_acl_interfaces/meta/main.yaml | 3 + .../targets/junos_acl_interfaces/tasks/main.yaml | 5 + .../junos_acl_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 20 + .../tests/netconf/_reset_config.yaml | 18 + .../tests/netconf/deleted.yaml | 64 ++++ .../tests/netconf/empty_config.yaml | 55 +++ .../junos_acl_interfaces/tests/netconf/merged.yaml | 58 +++ .../tests/netconf/overridden.yaml | 51 +++ .../tests/netconf/replaced.yaml | 51 +++ .../targets/junos_acls/defaults/main.yaml | 3 + .../integration/targets/junos_acls/meta/main.yaml | 3 + .../integration/targets/junos_acls/tasks/main.yaml | 4 + .../targets/junos_acls/tasks/netconf.yaml | 20 + .../junos_acls/tests/netconf/_reset_config.yaml | 19 + .../junos_acls/tests/netconf/config_policy.yaml | 14 + .../targets/junos_acls/tests/netconf/deleted.yaml | 166 +++++++++ .../junos_acls/tests/netconf/empty_config.yaml | 66 ++++ .../junos_acls/tests/netconf/fixtures/parsed.cfg | 45 +++ .../junos_acls/tests/netconf/idempotent.yaml | 79 ++++ .../targets/junos_acls/tests/netconf/merged.yaml | 106 ++++++ .../junos_acls/tests/netconf/overridden.yaml | 49 +++ .../targets/junos_acls/tests/netconf/parsed.yaml | 44 +++ .../targets/junos_acls/tests/netconf/rendered.yaml | 35 ++ .../targets/junos_acls/tests/netconf/replaced.yaml | 105 ++++++ .../tests/netconf/reset_policy_config.yaml | 16 + .../targets/junos_banner/defaults/main.yaml | 3 + .../integration/targets/junos_banner/meta/main.yml | 3 + .../targets/junos_banner/tasks/main.yaml | 3 + .../targets/junos_banner/tasks/netconf.yaml | 21 ++ .../targets/junos_banner/tests/netconf/basic.yaml | 205 +++++++++++ .../junos_bgp_address_family/defaults/main.yaml | 3 + .../targets/junos_bgp_address_family/meta/main.yml | 3 + .../junos_bgp_address_family/tasks/main.yaml | 5 + .../junos_bgp_address_family/tasks/netconf.yaml | 20 + .../tests/netconf/_reset_config.yaml | 13 + .../tests/netconf/deleted.yaml | 136 +++++++ .../tests/netconf/empty_config.yaml | 70 ++++ .../tests/netconf/fixtures/parsed.cfg | 120 ++++++ .../tests/netconf/gathered.yaml | 149 ++++++++ .../tests/netconf/merged.yaml | 155 ++++++++ .../tests/netconf/overridden.yaml | 131 +++++++ .../tests/netconf/parsed.yaml | 84 +++++ .../tests/netconf/rendered.yaml | 83 +++++ .../tests/netconf/replaced.yaml | 177 +++++++++ .../targets/junos_bgp_global/defaults/main.yaml | 3 + .../targets/junos_bgp_global/meta/main.yml | 3 + .../targets/junos_bgp_global/tasks/main.yaml | 5 + .../targets/junos_bgp_global/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 35 ++ .../tests/netconf/_reset_config.yaml | 37 ++ .../junos_bgp_global/tests/netconf/deleted.yaml | 34 ++ .../tests/netconf/empty_config.yaml | 54 +++ .../tests/netconf/fixtures/parsed.cfg | 47 +++ .../junos_bgp_global/tests/netconf/gathered.yaml | 30 ++ .../junos_bgp_global/tests/netconf/merged.yaml | 129 +++++++ .../junos_bgp_global/tests/netconf/parsed.yaml | 52 +++ .../junos_bgp_global/tests/netconf/purged.yaml | 34 ++ .../junos_bgp_global/tests/netconf/rendered.yaml | 41 +++ .../junos_bgp_global/tests/netconf/replaced.yaml | 51 +++ .../targets/junos_bgp_global/tests/netconf/rtt.yml | 92 +++++ .../targets/junos_bgp_global/vars/main.yaml | 110 ++++++ .../targets/junos_command/defaults/main.yaml | 3 + .../targets/junos_command/meta/main.yml | 3 + .../targets/junos_command/tasks/cli.yaml | 19 + .../targets/junos_command/tasks/main.yaml | 14 + .../targets/junos_command/tasks/netconf_json.yaml | 21 ++ .../targets/junos_command/tasks/netconf_text.yaml | 21 ++ .../targets/junos_command/tasks/netconf_xml.yaml | 21 ++ .../junos_command/tests/cli/cli_commmand.yaml | 69 ++++ .../tests/netconf_json/bad_operator.yaml | 27 ++ .../junos_command/tests/netconf_json/contains.yaml | 28 ++ .../junos_command/tests/netconf_json/equal.yaml | 44 +++ .../tests/netconf_json/greaterthan.yaml | 46 +++ .../tests/netconf_json/greaterthanorequal.yaml | 46 +++ .../junos_command/tests/netconf_json/lessthan.yaml | 46 +++ .../tests/netconf_json/lessthanorequal.yaml | 46 +++ .../junos_command/tests/netconf_json/notequal.yaml | 46 +++ .../junos_command/tests/netconf_json/output.yaml | 67 ++++ .../tests/netconf_text/bad_operator.yaml | 28 ++ .../junos_command/tests/netconf_text/contains.yaml | 27 ++ .../junos_command/tests/netconf_text/invalid.yaml | 41 +++ .../tests/netconf_text/no_config.yaml | 26 ++ .../junos_command/tests/netconf_text/output.yaml | 78 ++++ .../junos_command/tests/netconf_text/timeout.yaml | 26 ++ .../tests/netconf_xml/bad_operator.yaml | 28 ++ .../junos_command/tests/netconf_xml/contains.yaml | 28 ++ .../junos_command/tests/netconf_xml/equal.yaml | 40 ++ .../tests/netconf_xml/greaterthan.yaml | 46 +++ .../tests/netconf_xml/greaterthanorequal.yaml | 46 +++ .../junos_command/tests/netconf_xml/invalid.yaml | 38 ++ .../junos_command/tests/netconf_xml/lessthan.yaml | 46 +++ .../tests/netconf_xml/lessthanorequal.yaml | 46 +++ .../junos_command/tests/netconf_xml/notequal.yaml | 44 +++ .../junos_command/tests/netconf_xml/output.yaml | 66 ++++ .../junos_command/tests/netconf_xml/timeout.yaml | 23 ++ .../targets/junos_config/defaults/main.yaml | 2 + .../integration/targets/junos_config/meta/main.yml | 3 + .../targets/junos_config/tasks/cli_config.yaml | 19 + .../targets/junos_config/tasks/main.yaml | 12 + .../targets/junos_config/tasks/netconf.yaml | 21 ++ .../targets/junos_config/tasks/redirection.yaml | 18 + .../targets/junos_config/templates/basic/config.j2 | 9 + .../junos_config/templates/basic/config.set | 1 + .../junos_config/templates/basic/config.xml | 15 + .../junos_config/tests/cli_config/cli_backup.yaml | 110 ++++++ .../junos_config/tests/cli_config/cli_basic.yaml | 65 ++++ .../junos_config/tests/cli_config/cli_replace.yaml | 65 ++++ .../targets/junos_config/tests/netconf/backup.yaml | 32 ++ .../junos_config/tests/netconf/bad_action.yaml | 17 + .../junos_config/tests/netconf/invalid.yaml | 27 ++ .../junos_config/tests/netconf/multiple.yaml | 43 +++ .../targets/junos_config/tests/netconf/single.yaml | 72 ++++ .../junos_config/tests/netconf/src_basic.yaml | 96 +++++ .../junos_config/tests/netconf/src_invalid.yaml | 18 + .../junos_config/tests/redirection/shortname.yaml | 47 +++ .../targets/junos_facts/defaults/main.yaml | 3 + .../integration/targets/junos_facts/meta/main.yml | 3 + .../targets/junos_facts/tasks/main.yaml | 3 + .../targets/junos_facts/tasks/netconf.yaml | 21 ++ .../targets/junos_facts/tests/netconf/facts.yaml | 126 +++++++ .../targets/junos_hostname/defaults/main.yaml | 3 + .../targets/junos_hostname/meta/main.yml | 3 + .../targets/junos_hostname/tasks/main.yaml | 5 + .../targets/junos_hostname/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 13 + .../tests/netconf/_reset_config.yaml | 13 + .../junos_hostname/tests/netconf/deleted.yaml | 33 ++ .../junos_hostname/tests/netconf/empty_config.yaml | 66 ++++ .../tests/netconf/fixtures/parsed.cfg | 156 ++++++++ .../junos_hostname/tests/netconf/gathered.yaml | 29 ++ .../junos_hostname/tests/netconf/merged.yaml | 59 +++ .../junos_hostname/tests/netconf/overridden.yaml | 46 +++ .../junos_hostname/tests/netconf/parsed.yaml | 23 ++ .../junos_hostname/tests/netconf/rendered.yaml | 26 ++ .../junos_hostname/tests/netconf/replaced.yaml | 45 +++ .../targets/junos_hostname/tests/netconf/rtt.yml | 60 +++ .../targets/junos_hostname/vars/main.yaml | 12 + .../targets/junos_interfaces/defaults/main.yaml | 3 + .../targets/junos_interfaces/meta/main.yaml | 3 + .../targets/junos_interfaces/tasks/main.yaml | 5 + .../targets/junos_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 15 + .../tests/netconf/_remove_config.yaml | 21 ++ .../junos_interfaces/tests/netconf/deleted.yaml | 105 ++++++ .../tests/netconf/fixtures/parsed.cfg | 53 +++ .../junos_interfaces/tests/netconf/gathered.yaml | 77 ++++ .../junos_interfaces/tests/netconf/groups.yaml | 59 +++ .../junos_interfaces/tests/netconf/merged.yaml | 94 +++++ .../junos_interfaces/tests/netconf/overridden.yaml | 72 ++++ .../junos_interfaces/tests/netconf/parsed.yaml | 42 +++ .../junos_interfaces/tests/netconf/rendered.yaml | 29 ++ .../junos_interfaces/tests/netconf/replaced.yaml | 86 +++++ .../junos_interfaces/tests/netconf/rtt.yaml | 105 ++++++ .../targets/junos_l2_interfaces/defaults/main.yaml | 3 + .../targets/junos_l2_interfaces/meta/main.yaml | 3 + .../targets/junos_l2_interfaces/tasks/main.yaml | 5 + .../targets/junos_l2_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_base_config.yaml | 18 + .../tests/netconf/_remove_config.yaml | 22 ++ .../junos_l2_interfaces/tests/netconf/deleted.yaml | 90 +++++ .../tests/netconf/fixtures/parsed.cfg | 53 +++ .../tests/netconf/gathered.yaml | 61 +++ .../junos_l2_interfaces/tests/netconf/merged.yaml | 67 ++++ .../tests/netconf/overridden.yaml | 71 ++++ .../junos_l2_interfaces/tests/netconf/parsed.yaml | 38 ++ .../tests/netconf/rendered.yaml | 63 ++++ .../tests/netconf/replaced.yaml | 67 ++++ .../junos_l2_interfaces/tests/netconf/rtt.yml | 76 ++++ .../targets/junos_l3_interfaces/defaults/main.yaml | 3 + .../targets/junos_l3_interfaces/meta/main.yaml | 3 + .../targets/junos_l3_interfaces/tasks/main.yaml | 5 + .../targets/junos_l3_interfaces/tasks/netconf.yaml | 19 + .../tests/netconf/fixtures/parsed.cfg | 55 +++ .../tests/netconf/junos_l3_interfaces.yml | 131 +++++++ .../junos_l3_interfaces/tests/netconf/parsed.yaml | 44 +++ .../tests/netconf/rendered.yaml | 65 ++++ .../targets/junos_lacp/defaults/main.yaml | 3 + .../integration/targets/junos_lacp/meta/main.yml | 3 + .../integration/targets/junos_lacp/tasks/main.yaml | 5 + .../targets/junos_lacp/tasks/netconf.yaml | 20 + .../junos_lacp/tests/netconf/_remove_config.yaml | 15 + .../targets/junos_lacp/tests/netconf/deleted.yaml | 47 +++ .../junos_lacp/tests/netconf/fixtures/parsed.cfg | 16 + .../targets/junos_lacp/tests/netconf/gathered.yaml | 37 ++ .../targets/junos_lacp/tests/netconf/merged.yaml | 45 +++ .../targets/junos_lacp/tests/netconf/parsed.yaml | 25 ++ .../targets/junos_lacp/tests/netconf/rendered.yaml | 24 ++ .../targets/junos_lacp/tests/netconf/replaced.yaml | 50 +++ .../targets/junos_lacp/tests/netconf/rtt.yaml | 58 +++ .../junos_lacp_interfaces/defaults/main.yaml | 3 + .../targets/junos_lacp_interfaces/meta/main.yaml | 2 + .../targets/junos_lacp_interfaces/tasks/main.yaml | 5 + .../junos_lacp_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_base_config.yaml | 20 + .../tests/netconf/_remove_config.yaml | 21 ++ .../tests/netconf/deleted.yaml | 110 ++++++ .../tests/netconf/fixtures/parsed.cfg | 130 +++++++ .../tests/netconf/gathered.yaml | 59 +++ .../tests/netconf/merged.yaml | 65 ++++ .../tests/netconf/overridden.yml | 85 +++++ .../tests/netconf/parsed.yaml | 35 ++ .../tests/netconf/rendered.yaml | 33 ++ .../tests/netconf/replaced.yaml | 117 ++++++ .../junos_lacp_interfaces/tests/netconf/rtt.yaml | 81 ++++ .../junos_lag_interfaces/defaults/main.yaml | 3 + .../targets/junos_lag_interfaces/meta/main.yaml | 3 + .../targets/junos_lag_interfaces/tasks/main.yaml | 5 + .../junos_lag_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_base_config.yaml | 16 + .../tests/netconf/_remove_config.yaml | 20 + .../tests/netconf/deleted.yaml | 99 +++++ .../tests/netconf/fixtures/parsed.cfg | 135 +++++++ .../tests/netconf/gathered.yaml | 66 ++++ .../junos_lag_interfaces/tests/netconf/merged.yaml | 75 ++++ .../tests/netconf/overridden.yaml | 71 ++++ .../junos_lag_interfaces/tests/netconf/parsed.yaml | 38 ++ .../tests/netconf/rendered.yaml | 36 ++ .../tests/netconf/replaced.yaml | 81 ++++ .../targets/junos_lldp_global/defaults/main.yaml | 3 + .../targets/junos_lldp_global/meta/main.yml | 3 + .../targets/junos_lldp_global/tasks/main.yaml | 5 + .../targets/junos_lldp_global/tasks/netconf.yaml | 20 + .../tests/netconf/_remove_config.yaml | 15 + .../junos_lldp_global/tests/netconf/deleted.yaml | 65 ++++ .../tests/netconf/fixtures/parsed.cfg | 28 ++ .../junos_lldp_global/tests/netconf/gathered.yaml | 56 +++ .../junos_lldp_global/tests/netconf/merged.yaml | 66 ++++ .../junos_lldp_global/tests/netconf/parsed.yaml | 27 ++ .../junos_lldp_global/tests/netconf/rendered.yaml | 26 ++ .../junos_lldp_global/tests/netconf/replaced.yaml | 78 ++++ .../junos_lldp_global/tests/netconf/rtt.yaml | 83 +++++ .../junos_lldp_interfaces/defaults/main.yaml | 3 + .../targets/junos_lldp_interfaces/meta/main.yaml | 3 + .../targets/junos_lldp_interfaces/tasks/main.yaml | 5 + .../junos_lldp_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_remove_config.yaml | 15 + .../tests/netconf/deleted.yaml | 95 +++++ .../tests/netconf/fixtures/parsed.cfg | 24 ++ .../tests/netconf/gathered.yaml | 58 +++ .../tests/netconf/merged.yaml | 66 ++++ .../tests/netconf/overridden.yaml | 69 ++++ .../tests/netconf/parsed.yaml | 28 ++ .../tests/netconf/rendered.yaml | 26 ++ .../tests/netconf/replaced.yaml | 73 ++++ .../junos_lldp_interfaces/tests/netconf/rtt.yaml | 78 ++++ .../integration/targets/junos_logging/aliases | 0 .../targets/junos_logging/defaults/main.yaml | 2 + .../targets/junos_logging/meta/main.yml | 3 + .../targets/junos_logging/tasks/main.yaml | 3 + .../targets/junos_logging/tasks/netconf.yaml | 21 ++ .../targets/junos_logging/tests/netconf/basic.yaml | 407 +++++++++++++++++++++ .../junos_logging_global/defaults/main.yaml | 3 + .../targets/junos_logging_global/meta/main.yml | 3 + .../targets/junos_logging_global/tasks/main.yaml | 5 + .../junos_logging_global/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 11 + .../tests/netconf/_reset_config.yaml | 12 + .../tests/netconf/backups/empty_config.yaml | 49 +++ .../tests/netconf/deleted.yaml | 99 +++++ .../tests/netconf/empty_config.yaml | 61 +++ .../tests/netconf/fixtures/parsed.cfg | 152 ++++++++ .../tests/netconf/gathered.yaml | 99 +++++ .../junos_logging_global/tests/netconf/merged.yaml | 136 +++++++ .../tests/netconf/overridden.yaml | 175 +++++++++ .../junos_logging_global/tests/netconf/parsed.yaml | 20 + .../tests/netconf/rendered.yaml | 29 ++ .../tests/netconf/replaced.yaml | 175 +++++++++ .../junos_logging_global/tests/netconf/rtt.yml | 141 +++++++ .../targets/junos_logging_global/vars/main.yaml | 206 +++++++++++ .../targets/junos_netconf/defaults/main.yaml | 3 + .../targets/junos_netconf/tasks/cli.yaml | 21 ++ .../targets/junos_netconf/tasks/main.yaml | 3 + .../junos_netconf/tests/cli/changeport.yaml | 123 +++++++ .../targets/junos_netconf/tests/cli/netconf.yaml | 133 +++++++ .../junos_netconf/tests/utils/junos_command.yaml | 6 + .../targets/junos_ntp_global/defaults/main.yaml | 3 + .../targets/junos_ntp_global/meta/main.yml | 3 + .../targets/junos_ntp_global/tasks/main.yaml | 5 + .../targets/junos_ntp_global/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 12 + .../tests/netconf/_populate_config.yaml | 21 ++ .../tests/netconf/_reset_config.yaml | 12 + .../tests/netconf/backups/empty_config.yaml | 49 +++ .../junos_ntp_global/tests/netconf/deleted.yaml | 26 ++ .../tests/netconf/empty_config.yaml | 60 +++ .../tests/netconf/fixtures/parsed.cfg | 156 ++++++++ .../junos_ntp_global/tests/netconf/gathered.yaml | 25 ++ .../junos_ntp_global/tests/netconf/merged.yaml | 101 +++++ .../junos_ntp_global/tests/netconf/overridden.yaml | 47 +++ .../junos_ntp_global/tests/netconf/parsed.yaml | 20 + .../junos_ntp_global/tests/netconf/rendered.yaml | 30 ++ .../junos_ntp_global/tests/netconf/replaced.yaml | 47 +++ .../targets/junos_ntp_global/tests/netconf/rtt.yml | 105 ++++++ .../targets/junos_ntp_global/vars/main.yaml | 104 ++++++ .../targets/junos_ospf/defaults/main.yaml | 3 + .../integration/targets/junos_ospf/meta/main.yaml | 3 + .../integration/targets/junos_ospf/tasks/main.yaml | 4 + .../targets/junos_ospf/tasks/netconf.yaml | 20 + .../junos_ospf/tests/netconf/_initial_config.yaml | 18 + .../junos_ospf/tests/netconf/_reset_config.yaml | 11 + .../targets/junos_ospf/tests/netconf/deleted.yaml | 25 ++ .../junos_ospf/tests/netconf/empty_config.yaml | 61 +++ .../junos_ospf/tests/netconf/fixtures/parsed.cfg | 32 ++ .../targets/junos_ospf/tests/netconf/gathered.yaml | 50 +++ .../targets/junos_ospf/tests/netconf/merged.yaml | 57 +++ .../junos_ospf/tests/netconf/overridden.yaml | 64 ++++ .../targets/junos_ospf/tests/netconf/parsed.yaml | 38 ++ .../targets/junos_ospf/tests/netconf/rendered.yaml | 38 ++ .../targets/junos_ospf/tests/netconf/replaced.yaml | 38 ++ .../targets/junos_ospf/tests/netconf/rtt.yaml | 73 ++++ .../junos_ospf_interfaces/defaults/main.yaml | 3 + .../targets/junos_ospf_interfaces/meta/main.yaml | 3 + .../targets/junos_ospf_interfaces/tasks/main.yaml | 4 + .../junos_ospf_interfaces/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 20 + .../tests/netconf/_reset_config.yaml | 11 + .../tests/netconf/deleted.yaml | 69 ++++ .../tests/netconf/empty_config.yaml | 50 +++ .../netconf/fixtures/parse_ospf_router_id.cfg | 23 ++ .../tests/netconf/fixtures/parsed.cfg | 20 + .../tests/netconf/gathered.yaml | 39 ++ .../tests/netconf/merged.yaml | 56 +++ .../tests/netconf/merged_update.yaml | 66 ++++ .../tests/netconf/overridden.yaml | 69 ++++ .../tests/netconf/parsed.yaml | 57 +++ .../tests/netconf/rendered.yaml | 31 ++ .../tests/netconf/replaced.yaml | 46 +++ .../targets/junos_ospfv3/defaults/main.yaml | 3 + .../targets/junos_ospfv3/meta/main.yaml | 3 + .../targets/junos_ospfv3/tasks/main.yaml | 4 + .../targets/junos_ospfv3/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 18 + .../junos_ospfv3/tests/netconf/_reset_config.yaml | 11 + .../junos_ospfv3/tests/netconf/deleted.yaml | 56 +++ .../junos_ospfv3/tests/netconf/empty_config.yaml | 49 +++ .../junos_ospfv3/tests/netconf/fixtures/parsed.cfg | 34 ++ .../junos_ospfv3/tests/netconf/gathered.yaml | 38 ++ .../targets/junos_ospfv3/tests/netconf/merged.yaml | 57 +++ .../junos_ospfv3/tests/netconf/overridden.yaml | 64 ++++ .../targets/junos_ospfv3/tests/netconf/parsed.yaml | 40 ++ .../junos_ospfv3/tests/netconf/rendered.yaml | 38 ++ .../junos_ospfv3/tests/netconf/replaced.yaml | 41 +++ .../targets/junos_prefix_lists/defaults/main.yaml | 3 + .../targets/junos_prefix_lists/meta/main.yml | 3 + .../targets/junos_prefix_lists/tasks/main.yaml | 5 + .../targets/junos_prefix_lists/tasks/netconf.yaml | 20 + .../tests/netconf/_reset_config.yaml | 10 + .../junos_prefix_lists/tests/netconf/deleted.yaml | 78 ++++ .../tests/netconf/empty_config.yaml | 62 ++++ .../tests/netconf/fixtures/parsed.cfg | 21 ++ .../junos_prefix_lists/tests/netconf/gathered.yaml | 56 +++ .../junos_prefix_lists/tests/netconf/merged.yaml | 93 +++++ .../tests/netconf/overridden.yaml | 70 ++++ .../junos_prefix_lists/tests/netconf/parsed.yaml | 30 ++ .../junos_prefix_lists/tests/netconf/rendered.yaml | 34 ++ .../junos_prefix_lists/tests/netconf/replaced.yaml | 72 ++++ .../junos_routing_instances/defaults/main.yaml | 3 + .../targets/junos_routing_instances/meta/main.yml | 3 + .../junos_routing_instances/tasks/main.yaml | 5 + .../junos_routing_instances/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 12 + .../tests/netconf/_reset_config.yaml | 12 + .../tests/netconf/deleted.yaml | 84 +++++ .../tests/netconf/empty_config.yaml | 62 ++++ .../tests/netconf/fixtures/parsed.cfg | 30 ++ .../tests/netconf/gathered.yaml | 65 ++++ .../tests/netconf/merged.yaml | 71 ++++ .../tests/netconf/overridden.yaml | 111 ++++++ .../tests/netconf/parsed.yaml | 39 ++ .../tests/netconf/rendered.yaml | 37 ++ .../tests/netconf/replaced.yaml | 87 +++++ .../junos_routing_options/defaults/main.yaml | 3 + .../targets/junos_routing_options/meta/main.yml | 3 + .../targets/junos_routing_options/tasks/main.yaml | 5 + .../junos_routing_options/tasks/netconf.yaml | 20 + .../tests/netconf/_populate_config.yaml | 8 + .../tests/netconf/_reset_config.yaml | 12 + .../tests/netconf/deleted.yaml | 25 ++ .../tests/netconf/empty_config.yaml | 61 +++ .../tests/netconf/fixtures/parsed.cfg | 14 + .../tests/netconf/gathered.yaml | 24 ++ .../tests/netconf/merged.yaml | 59 +++ .../tests/netconf/overridden.yaml | 44 +++ .../tests/netconf/parsed.yaml | 20 + .../tests/netconf/rendered.yaml | 27 ++ .../tests/netconf/replaced.yaml | 44 +++ .../junos_routing_options/tests/netconf/rtt.yml | 65 ++++ .../targets/junos_routing_options/vars/main.yaml | 21 ++ .../targets/junos_rpc/defaults/main.yaml | 3 + .../integration/targets/junos_rpc/meta/main.yml | 3 + .../integration/targets/junos_rpc/tasks/main.yaml | 3 + .../targets/junos_rpc/tasks/netconf.yaml | 21 ++ .../targets/junos_rpc/tests/netconf/rpc.yaml | 69 ++++ .../junos_security_policies/defaults/main.yaml | 3 + .../targets/junos_security_policies/meta/main.yml | 3 + .../junos_security_policies/tasks/main.yaml | 5 + .../junos_security_policies/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 37 ++ .../tests/netconf/_populate_config.yaml | 53 +++ .../tests/netconf/_reset_config.yaml | 22 ++ .../tests/netconf/deleted.yaml | 27 ++ .../tests/netconf/empty_config.yaml | 61 +++ .../tests/netconf/fixtures/parsed.xml | 301 +++++++++++++++ .../tests/netconf/gathered.yaml | 31 ++ .../tests/netconf/merged.yaml | 171 +++++++++ .../tests/netconf/overridden.yaml | 53 +++ .../tests/netconf/parsed.yaml | 23 ++ .../tests/netconf/rendered.yaml | 124 +++++++ .../tests/netconf/replaced.yaml | 53 +++ .../junos_security_policies/tests/netconf/rtt.yml | 197 ++++++++++ .../targets/junos_security_policies/vars/main.yaml | 235 ++++++++++++ .../defaults/main.yaml | 3 + .../junos_security_policies_global/meta/main.yml | 3 + .../junos_security_policies_global/tasks/main.yaml | 5 + .../tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 11 + .../tests/netconf/_populate_config.yaml | 22 ++ .../tests/netconf/_reset_config.yaml | 12 + .../tests/netconf/deleted.yaml | 26 ++ .../tests/netconf/empty_config.yaml | 61 +++ .../tests/netconf/fixtures/parsed.cfg | 42 +++ .../tests/netconf/gathered.yaml | 25 ++ .../tests/netconf/merged.yaml | 95 +++++ .../tests/netconf/overridden.yaml | 65 ++++ .../tests/netconf/parsed.yaml | 20 + .../tests/netconf/rendered.yaml | 44 +++ .../tests/netconf/replaced.yaml | 54 +++ .../tests/netconf/rtt.yml | 91 +++++ .../junos_security_policies_global/vars/main.yaml | 65 ++++ .../junos_security_zones/defaults/main.yaml | 3 + .../targets/junos_security_zones/meta/main.yml | 3 + .../targets/junos_security_zones/tasks/main.yaml | 5 + .../junos_security_zones/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 18 + .../tests/netconf/_populate_config.yaml | 38 ++ .../tests/netconf/_reset_config.yaml | 16 + .../tests/netconf/deleted.yaml | 26 ++ .../tests/netconf/empty_config.yaml | 61 +++ .../tests/netconf/fixtures/parsed.cfg | 137 +++++++ .../tests/netconf/gathered.yaml | 23 ++ .../junos_security_zones/tests/netconf/merged.yaml | 143 ++++++++ .../tests/netconf/overridden.yaml | 104 ++++++ .../junos_security_zones/tests/netconf/parsed.yaml | 18 + .../tests/netconf/rendered.yaml | 90 +++++ .../tests/netconf/replaced.yaml | 104 ++++++ .../junos_security_zones/tests/netconf/rtt.yml | 184 ++++++++++ .../targets/junos_security_zones/vars/main.yaml | 220 +++++++++++ .../targets/junos_smoke/defaults/main.yaml | 3 + .../integration/targets/junos_smoke/meta/main.yml | 3 + .../integration/targets/junos_smoke/tasks/cli.yaml | 29 ++ .../targets/junos_smoke/tasks/main.yaml | 8 + .../targets/junos_smoke/tasks/netconf.yaml | 19 + .../targets/junos_smoke/tests/cli/caching.yaml | 52 +++ .../targets/junos_smoke/tests/cli/reboot.yaml | 20 + .../junos_smoke/tests/netconf/common_utils.yaml | 24 ++ .../tests/netconf/module_utils_junos.yaml | 53 +++ .../targets/junos_snmp_server/defaults/main.yaml | 3 + .../targets/junos_snmp_server/meta/main.yml | 3 + .../targets/junos_snmp_server/tasks/main.yaml | 5 + .../targets/junos_snmp_server/tasks/netconf.yaml | 20 + .../tests/netconf/_initial_config.yaml | 12 + .../tests/netconf/_populate_config.yaml | 23 ++ .../tests/netconf/_reset_config.yaml | 12 + .../tests/netconf/backups/empty_config.yaml | 49 +++ .../junos_snmp_server/tests/netconf/deleted.yaml | 26 ++ .../tests/netconf/empty_config.yaml | 60 +++ .../tests/netconf/fixtures/parsed.cfg | 62 ++++ .../junos_snmp_server/tests/netconf/gathered.yaml | 25 ++ .../junos_snmp_server/tests/netconf/merged.yaml | 88 +++++ .../tests/netconf/overridden.yaml | 53 +++ .../junos_snmp_server/tests/netconf/parsed.yaml | 20 + .../junos_snmp_server/tests/netconf/rendered.yaml | 30 ++ .../junos_snmp_server/tests/netconf/replaced.yaml | 53 +++ .../junos_snmp_server/tests/netconf/rtt.yaml | 86 +++++ .../targets/junos_snmp_server/vars/main.yaml | 97 +++++ .../targets/junos_static_routes/defaults/main.yaml | 3 + .../targets/junos_static_routes/meta/main.yaml | 2 + .../targets/junos_static_routes/tasks/main.yaml | 5 + .../targets/junos_static_routes/tasks/netconf.yaml | 20 + .../tests/netconf/_base_config.yaml | 25 ++ .../tests/netconf/_remove_config.yaml | 18 + .../junos_static_routes/tests/netconf/deleted.yaml | 43 +++ .../junos_static_routes/tests/netconf/merged.yaml | 78 ++++ .../tests/netconf/overridden.yaml | 57 +++ .../tests/netconf/replaced.yaml | 60 +++ .../tests/integration/targets/junos_system/aliases | 0 .../targets/junos_system/defaults/main.yaml | 3 + .../integration/targets/junos_system/meta/main.yml | 3 + .../targets/junos_system/tasks/main.yaml | 3 + .../targets/junos_system/tasks/netconf.yaml | 21 ++ .../targets/junos_system/tests/netconf/basic.yaml | 370 +++++++++++++++++++ .../targets/junos_user/defaults/main.yaml | 3 + .../integration/targets/junos_user/meta/main.yml | 3 + .../integration/targets/junos_user/tasks/main.yaml | 3 + .../targets/junos_user/tasks/netconf.yaml | 21 ++ .../targets/junos_user/tests/netconf/basic.yaml | 204 +++++++++++ .../targets/junos_vlans/defaults/main.yaml | 3 + .../integration/targets/junos_vlans/meta/main.yaml | 2 + .../targets/junos_vlans/tasks/main.yaml | 5 + .../targets/junos_vlans/tasks/netconf.yaml | 20 + .../junos_vlans/tests/netconf/_base_config.yaml | 13 + .../junos_vlans/tests/netconf/_initial_config.yaml | 12 + .../junos_vlans/tests/netconf/_remove_config.yaml | 12 + .../targets/junos_vlans/tests/netconf/deleted.yaml | 39 ++ .../junos_vlans/tests/netconf/empty_config.yaml | 65 ++++ .../junos_vlans/tests/netconf/fixtures/parsed.cfg | 17 + .../junos_vlans/tests/netconf/gathered.yaml | 35 ++ .../targets/junos_vlans/tests/netconf/merged.yaml | 53 +++ .../junos_vlans/tests/netconf/overridden.yaml | 47 +++ .../targets/junos_vlans/tests/netconf/parsed.yaml | 29 ++ .../junos_vlans/tests/netconf/rendered.yaml | 28 ++ .../junos_vlans/tests/netconf/replaced.yaml | 50 +++ .../targets/junos_vlans/tests/netconf/rtt.yml | 65 ++++ .../targets/junos_vrf/defaults/main.yaml | 3 + .../integration/targets/junos_vrf/meta/main.yml | 3 + .../integration/targets/junos_vrf/tasks/main.yaml | 3 + .../targets/junos_vrf/tasks/netconf.yaml | 21 ++ .../targets/junos_vrf/tests/netconf/basic.yaml | 320 ++++++++++++++++ .../targets/prepare_junos_tests/meta/main.yaml | 2 + .../targets/prepare_junos_tests/tasks/main.yml | 17 + 523 files changed, 22959 insertions(+) create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/target-prefixes.network create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/config_policy.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/idempotent.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/reset_policy_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tests/netconf/basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/purged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/cli.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_json.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_text.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_xml.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/cli/cli_commmand.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/contains.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/equal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthan.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/notequal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/output.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/contains.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/invalid.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/no_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/output.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/timeout.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/contains.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/equal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/invalid.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/notequal.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/output.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/timeout.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/cli_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/redirection.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.j2 create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.set create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.xml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_backup.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_replace.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/backup.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/bad_action.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/invalid.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/multiple.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/single.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_invalid.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/redirection/shortname.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/facts.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/groups.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_base_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_base_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/overridden.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_base_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/backups/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/cli.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/changeport.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/utils/junos_command.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_populate_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/backups/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parse_ospf_router_id.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged_update.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_populate_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tests/netconf/rpc.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_populate_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/fixtures/parsed.xml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_populate_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_populate_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/cli.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/caching.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/reboot.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/common_utils.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/module_utils_junos.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_populate_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_reset_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/backups/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rtt.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/vars/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_base_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/aliases create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tests/netconf/basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tests/netconf/basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_base_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_initial_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_remove_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/deleted.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/empty_config.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/fixtures/parsed.cfg create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/gathered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/merged.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/overridden.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/parsed.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rendered.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/replaced.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rtt.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/defaults/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/meta/main.yml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/netconf.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tests/netconf/basic.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/meta/main.yaml create mode 100644 ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml (limited to 'ansible_collections/junipernetworks/junos/tests/integration') diff --git a/ansible_collections/junipernetworks/junos/tests/integration/target-prefixes.network b/ansible_collections/junipernetworks/junos/tests/integration/target-prefixes.network new file mode 100644 index 000000000..738c4ab49 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +junos diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/main.yaml new file mode 100644 index 000000000..d308b6d19 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Execute netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - "netconf" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..63ac8f93d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_initial_config.yaml @@ -0,0 +1,20 @@ +--- +- name: Debug + ansible.builtin.debug: + msg: "START junipernetworks.junos.junos_acl_interfaces ACL interfaces initial config on connection={{ ansible_connection }}" + +- name: Set initial state for firewalls and interfaces + junipernetworks.junos.junos_acl_interfaces: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: initial_acl + direction: in + - name: second_acl + direction: out + +- name: Debug + ansible.builtin.debug: + msg: "END junipernetworks.junos.junos_acl_interfaces ACL interfaces initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..12fce836b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/_reset_config.yaml @@ -0,0 +1,18 @@ +--- +- name: Debug + ansible.builtin.debug: + msg: "START junipernetworks.junos.junos_acl_interfaces reset ACL and ACL interfaces config on connection={{ ansible_connection }}" + +- name: Set initial state for firewalls and interfaces + junipernetworks.junos.junos_config: + lines: + - delete firewall + - set firewall family inet filter initial_acl term ten_dot from source-port bgp protocol tcp source-address 10.0.0.0/8 + - set firewall family inet filter initial_acl term eleven_dot from source-port bgp protocol tcp source-address 11.0.0.0/8 + - set firewall family inet filter second_acl term twelve_dot from source-port bgp protocol tcp source-address 12.0.0.0/8 + - "delete interfaces ge-1/0/0" + - "delete interfaces ge-2/0/0" + +- name: Debug + ansible.builtin.debug: + msg: "END junipernetworks.junos.junos_acl_interfaces reset ACL and ACL interfaces config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..2915e0071 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,64 @@ +--- +- name: Debug + ansible.builtin.debug: + msg: "START junipernetworks.junos.junos_acl_interfaces deleted integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Invoke initial config + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: initial_acl + direction: in + + - name: Delete a single ACL + junipernetworks.junos.junos_acl_interfaces: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: second_acl + direction: out + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Set facts + ansible.builtin.set_fact: + config: [] + + - name: Delete all ACLs from the device + junipernetworks.junos.junos_acl_interfaces: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: deleted + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug + ansible.builtin.debug: + msg: "END junipernetworks.junos.junos_acl_interfaces deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..204b3b7b2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/empty_config.yaml @@ -0,0 +1,55 @@ +--- +- name: Debug + ansible.builtin.debug: + msg: + START junipernetworks.junos.junos_acl_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acl_interfaces: + config: + state: merged + +- name: Assert result + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acl_interfaces: + config: + state: replaced + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acl_interfaces: + running_config: + state: parsed + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acl_interfaces: + config: + state: rendered + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..d6a0a3533 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,58 @@ +--- +- name: Debug + ansible.builtin.debug: + msg: "START junipernetworks.junos.junos_acl_interfaces merged integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: second_acl + direction: in + - name: initial_acl + direction: out + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_acl_interfaces: &merged + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: second_acl + direction: in + - name: initial_acl + direction: out + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_acl_interfaces: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junipernetworks.junos.junos_acl_interfaces merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 000000000..ea1c6a1c6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,51 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junipernetworks.junos.junos_acl_interfaces overridden integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial configuration + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: initial_acl + direction: in + + - name: Override configuration of ACL + junipernetworks.junos.junos_acl_interfaces: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: initial_acl + direction: in + state: overridden + register: result + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: overridden + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junipernetworks.junos.junos_acl_interfaces overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..2d63c95dd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acl_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,51 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junipernetworks.junos.junos_acl_interfaces replaced integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial configuration + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: initial_acl + direction: in + - name: second_acl + direction: out + - name: initial_acl + direction: out + + - name: Replace configuration of ACL + junipernetworks.junos.junos_acl_interfaces: + config: + - name: ge-1/0/0 + access_groups: + - afi: ipv4 + acls: + - name: initial_acl + direction: out + state: replaced + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - "{{ config|symmetric_difference(result.after) == [] }}" + + tags: replaced + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junipernetworks.junos.junos_acl_interfaces replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/main.yaml new file mode 100644 index 000000000..7b18bda97 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: ["netconf"] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..436b450a0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/_reset_config.yaml @@ -0,0 +1,19 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_acls reset ACL config on connection={{ ansible_connection }}" + +- name: Set initial state + junipernetworks.junos.junos_config: + lines: + - delete firewall + - set firewall family inet filter initial_acl term ten_dot from source-port bgp protocol tcp source-address 10.0.0.0/8 + - set firewall family inet filter initial_acl term eleven_dot from source-port bgp protocol tcp source-address 11.0.0.0/8 + - set firewall family inet filter second_acl term twelve_dot from source-port bgp protocol tcp source-address 12.0.0.0/8 + - set firewall family inet filter third_acl term thirteen_dot from source-port bgp protocol tcp source-address 13.0.0.0/16 + - set firewall family inet filter third_acl term thirteen_dot from source-port bgp protocol tcp source-address 13.1.0.0/16 + - "set firewall family inet6 filter initial_acl6 term colon_eleven from source-port 631 source-address ::11" + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_acls reset ACL config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/config_policy.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/config_policy.yaml new file mode 100644 index 000000000..c425425c3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/config_policy.yaml @@ -0,0 +1,14 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_acls preconfig policy options config on connection={{ ansible_connection }}" + +- name: Set policy config + junipernetworks.junos.junos_config: + lines: + - set policy-options prefix-list ospf-all-routers + - set policy-options prefix-list ipv4-interfaces + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_acls preconfig policy options config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/deleted.yaml new file mode 100644 index 000000000..e44d37280 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/deleted.yaml @@ -0,0 +1,166 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_acls deleted integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset config + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + - aces: + - name: twelve_dot + source: + address: 12.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: second_acl + - aces: + - name: thirteen_dot + source: + address: + - 13.0.0.0/16 + - 13.1.0.0/16 + port_protocol: + eq: bgp + protocol: tcp + name: third_acl + afi: ipv4 + - acls: + - aces: + - name: colon_eleven + source: + address: ::11/128 + port_protocol: + eq: "631" + name: initial_acl6 + afi: ipv6 + + - name: Delete a single ACE + junipernetworks.junos.junos_acls: + config: + - afi: ipv4 + acls: + - name: initial_acl + aces: + - name: eleven_dot + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Set facts + ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + - aces: + - name: thirteen_dot + source: + address: + - 13.0.0.0/16 + - 13.1.0.0/16 + port_protocol: + eq: bgp + protocol: tcp + name: third_acl + afi: ipv4 + - acls: + - aces: + - name: colon_eleven + source: + address: ::11/128 + port_protocol: + eq: "631" + name: initial_acl6 + afi: ipv6 + + - name: Delete a whole ACL + junipernetworks.junos.junos_acls: + config: + - afi: ipv4 + acls: + - name: second_acl + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: *changed + + - name: Set facts + ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + - aces: + - name: thirteen_dot + source: + address: + - 13.0.0.0/16 + - 13.1.0.0/16 + port_protocol: + eq: bgp + protocol: tcp + name: third_acl + afi: ipv4 + + - name: Delete all ACLs under one AFI + junipernetworks.junos.junos_acls: + config: + - afi: ipv6 + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: *changed + + - name: Set facts + ansible.builtin.set_fact: + config: [] + + - name: Delete all ACLs from the device + junipernetworks.junos.junos_acls: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: deleted + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_acls deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..99878acf4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/empty_config.yaml @@ -0,0 +1,66 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_acls empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acls: + config: + state: merged + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acls: + config: + state: replaced + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acls: + config: + state: overridden + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acls: + running_config: + state: parsed + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_acls: + config: + state: rendered + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..c5e52190c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,45 @@ + + + + 18.4R1-S2.4 + + + + + from-cisco + + 1 + + + 10.0.0.0/8 + + + 11.0.0.0/8 + + 1000 + + udp + vrrp + 100 + who + radius + + + icmp_deny + + + + + + 2 + + radius + + + + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/idempotent.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/idempotent.yaml new file mode 100644 index 000000000..e944f5de5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/idempotent.yaml @@ -0,0 +1,79 @@ +--- +- ansible.builtin.debug: + msg: "START junos_acls idempotence integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + - name: eleven_dot + source: + address: 11.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + - aces: + - name: twelve_dot + source: + address: 12.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: second_acl + - aces: + - name: thirteen_dot + source: + address: + - 13.0.0.0/16 + - 13.1.0.0/16 + port_protocol: + eq: bgp + protocol: tcp + name: third_acl + afi: ipv4 + - acls: + - aces: + - name: colon_eleven + source: + address: ::11/128 + port_protocol: + eq: 631 + name: initial_acl6 + afi: ipv6 + + - name: Test equivalence + junipernetworks.junos.junos_acls: + config: "{{ config }}" + state: merged + register: result + + - ansible.builtin.assert: + that: + - result.changed == False + + - name: Test idempotence + junipernetworks.junos.junos_acls: + config: "{{ config }}" + state: overridden + register: result + + - ansible.builtin.assert: + that: + - result.changed == False + + tags: idempotence + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_acls idempotence integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/merged.yaml new file mode 100644 index 000000000..4f360ead8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/merged.yaml @@ -0,0 +1,106 @@ +--- +- ansible.builtin.debug: + msg: "START junos_acls merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: config_policy.yaml + + - ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + - name: eleven_dot + source: + address: 11.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + - aces: + - name: twelve_dot + source: + address: 12.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: second_acl + - aces: + - name: thirteen_dot + source: + address: + - 13.0.0.0/16 + - 13.1.0.0/16 + port_protocol: + eq: bgp + protocol: tcp + name: third_acl + - aces: + - name: ssh_rule + source: + prefix_list: + - name: "ipv4-interfaces" + - name: "ospf-all-routers" + port_protocol: + eq: ssh + protocol: tcp + name: allow_ssh_acl + afi: ipv4 + - acls: + - aces: + - name: colon_eleven + source: + address: ::11/128 + port_protocol: + eq: "631" + name: initial_acl6 + afi: ipv6 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_acls: &merged + config: + - afi: ipv4 + acls: + - name: allow_ssh_acl + aces: + - name: ssh_rule + source: + prefix_list: + - name: "ipv4-interfaces" + - name: "ospf-all-routers" + port_protocol: + eq: ssh + protocol: tcp + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_acls: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: reset_policy_config.yaml + +- ansible.builtin.debug: + msg: "END junos_acls merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/overridden.yaml new file mode 100644 index 000000000..6de41d2e7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/overridden.yaml @@ -0,0 +1,49 @@ +--- +- ansible.builtin.debug: + msg: "START junos_acls overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ace_10 + grant: deny + protocol: tcp + name: acl_1 + - aces: + - name: ace_20 + grant: deny + protocol: udp + name: acl_2 + afi: ipv4 + + - name: Override the entire running configuration with the provided configuration + junipernetworks.junos.junos_acls: &overridden + config: "{{ config }}" + state: overridden + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Override the entire running configuration with the provided configuration (IDEMPOTENT) + junipernetworks.junos.junos_acls: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_acls overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/parsed.yaml new file mode 100644 index 000000000..bd55e13a1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/parsed.yaml @@ -0,0 +1,44 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_acls parsed integration tests on connection={{ ansible_connection + }} + +- name: Set facts + ansible.builtin.set_fact: + expected_parsed_output: + - acls: + - aces: + - destination: + address: "11.0.0.0/8" + port_protocol: + eq: "['who', 'radius']" + name: "1" + protocol: "['udp', 'vrrp']" + source: + address: "10.0.0.0/8" + - destination: + port_protocol: + eq: "radius" + name: "2" + name: "from-cisco" + afi: ipv4 + +- name: Parse externally provided acls config to agnostic model + register: result + junipernetworks.junos.junos_acls: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_acls parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/rendered.yaml new file mode 100644 index 000000000..1dae9de30 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/rendered.yaml @@ -0,0 +1,35 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_acls rendered integration tests on connection={{ + ansible_connection }} + +- name: Set facts + ansible.builtin.set_fact: + expected_rendered_output: 'initial_aclten_dot10.0.0.0/8bgptcp' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_acls: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + afi: ipv4 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: END junos_acls rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/replaced.yaml new file mode 100644 index 000000000..679dccd23 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/replaced.yaml @@ -0,0 +1,105 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_acls replaced integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: + - acls: + - aces: + - name: ten_dot + source: + address: 10.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + - name: eleven_dot + source: + address: 11.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + name: initial_acl + - aces: + - name: twelve_dot + source: + address: 12.0.0.0/8 + port_protocol: + eq: bgp + protocol: tcp + - name: ace_20 + grant: permit + protocol: igmp + source: + address: 192.168.1.100/32 + - name: ace_21 + grant: permit + protocol: tcp + name: second_acl + - aces: + - name: thirteen_dot + source: + address: + - 13.0.0.0/16 + - 13.1.0.0/16 + port_protocol: + eq: bgp + protocol: tcp + name: third_acl + afi: ipv4 + - acls: + - aces: + - name: colon_eleven + source: + address: ::11/128 + port_protocol: + eq: "631" + name: initial_acl6 + afi: ipv6 + + - name: Replace the specified ACL with given config + junipernetworks.junos.junos_acls: &replaced + config: + - afi: ipv4 + acls: + - name: second_acl + aces: + - name: ace_20 + grant: permit + protocol: igmp + source: + address: 192.168.1.100 + - name: ace_21 + grant: permit + protocol: tcp + state: replaced + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Replace the specified ACL with given config (IDEMPOTENT) + junipernetworks.junos.junos_acls: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_acls replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/reset_policy_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/reset_policy_config.yaml new file mode 100644 index 000000000..82c89c158 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_acls/tests/netconf/reset_policy_config.yaml @@ -0,0 +1,16 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_acls reset policy options config on connection={{ ansible_connection }}" + +- name: Reset policy options config + junipernetworks.junos.junos_config: + lines: + - delete firewall family inet filter PROTECT-RE term allow-ospf from source-prefix-list ipv4-interfaces + - delete firewall family inet filter PROTECT-RE term allow-ospf from source-prefix-list ospf-all-routers + - delete policy-options prefix-list ospf-all-routers + - delete policy-options prefix-list ipv4-interfaces + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_acls reset policy options config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/main.yaml new file mode 100644 index 000000000..ac951c8f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/netconf.yaml new file mode 100644 index 000000000..824d3b006 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tests/netconf/basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tests/netconf/basic.yaml new file mode 100644 index 000000000..f1205566c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_banner/tests/netconf/basic.yaml @@ -0,0 +1,205 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START junos_banner netconf/basic.yaml on connection={{ ansible_connection + }}" + +- name: Setup - remove login banner + junipernetworks.junos.junos_banner: + banner: login + state: absent + +- name: Create login banner + register: result + junipernetworks.junos.junos_banner: + banner: login + text: this is my login banner + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my login banner' in config.xml" + +- name: Create login banner (idempotent) + register: result + junipernetworks.junos.junos_banner: + banner: login + text: this is my login banner + state: present + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate login banner + register: result + junipernetworks.junos.junos_banner: + banner: login + text: this is my login banner + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - '''this is my login banner'' in config.xml' + +- name: Activate login banner + register: result + junipernetworks.junos.junos_banner: + banner: login + text: this is my login banner + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my login banner' in config.xml" + +- name: check mode + register: result + check_mode: true + junipernetworks.junos.junos_banner: + banner: login + text: this is not the login banner you're looking for + state: present + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - result.failed == false + +- name: Delete login banner + register: result + junipernetworks.junos.junos_banner: + banner: login + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my login banner' not in config.xml" + +- name: Setup - remove motd banner + junipernetworks.junos.junos_banner: + banner: motd + state: absent + +- name: Create motd banner + register: result + junipernetworks.junos.junos_banner: + banner: motd + text: this is my motd banner + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my motd banner' in config.xml" + +- name: Create motd banner (idempotent) + register: result + junipernetworks.junos.junos_banner: + banner: motd + text: this is my motd banner + state: present + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate motd banner + register: result + junipernetworks.junos.junos_banner: + banner: motd + text: this is my motd banner + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my motd banner'\ + \ in config.xml" + +- name: Activate motd banner + register: result + junipernetworks.junos.junos_banner: + banner: motd + text: this is my motd banner + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my motd banner' in config.xml" + +- name: Delete motd banner + register: result + junipernetworks.junos.junos_banner: + banner: motd + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == true + - "'this is my motd banner' not in config.xml" + +- name: Debug task + ansible.builtin.debug: + msg="END junos_banner netconf/basic.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..18a11dd70 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/_reset_config.yaml @@ -0,0 +1,13 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_address_family reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to bgp address family resource + junipernetworks.junos.junos_config: + lines: + - delete protocols bgp family + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_address_family reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/deleted.yaml new file mode 100644 index 000000000..248421891 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/deleted.yaml @@ -0,0 +1,136 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_address_family deleted integration tests on connection={{ ansible_connection }}" + +- block: + - name: Initial configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + expected_deleted_output: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_bgp_address_family: &merged + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + - afi: "inet" + af_type: + - type: "flow" + legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + + - type: "unicast" + extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + + - type: "labeled-unicast" + entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_prefix_label: true + per_group_label: true + prefix_limit: + maximum: 20 + limit_threshold: 99 + forever: true + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + + - type: "any" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 99 + idle_timeout_value: 2000 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + state: merged + + - name: Delete existing configuration with running configuration + junipernetworks.junos.junos_bgp_address_family: &deleted + config: + address_family: + - afi: "inet" + state: deleted + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_deleted_output == result.after }}" + + - name: Delete the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_bgp_address_family: *deleted + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Set facts + ansible.builtin.set_fact: + expected_deleted_res_output: {} + + - name: Merge the existing config with provided configuration + junos_bgp_address_family: *merged + register: result + + - name: Delete complete existing bgp address family configuration + junipernetworks.junos.junos_bgp_address_family: &deleted_res + config: + state: deleted + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_deleted_res_output == result.after }}" + + tags: deleted + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_address_family deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..64f38991f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/empty_config.yaml @@ -0,0 +1,70 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_bgp_address_family empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_address_family: + config: + state: merged + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_address_family: + config: + state: replaced + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Override with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_address_family: + config: + state: overridden + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_address_family: + running_config: + state: parsed + +- name: Debug task + ansible.builtin.debug: + msg: result + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_address_family: + config: + state: rendered + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..bb0b56fce --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,120 @@ + + + + 18.4R1-S2.4 + + + 2 + 5 + + 10 + + + + 9.9.9.9 + + + + + + 4 + + + + + + + + + + + + + + 20 + + 99 + + 2000 + + + + + + + 23000 + 32000 + + + 20 + 32000 + + + + 2 + + + from-fib + + + + + 20 + + 99 + + + + + + + 3 + + + + + + + + + + + + + + + + + + + 20 + + 98 + + 2001 + + + + + + 2 + + + + + + + + + + 172.16.17.0/24 + + + + 10.200.16.75 + + 65432 + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/gathered.yaml new file mode 100644 index 000000000..023c18015 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/gathered.yaml @@ -0,0 +1,149 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_bgp_address_family gathered integration tests on connection={{ ansible_connection }} + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + expected_gathered_output: + address_family: + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2001 + limit_threshold: 98 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + type: "signaling" + afi: "evpn" + + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2000 + limit_threshold: 99 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + type: "any" + + - legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + type: "flow" + + - entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_group_label: true + per_prefix_label: true + prefix_limit: + forever: true + limit_threshold: 99 + maximum: 20 + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + type: "labeled-unicast" + + - extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + type: "unicast" + afi: "inet" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_bgp_address_family: &merged + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + - afi: "inet" + af_type: + - type: "flow" + legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + + - type: "unicast" + extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + + - type: "labeled-unicast" + entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_prefix_label: true + per_group_label: true + prefix_limit: + maximum: 20 + limit_threshold: 99 + forever: true + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + + - type: "any" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 99 + idle_timeout_value: 2000 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + state: merged + + - name: Gather bgp address family facts using gathered state + register: result + junipernetworks.junos.junos_bgp_address_family: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ expected_gathered_output == result['gathered'] }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_bgp_address_family gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/merged.yaml new file mode 100644 index 000000000..f47dd971c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/merged.yaml @@ -0,0 +1,155 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_address_family merged integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + expected_merged_output: + address_family: + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2001 + limit_threshold: 98 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + type: "signaling" + afi: "evpn" + + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2000 + limit_threshold: 99 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + type: "any" + + - legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + type: "flow" + + - entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_group_label: true + per_prefix_label: true + prefix_limit: + forever: true + limit_threshold: 99 + maximum: 20 + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + type: "labeled-unicast" + + - extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + type: "unicast" + afi: "inet" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_bgp_address_family: &merged + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + - afi: "inet" + af_type: + - type: "flow" + legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + + - type: "unicast" + extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + + - type: "labeled-unicast" + entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_prefix_label: true + per_group_label: true + prefix_limit: + maximum: 20 + limit_threshold: 99 + forever: true + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + + - type: "any" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 99 + idle_timeout_value: 2000 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_merged_output == result.after }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_bgp_address_family: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_address_family merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/overridden.yaml new file mode 100644 index 000000000..286793b8c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/overridden.yaml @@ -0,0 +1,131 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_address_family overridden integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + expected_overridden_output: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 21 + limit_threshold: 99 + idle_timeout_value: 2002 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + damping: true + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_bgp_address_family: &merged + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + - afi: "inet" + af_type: + - type: "flow" + legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + + - type: "unicast" + extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + + - type: "labeled-unicast" + entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_prefix_label: true + per_group_label: true + prefix_limit: + maximum: 20 + limit_threshold: 99 + forever: true + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + + - type: "any" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 99 + idle_timeout_value: 2000 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + state: merged + + - name: Override existing configuration with running configuration + junipernetworks.junos.junos_bgp_address_family: &overridden + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 21 + limit_threshold: 99 + idle_timeout_value: 2002 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + damping: true + state: overridden + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_overridden_output == result.after }}" + + - name: Override the existing running configuration with the provided configuration (IDEMPOTENT) + junipernetworks.junos.junos_bgp_address_family: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_address_family overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/parsed.yaml new file mode 100644 index 000000000..5203c8288 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/parsed.yaml @@ -0,0 +1,84 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_bgp_address_family parsed integration tests on connection={{ ansible_connection + }} + +- name: Set facts + ansible.builtin.set_fact: + expected_parsed_output: + address_family: + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2001 + limit_threshold: 98 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + type: "signaling" + afi: "evpn" + + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2000 + limit_threshold: 99 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + type: "any" + + - legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + type: "flow" + + - entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_group_label: true + per_prefix_label: true + prefix_limit: + forever: true + limit_threshold: 99 + maximum: 20 + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + type: "labeled-unicast" + + - extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + type: "unicast" + afi: "inet" + +- name: Parse externally provided bgp_address_family config to agnostic model + register: result + junipernetworks.junos.junos_bgp_address_family: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_bgp_address_family parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/rendered.yaml new file mode 100644 index 000000000..e919a2c8d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/rendered.yaml @@ -0,0 +1,83 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_bgp_address_family rendered integration tests on connection={{ + ansible_connection }} + +- name: Set facts + ansible.builtin.set_fact: + expected_rendered_output: '20982001249.9.9.92099320992000220320003200023000from-fib' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_bgp_address_family: + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + - afi: "inet" + af_type: + - type: "flow" + legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + + - type: "unicast" + extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + + - type: "labeled-unicast" + entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_prefix_label: true + per_group_label: true + prefix_limit: + maximum: 20 + limit_threshold: 99 + forever: true + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + + - type: "any" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 99 + idle_timeout_value: 2000 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_bgp_address_family rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/replaced.yaml new file mode 100644 index 000000000..d827874e9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_address_family/tests/netconf/replaced.yaml @@ -0,0 +1,177 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_address_family replaced integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + expected_replaced_output: + address_family: + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2002 + limit_threshold: 99 + maximum: 21 + damping: true + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + type: "signaling" + afi: "evpn" + + - af_type: + - accepted_prefix_limit: + idle_timeout_value: 2000 + limit_threshold: 99 + maximum: 20 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + type: "any" + + - legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + type: "flow" + + - entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_group_label: true + per_prefix_label: true + prefix_limit: + forever: true + limit_threshold: 99 + maximum: 20 + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + type: "labeled-unicast" + + - extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + type: "unicast" + afi: "inet" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_bgp_address_family: &merged + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 98 + idle_timeout_value: 2001 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + - afi: "inet" + af_type: + - type: "flow" + legacy_redirect_ip_action: + send: true + receive: true + loops: 4 + no_install: true + output_queue_priority_expedited: true + secondary_independent_resolution: true + + - type: "unicast" + extended_nexthop: true + extended_nexthop_color: true + local_ipv4_address: "9.9.9.9" + + - type: "labeled-unicast" + entropy_label: + no_next_hop_validation: true + explicit_null: + connected_only: true + per_prefix_label: true + per_group_label: true + prefix_limit: + maximum: 20 + limit_threshold: 99 + forever: true + resolve_vpn: true + rib: "inet.3" + route_refresh_priority_priority: 3 + + - type: "any" + accepted_prefix_limit: + maximum: 20 + limit_threshold: 99 + idle_timeout_value: 2000 + damping: true + defer_initial_multipath_build: + maximum_delay: 2 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + graceful_restart_forwarding_state_bit: "from-fib" + state: merged + + - name: Replace existing configuration with running configuration + junipernetworks.junos.junos_bgp_address_family: &replaced + config: + address_family: + - afi: "evpn" + af_type: + - type: "signaling" + accepted_prefix_limit: + maximum: 21 + limit_threshold: 99 + idle_timeout_value: 2002 + delay_route_advertisements: + max_delay_route_age: 20 + max_delay_routing_uptime: 32000 + min_delay_inbound_convergence: 32000 + min_delay_routing_uptime: 23000 + damping: true + state: replaced + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_replaced_output == result.after }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_bgp_address_family: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_address_family replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..d5ab5e107 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_initial_config.yaml @@ -0,0 +1,35 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_global initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to BGP GLOBAL + junipernetworks.junos.junos_config: + lines: + - set routing-options autonomous-system 65534 + - set routing-options autonomous-system loops 3 + - set routing-options autonomous-system asdot-notation + - set protocols bgp accept-remote-nexthop + - set protocols bgp add-path-display-ipv4-address + - set protocols bgp advertise-from-main-vpn-tables + - set protocols bgp advertise-inactive + - set protocols bgp authentication-algorithm md5 + - set protocols bgp bgp-error-tolerance malformed-route-limit 20000000 + - set protocols bgp bmp monitor enable + - set protocols bgp damping + - set protocols bgp description "This is configured with Junos_bgp resource module" + - set protocols bgp egress-te-sid-stats + - set protocols bgp hold-time 5 + - set protocols bgp holddown-all-stale-labels + - set protocols bgp include-mp-next-hop + - set protocols bgp log-updown + - set protocols bgp no-advertise-peer-as + - set protocols bgp no-aggregator-id + - set protocols bgp no-client-reflect + - set protocols bgp out-delay 10 + - set protocols bgp precision-timers + - set protocols bgp preference 2 + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_global initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..efa729d73 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/_reset_config.yaml @@ -0,0 +1,37 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_global reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to bgp global resource + junipernetworks.junos.junos_config: + lines: + - delete routing-options autonomous-system + - delete protocols bgp accept-remote-nexthop + - delete protocols bgp add-path-display-ipv4-address + - delete protocols bgp advertise-from-main-vpn-tables + - delete protocols bgp advertise-inactive + - delete protocols bgp authentication-algorithm + - delete protocols bgp bgp-error-tolerance + - delete protocols bgp bmp + - delete protocols bgp damping + - delete protocols bgp description + - delete protocols bgp egress-te-sid-stats + - delete protocols bgp hold-time + - delete protocols bgp holddown-all-stale-labels + - delete protocols bgp include-mp-next-hop + - delete protocols bgp log-updown + - delete protocols bgp no-advertise-peer-as + - delete protocols bgp no-aggregator-id + - delete protocols bgp no-client-reflect + - delete protocols bgp out-delay + - delete protocols bgp precision-timers + - delete protocols bgp preference + - delete protocols bgp egress-te + - delete protocols bgp egress-te-backup-paths + - delete protocols bgp group external + - delete protocols bgp group internal + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_global reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/deleted.yaml new file mode 100644 index 000000000..c892c7fd3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/deleted.yaml @@ -0,0 +1,34 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_global deleted integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial config + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: {} + + - name: Delete all ospf config from the device + junipernetworks.junos.junos_bgp_global: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_global deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..50ccb3ff5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/empty_config.yaml @@ -0,0 +1,54 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_bgp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: merged + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: replaced + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + running_config: + state: parsed + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: rendered + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..f91cc45a4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,47 @@ + + + + 18.4R1-S2.4 + + + + + + This is configured with Junos_bgp resource module + + 2 + 5 + + + + 10 + + + md5 + + + + + enable + + + static-to-bgp + + + + + + + + + 172.16.17.0/24 + + + + 10.200.16.75 + + 65432 + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/gathered.yaml new file mode 100644 index 000000000..1d1cde1af --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/gathered.yaml @@ -0,0 +1,30 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_bgp_global gathered integration tests on connection={{ ansible_connection }} + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial config + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_bgp_global: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['gathered'] }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_bgp_global gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/merged.yaml new file mode 100644 index 000000000..a89774613 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/merged.yaml @@ -0,0 +1,129 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_global merged integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_bgp_global: &merged + config: + as_number: "65534" + loops: 3 + asdot_notation: true + accept_remote_nexthop: true + add_path_display_ipv4_address: true + advertise_from_main_vpn_tables: true + advertise_inactive: true + authentication_algorithm: "md5" + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + description: "This is configured with Junos_bgp resource module" + egress_te_sid_stats: true + hold_time: 5 + holddown_all_stale_labels: true + include_mp_next_hop: true + log_updown: true + no_advertise_peer_as: true + no_aggregator_id: true + no_client_reflect: true + out_delay: 10 + precision_timers: true + preference: "2" + state: merged + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_bgp_global: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_bgp_global: + config: + as_number: "65534" + loops: 2 + asdot_notation: true + description: "This is updated with Junos_bgp resource module" + egress_te_backup_paths: + templates: + - path_name: "customer1" + peers: + - "11.11.11.11" + - "11.11.11.12" + - "11.11.11.13" + remote_nexthop: "2.2.2.2" + groups: + - name: "internal" + type: "internal" + vpn_apply_export: true + out_delay: 30 + accept_remote_nexthop: true + add_path_display_ipv4_address: true + peer_as: "65534" + allow: + - "all" + - "1.1.1.0/24" + neighbors: + - neighbor_address: "11.11.11.11" + peer_as: "65534" + out_delay: 11 + - neighbor_address: "11.11.11.12" + peer_as: "65534" + out_delay: 12 + + - name: "external" + out_delay: 20 + peer_as: "65534" + accept_remote_nexthop: true + add_path_display_ipv4_address: true + neighbors: + - neighbor_address: "12.12.12.12" + peer_as: "65534" + out_delay: 21 + accept_remote_nexthop: true + add_path_display_ipv4_address: true + - neighbor_address: "11.11.11.13" + peer_as: "65534" + out_delay: 31 + accept_remote_nexthop: true + add_path_display_ipv4_address: true + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_global merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/parsed.yaml new file mode 100644 index 000000000..8b226564e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/parsed.yaml @@ -0,0 +1,52 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_bgp_global parsed integration tests on connection={{ ansible_connection + }} + +- name: Set facts + ansible.builtin.set_fact: + expected_parsed_output: + accept_remote_nexthop: true + add_path_display_ipv4_address: true + advertise_bgp_static: + policy: "static-to-bgp" + advertise_from_main_vpn_tables: true + advertise_inactive: true + as_number: "65432" + authentication_algorithm: "md5" + bmp: + monitor: true + damping: true + description: "This is configured with Junos_bgp resource module" + egress_te_sid_stats: true + hold_time: 5 + holddown_all_stale_labels: true + include_mp_next_hop: true + log_updown: true + no_advertise_peer_as: true + no_aggregator_id: true + no_client_reflect: true + out_delay: 10 + precision_timers: true + preference: "2" + remove_private: + set: true + +- name: Parse externally provided bgp_global config to agnostic model + register: result + junipernetworks.junos.junos_bgp_global: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_bgp_global parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/purged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/purged.yaml new file mode 100644 index 000000000..6ad1d45b3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/purged.yaml @@ -0,0 +1,34 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_global purged integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial config + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: {} + + - name: Purge all ospf config from the device + junipernetworks.junos.junos_bgp_global: + state: purged + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_global purged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rendered.yaml new file mode 100644 index 000000000..6ca1f765d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rendered.yaml @@ -0,0 +1,41 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_bgp_global rendered integration tests on connection={{ + ansible_connection }} + +- name: Set facts + ansible.builtin.set_fact: + expected_rendered_output: 'md5This is configured with Junos_bgp resource module52410automatic20000000enable' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_bgp_global: + config: + authentication_algorithm: "md5" + bfd_liveness_detection: + minimum_receive_interval: 4 + multiplier: 10 + no_adaptation: true + transmit_interval: + minimum_interval: 2 + version: "automatic" + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + description: "This is configured with Junos_bgp resource module" + egress_te_sid_stats: true + hold_time: 5 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: END junos_bgp_global rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/replaced.yaml new file mode 100644 index 000000000..a34d186fe --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/replaced.yaml @@ -0,0 +1,51 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_bgp_global replaced integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial config + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Replace configuration + junipernetworks.junos.junos_bgp_global: &replaced + config: + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + description: "This is configured with Junos_bgp resource module" + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_bgp_global: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_bgp_global replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rtt.yml new file mode 100644 index 000000000..e8bf494b0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/tests/netconf/rtt.yml @@ -0,0 +1,92 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_bgp_global round trip integration tests on connection={{ + ansible_connection }} + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_bgp_global: + config: + accept_remote_nexthop: true + add_path_display_ipv4_address: true + advertise_from_main_vpn_tables: true + advertise_inactive: true + as_number: "65534" + asdot_notation: true + authentication_algorithm: "md5" + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + egress_te_sid_stats: true + hold_time: 5 + holddown_all_stale_labels: true + include_mp_next_hop: true + log_updown: true + loops: 3 + no_advertise_peer_as: true + no_aggregator_id: true + no_client_reflect: true + out_delay: 10 + precision_timers: true + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - bgp_global + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_bgp_global: + config: + accept_remote_nexthop: true + add_path_display_ipv4_address: true + advertise_from_main_vpn_tables: true + advertise_inactive: true + as_number: "65535" + asdot_notation: true + authentication_algorithm: "md5" + bgp_error_tolerance: + malformed_route_limit: 20000000 + preference: "2" + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_bgp_global: + config: "{{ ansible_facts['network_resources']['bgp_global'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_bgp_global round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/vars/main.yaml new file mode 100644 index 000000000..5927e7ff0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_bgp_global/vars/main.yaml @@ -0,0 +1,110 @@ +--- +merged: + before: {} + + after: + accept_remote_nexthop: true + add_path_display_ipv4_address: true + advertise_from_main_vpn_tables: true + advertise_inactive: true + as_number: "65534" + asdot_notation: true + authentication_algorithm: "md5" + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + description: "This is configured with Junos_bgp resource module" + egress_te_sid_stats: true + hold_time: 5 + holddown_all_stale_labels: true + include_mp_next_hop: true + log_updown: true + loops: 3 + no_advertise_peer_as: true + no_aggregator_id: true + no_client_reflect: true + out_delay: 10 + precision_timers: true + preference: "2" + + updated: + accept_remote_nexthop: true + add_path_display_ipv4_address: true + advertise_from_main_vpn_tables: true + advertise_inactive: true + as_number: "65534" + asdot_notation: true + authentication_algorithm: "md5" + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + description: "This is updated with Junos_bgp resource module" + egress_te_backup_paths: + templates: + - path_name: "customer1" + peers: + - "11.11.11.11" + - "11.11.11.12" + - "11.11.11.13" + remote_nexthop: "2.2.2.2" + egress_te_sid_stats: true + groups: + - accept_remote_nexthop: true + add_path_display_ipv4_address: true + allow: + - "0.0.0.0/0" + - "1.1.1.0/24" + name: "internal" + neighbors: + - neighbor_address: "11.11.11.11" + out_delay: 11 + peer_as: "65534" + - neighbor_address: "11.11.11.12" + out_delay: 12 + peer_as: "65534" + out_delay: 30 + peer_as: "65534" + type: "internal" + vpn_apply_export: true + + - accept_remote_nexthop: true + add_path_display_ipv4_address: true + name: "external" + neighbors: + - accept_remote_nexthop: true + add_path_display_ipv4_address: true + neighbor_address: "12.12.12.12" + out_delay: 21 + peer_as: "65534" + + - accept_remote_nexthop: true + add_path_display_ipv4_address: true + neighbor_address: "11.11.11.13" + out_delay: 31 + peer_as: "65534" + out_delay: 20 + peer_as: "65534" + hold_time: 5 + holddown_all_stale_labels: true + include_mp_next_hop: true + log_updown: true + loops: 2 + no_advertise_peer_as: true + no_aggregator_id: true + no_client_reflect: true + out_delay: 10 + precision_timers: true + preference: "2" + +replaced: + after: + bgp_error_tolerance: + malformed_route_limit: 20000000 + bmp: + monitor: true + damping: true + description: "This is configured with Junos_bgp resource module" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/cli.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/cli.yaml new file mode 100644 index 000000000..7a0bc5414 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/cli.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + vars: + ansible_connection: ansible.netcommon.network_cli + loop_control: + loop_var: test_case_to_run diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/main.yaml new file mode 100644 index 000000000..3243ad57e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/main.yaml @@ -0,0 +1,14 @@ +--- +- name: Invoke netconf xml tasks + ansible.builtin.include_tasks: netconf_xml.yaml + +- name: Invoke netconf text + ansible.builtin.include_tasks: netconf_text.yaml + +- name: Invoke netconf json tasks + ansible.builtin.include_tasks: netconf_json.yaml + +- name: Invoke netconf cli tasks + ansible.builtin.include_tasks: cli.yaml + tags: + - network_cli diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_json.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_json.yaml new file mode 100644 index 000000000..88125160e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_json.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf_json test cases with json encoding + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf_json" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_text.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_text.yaml new file mode 100644 index 000000000..6680dd8a3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_text.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf_text test cases with text encoding + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf_text" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_xml.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_xml.yaml new file mode 100644 index 000000000..e2a9be498 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tasks/netconf_xml.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf_xml test cases with xml encoding + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf_xml" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/cli/cli_commmand.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/cli/cli_commmand.yaml new file mode 100644 index 000000000..649e5a52e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/cli/cli_commmand.yaml @@ -0,0 +1,69 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START cli/cli_command.yaml on connection={{ ansible_connection }} + +- block: + - name: Run get output for single command + register: result + ansible.netcommon.cli_command: + command: show version + + - name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + + - name: Run test with prompt and answer + loop: + - configure + - set system syslog file test any any + - rollback + - exit + register: result + ansible.netcommon.cli_command: + command: "{{ item }}" + prompt: + - Exit with uncommitted changes + answer: true + + - name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + + - loop: + - configure + - rollback + - set system login user ansible_test class operator authentication plain-text-password + - commit + register: result + ignore_errors: true + ansible.netcommon.cli_command: + command: "{{item}}" + prompt: + - New password + - Retype new password + answer: + - Test1234 + - Test1234 + check_all: true + + - name: Assertion + ansible.builtin.assert: + that: + - "'failed' not in result" + + - register: result + ignore_errors: true + junipernetworks.junos.junos_netconf: + + - name: Assertion + ansible.builtin.assert: + that: + - result.failed == false + when: ansible_connection == 'ansible.netcommon.network_cli' + +- name: Debug task + ansible.builtin.debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml new file mode 100644 index 000000000..6b51014f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/bad_operator.yaml @@ -0,0 +1,27 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/bad_operator.yaml on connection={{ ansible_connection + }}" + +- name: Run test bad operator with json encoding + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[0]['software-information'][0]['host-name'][0]['data'] foo lo0 + format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/bad_operator.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/contains.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/contains.yaml new file mode 100644 index 000000000..32129d3f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/contains.yaml @@ -0,0 +1,28 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/contains.yaml on connection={{ ansible_connection + }}" + +- name: Run test contains operator with json encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] + contains lo0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/contains.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/equal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/equal.yaml new file mode 100644 index 000000000..9d397f3f7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/equal.yaml @@ -0,0 +1,44 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/equal.yaml on connection={{ ansible_connection + }}" + +- name: Perform test == operator with xml encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] + == lo0 + format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test eq operator with json encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] + eq lo0 + format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_json/equal.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml new file mode 100644 index 000000000..474a54bb1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthan.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/greaterthan.yaml on connection={{ ansible_connection + }}" + +- name: Test gt operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0]['data'] + gt 5 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test > operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0]['data'] + > 5 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/greaterthan.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml new file mode 100644 index 000000000..c5ba4a525 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/greaterthanorequal.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/greaterthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: Run test ge operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0]['data'] + ge 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test >= operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0]['data'] + >= 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/greaterthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthan.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthan.yaml new file mode 100644 index 000000000..3fba44bc3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthan.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/lessthan.yaml on connection={{ ansible_connection + }}" + +- name: Run test lt operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0]['data'] + lt 7 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test < operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0]['data'] + lt 7 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/lessthan.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml new file mode 100644 index 000000000..6d5989809 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/lessthanorequal.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/lessthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: Run test le operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0][data] + le 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test <= operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['local-index'][0][data] + <= 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/lessthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/notequal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/notequal.yaml new file mode 100644 index 000000000..3213b8b64 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/notequal.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/notequal.yaml on connection={{ ansible_connection + }}" + +- name: Run test neq operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] + neq em0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test != operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: json + wait_for: + - result[1]['interface-information'][0]['physical-interface'][0]['name'][0]['data'] + neq em0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_json/notequal.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/output.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/output.yaml new file mode 100644 index 000000000..9e1c16a2b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_json/output.yaml @@ -0,0 +1,67 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_json/output.yaml on connection={{ ansible_connection + }}" + +- name: Run get output for single command + register: result + junipernetworks.junos.junos_command: + commands: + - show version + format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for multiple commands + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show route + format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for single command with cli transport + register: result + connection: ansible.netcommon.network_cli + junipernetworks.junos.junos_command: + commands: + - show version | display json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for multiple commands with cli transport + register: result + connection: ansible.netcommon.network_cli + junipernetworks.junos.junos_command: + commands: + - show version + - show route + format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_json/output.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml new file mode 100644 index 000000000..9fa6242da --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/bad_operator.yaml @@ -0,0 +1,28 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_text/bad_operator.yaml on connection={{ ansible_connection + }}" + +- name: Test bad operator with text encoding + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[1].interface-information[0].physical-interface[0].name[0].data foo + lo0 + encoding: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_text/bad_operator.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/contains.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/contains.yaml new file mode 100644 index 000000000..13cb325c5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/contains.yaml @@ -0,0 +1,27 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_text/contains.yaml on connection={{ ansible_connection + }}" + +- name: Test contains operator with text encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + display: text + wait_for: + - result[1] contains lo0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_text/contains.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/invalid.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/invalid.yaml new file mode 100644 index 000000000..ae847181a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/invalid.yaml @@ -0,0 +1,41 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_text/invalid.yaml on connection={{ ansible_connection + }}" + +- name: Run invalid command + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show foo + display: text + +- name: Debug task + ansible.builtin.debug: var=result + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Run commands that ansible.builtin.include invalid command + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + - show foo + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_text/invalid.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/no_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/no_config.yaml new file mode 100644 index 000000000..b90ee1067 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/no_config.yaml @@ -0,0 +1,26 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_text/no_config.yaml on connection={{ ansible_connection + }}" + +- name: Test handling of show command's empty response received from network device + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show configuration system ntp + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == false + - result.changed == false + - result.stdout|symmetric_difference([""]) == [] + - result.stdout_lines|symmetric_difference([[""]]) == [] + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_text/no_config.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/output.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/output.yaml new file mode 100644 index 000000000..74bc67f1a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/output.yaml @@ -0,0 +1,78 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_text/output.yaml on connection={{ ansible_connection + }}" + +- name: Get output for single command + register: result + junipernetworks.junos.junos_command: + commands: show version + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for multiple commands + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show route + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: get output for partial config commands + register: result + junipernetworks.junos.junos_command: + commands: + - show configuration system syslog + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for single command with cli transport + register: result + junipernetworks.junos.junos_command: + commands: show version + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for multiple commands with cli transport + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show route + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_text/output.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/timeout.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/timeout.yaml new file mode 100644 index 000000000..f1a6d51dd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_text/timeout.yaml @@ -0,0 +1,26 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_text/timeout.yaml on connection={{ ansible_connection + }}" + +- name: Test bad condition + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + display: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Assertion + ansible.builtin.debug: + msg="END netconf_text/timeout.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml new file mode 100644 index 000000000..8e3f1c2db --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/bad_operator.yaml @@ -0,0 +1,28 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/bad_operator.yaml on connection={{ ansible_connection + }}" + +- name: Test bad operator with xml encoding + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[1].rpc-reply.interface-information[0].physical-interface[0].name[0].data + foo lo0 + format: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/bad_operator.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/contains.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/contains.yaml new file mode 100644 index 000000000..1cb019682 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/contains.yaml @@ -0,0 +1,28 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/contains.yaml on connection={{ ansible_connection + }}" + +- name: Test contains operator with xml encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.name contains + lo0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/contains.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/equal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/equal.yaml new file mode 100644 index 000000000..74507da7c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/equal.yaml @@ -0,0 +1,40 @@ +--- +- name: Debug task + ansible.builtin.debug: msg="START netconf_xml/equal.yaml on connection={{ ansible_connection }}" + +- name: Run test == operator with xml encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.name == lo0 + format: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Test eq operator with json encoding + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.name eq lo0 + format: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_xml/equal.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml new file mode 100644 index 000000000..d6ca1d0fd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthan.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/greaterthan.yaml on connection={{ ansible_connection + }}" + +- name: Run test gt operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + gt 5 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Run test > operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + > 5 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/greaterthan.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml new file mode 100644 index 000000000..6f1aebb29 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/greaterthanorequal.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/greaterthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: Test ge operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + ge 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Test >= operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + >= 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/greaterthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/invalid.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/invalid.yaml new file mode 100644 index 000000000..95351ecef --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/invalid.yaml @@ -0,0 +1,38 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/invalid.yaml on connection={{ ansible_connection + }}" + +- name: Run invalid command + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show foo + +- name: Debug task + ansible.builtin.debug: var=result + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Run commands that ansible.builtin.include invalid command + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + - show foo + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_xml/invalid.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml new file mode 100644 index 000000000..da596f53d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthan.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/lessthan.yaml on connection={{ ansible_connection + }}" + +- name: Test lt operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + lt 7 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Test < operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + lt 7 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/lessthan.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml new file mode 100644 index 000000000..bb8c0b852 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/lessthanorequal.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/lessthanorequal.yaml on connection={{ ansible_connection + }}" + +- name: Test le operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + le 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Test <= operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.local-index + <= 6 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/lessthanorequal.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/notequal.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/notequal.yaml new file mode 100644 index 000000000..2e901f215 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/notequal.yaml @@ -0,0 +1,44 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/notequal.yaml on connection={{ ansible_connection + }}" + +- name: Test neq operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.name neq em0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Test != operator + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show interfaces lo0 + format: xml + wait_for: + - result[1].rpc-reply.interface-information.physical-interface.name neq em0 + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: + msg="END netconf_xml/notequal.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/output.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/output.yaml new file mode 100644 index 000000000..ad3e3f684 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/output.yaml @@ -0,0 +1,66 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/output.yaml on connection={{ ansible_connection + }}" + +- name: Get output for single command + register: result + junipernetworks.junos.junos_command: + commands: + - show version + format: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for multiple commands + register: result + junipernetworks.junos.junos_command: + commands: + - show version + - show route + format: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for single command with cli transport + register: result + connection: ansible.netcommon.network_cli + junipernetworks.junos.junos_command: + commands: show version | display xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Get output for multiple commands with cli transport + register: result + connection: ansible.netcommon.network_cli + junipernetworks.junos.junos_command: + commands: + - show version + - show route + display: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - result.stdout is defined + - result.stdout_lines is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_xml/output.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/timeout.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/timeout.yaml new file mode 100644 index 000000000..fedb6d5dd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_command/tests/netconf_xml/timeout.yaml @@ -0,0 +1,23 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg="START netconf_xml/timeout.yaml on connection={{ ansible_connection + }}" + +- name: Test bad condition + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - show version + wait_for: + - result[0] contains bad_value_string + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - result.msg is defined + +- name: Debug task + ansible.builtin.debug: msg="END netconf_xml/timeout.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/defaults/main.yaml new file mode 100644 index 000000000..5f709c5aa --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/cli_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/cli_config.yaml new file mode 100644 index 000000000..7e2151847 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/cli_config.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all cli test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli_config" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.network_cli diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/main.yaml new file mode 100644 index 000000000..7daaf8c3b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/main.yaml @@ -0,0 +1,12 @@ +--- +- name: Invoke netconf netconf tasks + ansible.builtin.include_tasks: netconf.yaml + +- name: Invoke cli tasks + ansible.builtin.include_tasks: cli_config.yaml + tags: + - network_cli + +- name: Invoke tasks + ansible.builtin.include_tasks: redirection.yaml + when: ansible_version.full is version('2.10.0', '>=') diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/netconf.yaml new file mode 100644 index 000000000..824d3b006 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/redirection.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/redirection.yaml new file mode 100644 index 000000000..7671a0477 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tasks/redirection.yaml @@ -0,0 +1,18 @@ +--- +- name: Collect redirection test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/redirection/" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.j2 b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.j2 new file mode 100644 index 000000000..44ddf67bf --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.j2 @@ -0,0 +1,9 @@ +interfaces { + lo0 { + unit 0 { + family inet { + address 192.0.2.1/32; + } + } + } +} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.set b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.set new file mode 100644 index 000000000..df436bba9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.set @@ -0,0 +1 @@ +set interfaces lo0 unit 0 family inet address 192.0.2.1/32 diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.xml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.xml new file mode 100644 index 000000000..a120d4bc4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/templates/basic/config.xml @@ -0,0 +1,15 @@ + + + lo0 + + 0 + + +
+ 192.0.2.1/32 +
+
+
+
+
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_backup.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_backup.yaml new file mode 100644 index 000000000..37c7157bc --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_backup.yaml @@ -0,0 +1,110 @@ +--- +- ansible.builtin.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 + ansible.builtin.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 + register: result + ansible.netcommon.cli_config: + backup: true + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: collect any backup files + ansible.builtin.find: + paths: "{{ role_path }}/backup" + pattern: "{{ inventory_hostname_short }}_config*" + register: backup_files + connection: local + +- ansible.builtin.assert: + that: + - backup_files.files is defined + +- name: take configuration backup in custom filename and directory path + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + filename: backup.cfg + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: check if the backup file-1 exist + ansible.builtin.find: + paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg" + register: backup_file + connection: local + +- ansible.builtin.assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom filename + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + filename: backup.cfg + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: check if the backup file-2 exist + ansible.builtin.find: + paths: "{{ role_path }}/backup/backup.cfg" + register: backup_file + connection: local + +- ansible.builtin.assert: + that: + - backup_file.files is defined + +- name: take configuration backup in custom path and default filename + register: result + ansible.netcommon.cli_config: + backup: true + backup_options: + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: check if the backup file-3 exist + ansible.builtin.find: + paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + pattern: "{{ inventory_hostname_short }}_config*" + register: backup_file + connection: local + +- ansible.builtin.assert: + that: + - backup_file.files is defined + +- ansible.builtin.debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_basic.yaml new file mode 100644 index 000000000..fd0659a30 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_basic.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" + +- name: setup + ansible.netcommon.cli_config: &id002 + config: delete interfaces ge-0/0/1 + +- name: setup + ansible.netcommon.cli_config: &id003 + config: delete interfaces ge-0/0/2 + +- name: configure device with config + register: result + ansible.netcommon.cli_config: &id001 + config: set interfaces ge-0/0/1 description 'test-interface' + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: Idempotence + register: result + ansible.netcommon.cli_config: *id001 + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: configure device with config + register: result + ansible.netcommon.cli_config: + config: set interfaces ge-0/0/2 description 'test-interface' + +- name: test rollabck + register: result + ansible.netcommon.cli_config: + rollback: 1 + +- ansible.builtin.assert: + that: + - result.changed == true + - "'ge-0/0/2' in result.diff.prepared" + +- name: remove root-authethication (test error scenario) + ignore_errors: true + register: result + ansible.netcommon.cli_config: + config: delete system root-authentication + +- ansible.builtin.assert: + that: + - result.failed == true + - "'Missing mandatory statement' in result.msg" + +- name: teardown + ansible.netcommon.cli_config: *id002 + +- name: teardown + ansible.netcommon.cli_config: *id003 + +- ansible.builtin.debug: + msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_replace.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_replace.yaml new file mode 100644 index 000000000..b997b318b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/cli_config/cli_replace.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg="START cli_config/cli_replace.yaml on connection={{ ansible_connection + }}" + +- name: set interface config + loop: + - delete interfaces ge-0/0/11 + - set interfaces ge-0/0/11 description "test cli_config" + ansible.netcommon.cli_config: + config: "{{ item }}" + +- name: get running configuration + register: result + ansible.netcommon.cli_command: + command: show configuration + +- name: copy configuration to file + copy: + content: "{{ result['stdout'] }}" + dest: /tmp/junos01.cfg + +- name: modify interface ge-0/0/11 configuration + replace: + path: /tmp/junos01.cfg + regexp: test cli_config + replace: test cli_config replaced + +- name: copy config file to remote host + ansible.netcommon.net_put: + src: /tmp/junos01.cfg + protocol: sftp + dest: /var/home/{{ ansible_user }}/junos01.cfg + +- name: replace syslog test file configuration + ansible.netcommon.cli_config: + replace: /var/home/{{ ansible_user }}/junos01.cfg + +- name: get interface configuration + register: result + ansible.netcommon.cli_command: + command: show configuration interfaces ge-0/0/11 + +- name: ansible.builtin.assert that interface config change is reflected on device + ansible.builtin.assert: + that: + - "'test cli_config replaced' in result.stdout" + +- name: replace interface configuration (idempotent) + register: result + ansible.netcommon.cli_config: + replace: /var/home/{{ ansible_user }}/junos01.cfg + +- name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + +- name: delete interface config + ansible.netcommon.cli_config: + config: delete interfaces ge-0/0/11 + +- ansible.builtin.debug: + msg="END cli_config/cli_replace.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/backup.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/backup.yaml new file mode 100644 index 000000000..b6746c40a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/backup.yaml @@ -0,0 +1,32 @@ +--- +- ansible.builtin.debug: msg="START netconf/backup.yaml on connection={{ ansible_connection }}" + +- name: setup + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - delete interfaces lo0 + +- name: configure device with config + register: result + junipernetworks.junos.junos_config: + src: basic/config.j2 + backup: true + +- ansible.builtin.assert: + that: + - result.changed == true + - result.updates is not defined + +- name: take configuration backup in custom filename + register: result + junipernetworks.junos.junos_config: + backup: true + backup_options: + filename: backup.cfg + +- ansible.builtin.assert: + that: + - result.changed == true + +- ansible.builtin.debug: msg="END netconf/backup.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/bad_action.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/bad_action.yaml new file mode 100644 index 000000000..ad97a18fd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/bad_action.yaml @@ -0,0 +1,17 @@ +--- +- ansible.builtin.debug: + msg="START netconf/bad_action.yaml on connection={{ ansible_connection + }}" + +- name: configure single bad_action command + register: result + ignore_errors: true + junipernetworks.junos.junos_config: + lines: + - invalid system foo + +- ansible.builtin.assert: + that: + - result.failed == true + +- ansible.builtin.debug: msg="END netconf/bad_action.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/invalid.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/invalid.yaml new file mode 100644 index 000000000..6cb7453d6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/invalid.yaml @@ -0,0 +1,27 @@ +--- +- ansible.builtin.debug: msg="START netconf/invalid.yaml on connection={{ ansible_connection }}" + +- name: configure single invalid command + register: result + ignore_errors: true + junipernetworks.junos.junos_config: + lines: + - set system foo + +- ansible.builtin.assert: + that: + - result.failed == true + +- name: configure multiple invalid command + register: result + ignore_errors: true + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - set system foo + +- ansible.builtin.assert: + that: + - result.failed == true + +- ansible.builtin.debug: msg="END netconf/invalid.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/multiple.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/multiple.yaml new file mode 100644 index 000000000..b53841930 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/multiple.yaml @@ -0,0 +1,43 @@ +--- +- ansible.builtin.debug: msg="START netconf/multiple.yaml on connection={{ ansible_connection }}" + +- name: setup + register: test + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - delete interfaces lo0 + +- name: configure multiple commands + register: result + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - set interfaces lo0 unit 0 family inet address 192.0.2.1/32 + +- ansible.builtin.assert: + that: + - result.changed == true + - "'host-name;' not in result.diff.prepared" + - "'address 192.0.2.1/32' in result.diff.prepared" + +- name: check multiple commands idempotent + register: result + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - set interfaces lo0 unit 0 family inet address 192.0.2.1/32 + +- ansible.builtin.assert: + that: + - result.changed == false + - result.diff is not defined + +- name: teardown + register: test + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - delete interfaces lo0 + +- ansible.builtin.debug: msg="END netconf/multiple.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/single.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/single.yaml new file mode 100644 index 000000000..07f09dce8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/single.yaml @@ -0,0 +1,72 @@ +--- +- ansible.builtin.debug: msg="START netconf/single.yaml on connection={{ ansible_connection }}" + +- name: setup + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + +- name: configure single command + register: result + junipernetworks.junos.junos_config: + lines: + - set system host-name localhost + +- ansible.builtin.assert: + that: + - result.changed == true + - "'+ host-name localhost;' in result.diff.prepared" + +- name: check single command idempotent + register: result + junipernetworks.junos.junos_config: + lines: + - set system host-name localhost + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: confirm previous commit + register: result + junipernetworks.junos.junos_config: + confirm_commit: true + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: teardown for rollback test + junipernetworks.junos.junos_config: + lines: + - delete system syslog file test1 + +- name: Configure syslog file + register: result + junipernetworks.junos.junos_config: + lines: + - set system syslog file test1 any any + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\+ *file test1") + - result.diff.prepared is search("\+ *any any") + +- name: Rollback junos config + register: result + junipernetworks.junos.junos_config: + rollback: 1 + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\+ *file test1") + - result.diff.prepared is search("\+ *any any") + +- name: teardown + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + +- ansible.builtin.debug: msg="END netconf/single.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_basic.yaml new file mode 100644 index 000000000..504a76938 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_basic.yaml @@ -0,0 +1,96 @@ +--- +- ansible.builtin.debug: msg="START netconf/src_basic.yaml on connection={{ ansible_connection }}" + +- name: setup + junipernetworks.junos.junos_config: + lines: + - set system host-name {{ inventory_hostname_short }} + - delete interfaces lo0 + +- name: configure device with text config + register: result + junipernetworks.junos.junos_config: + src: basic/config.j2 + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: check device with config + register: result + junipernetworks.junos.junos_config: + src: basic/config.j2 + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: teardown + register: result + junipernetworks.junos.junos_config: + lines: + - delete interfaces lo0 + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: configure device with set config + register: result + junipernetworks.junos.junos_config: + src: basic/config.set + +- ansible.builtin.assert: + that: + - result.changed == true + - "'address 192.0.2.1/32' in result.diff.prepared" + +- name: check device with config + register: result + junipernetworks.junos.junos_config: + src: basic/config.set + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: teardown + register: result + junipernetworks.junos.junos_config: + lines: + - delete interfaces lo0 + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: configure device with xml config + register: result + junipernetworks.junos.junos_config: + src: basic/config.xml + +- ansible.builtin.assert: + that: + - result.changed == true + - "'address 192.0.2.1/32' in result.diff.prepared" + +- name: check device with config + register: result + junipernetworks.junos.junos_config: + src: basic/config.xml + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: teardown + register: result + junipernetworks.junos.junos_config: + lines: + - delete interfaces lo0 + +- ansible.builtin.assert: + that: + - result.changed == true + +- ansible.builtin.debug: msg="END netconf/src_basic.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_invalid.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_invalid.yaml new file mode 100644 index 000000000..1934b1c5f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/netconf/src_invalid.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg="START netconf/src_invalid.yaml on connection={{ ansible_connection + }}" + +- name: configure with invalid src + register: result + ignore_errors: true + junipernetworks.junos.junos_config: + src: basic/foobar.j2 + +- ansible.builtin.assert: + that: + - result.changed == false + - result.failed == true + - result.msg == 'path specified in src not found' + +- ansible.builtin.debug: msg="END netconf/src_invalid.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/redirection/shortname.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/redirection/shortname.yaml new file mode 100644 index 000000000..d21594c28 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_config/tests/redirection/shortname.yaml @@ -0,0 +1,47 @@ +--- +- ansible.builtin.debug: msg="START redirection/netconf/shortname.yaml on connection={{ ansible_connection }}" + +- name: setup + junipernetworks.junos.config: + lines: + - delete interfaces lo0 + +- name: Use src with module alias + register: result + junipernetworks.junos.config: + src: basic/config.j2 + +- ansible.builtin.assert: + that: + # make sure that the template content was read and not the path + - result.changed == true + +- name: teardown + register: result + junipernetworks.junos.config: + lines: + - delete interfaces lo0 + +- name: use module alias to take configuration backup + register: result + junipernetworks.junos.config: + backup: true + backup_options: + filename: backup_with_alias.cfg + dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}" + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: check if the backup file-4 exist + ansible.builtin.find: + paths: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup_with_alias.cfg" + register: backup_file + connection: local + +- ansible.builtin.assert: + that: + - backup_file.files is defined + +- ansible.builtin.debug: msg="END redirection/netconf/shortname.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/main.yaml new file mode 100644 index 000000000..ac951c8f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/netconf.yaml new file mode 100644 index 000000000..824d3b006 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/facts.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/facts.yaml new file mode 100644 index 000000000..b795d98ed --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/facts.yaml @@ -0,0 +1,126 @@ +--- +- name: Debug task + ansible.builtin.debug: msg="START netconf/facts.yaml on connection={{ ansible_connection }}" + +- name: Collect default facts from device + register: result + junipernetworks.junos.junos_facts: + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'ansible_net_hostname' in result['ansible_facts']" + - "'ansible_net_system' in result['ansible_facts']" + - "'ansible_net_model' in result['ansible_facts']" + +- name: Collect config facts from device + register: result + junipernetworks.junos.junos_facts: + gather_subset: config + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'ansible_net_config' in result['ansible_facts']" + - "'ansible_net_interfaces' not in result['ansible_facts']" + - "'ansible_net_memfree_mb' not in result['ansible_facts']" + +- name: Collect all facts from device except hardware + register: result + junipernetworks.junos.junos_facts: + gather_subset: "!hardware" + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'ansible_net_config' in result['ansible_facts']" + - "'ansible_net_interfaces' in result['ansible_facts']" + - "'ansible_net_memfree_mb' not in result['ansible_facts']" + +- name: Invalid facts subset value + ignore_errors: true + register: result + junipernetworks.junos.junos_facts: + gather_subset: test + +- name: Assertion + ansible.builtin.assert: + that: + - result.failed == true + - "'Subset must be one of' in result.msg" + +- name: Collect config facts from device in set format + register: result + junipernetworks.junos.junos_facts: + gather_subset: config + config_format: set + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'set system services netconf ssh' in result['ansible_facts']['ansible_net_config']" + +- name: Collect config facts from device in xml format + register: result + junipernetworks.junos.junos_facts: + gather_subset: config + config_format: xml + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'' in result['ansible_facts']['ansible_net_config']" + +- name: Collect config facts from device in json format + register: result + junipernetworks.junos.junos_facts: + gather_subset: config + config_format: json + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'{{ result['ansible_facts']['ansible_net_config']['configuration'][0]['system'][0]['service'][0]['netconf']\ + \ }}' is defined" + when: ansible_net_version == "15.1X49-D15.4" + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'ssh' in result['ansible_facts']['ansible_net_config']['configuration']['system']['services']['netconf']" + when: ansible_net_version == "17.3R1.10" + +- name: Collect config facts from device in text format + register: result + junipernetworks.junos.junos_facts: + gather_subset: config + config_format: text + +- name: Assertion + ansible.builtin.assert: + that: + - result.changed == false + - "'netconf {' in result['ansible_facts']['ansible_net_config']" + +- name: Collect list of available network resources for junos + register: result + junipernetworks.junos.junos_facts: + available_network_resources: true + gather_network_resources: all + +- name: Assert that correct available_network_resources returned + ansible.builtin.assert: + that: + - result.changed == false + - "{{ result['ansible_facts']['available_network_resources'] | symmetric_difference(result['ansible_facts']['ansible_net_gather_network_resources']) |length\ + \ == 0 }}" + +- name: Debug task + ansible.builtin.debug: msg="END netconf/facts.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..cf6e70db9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_initial_config.yaml @@ -0,0 +1,13 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_hostname initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to ntp global + junipernetworks.junos.junos_config: + lines: + - set system host-name "vsrx12" + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_hostname initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..a8d6419d5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/_reset_config.yaml @@ -0,0 +1,13 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_hostname reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to ntp global resource + junipernetworks.junos.junos_config: + lines: + - delete system host-name + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_hostname reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/deleted.yaml new file mode 100644 index 000000000..00a4b9683 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/deleted.yaml @@ -0,0 +1,33 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_hostname deleted integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial configuration + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Set facts + ansible.builtin.set_fact: + config: {} + - name: Delete hostname config + junipernetworks.junos.junos_hostname: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_hostname deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..ca0ed7182 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/empty_config.yaml @@ -0,0 +1,66 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_hostname empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_hostname: + config: + state: merged + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_hostname: + config: + state: replaced + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_hostname: + config: + state: overridden + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_hostname: + running_config: + state: parsed + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_hostname: + config: + state: rendered + +- name: Assertion + ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..6619c8d64 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,156 @@ + + + + 18.4R1-S2.4 + + + + vagrant + 2000 + super-user + + $6$QiBkxU5N$QY11GzNuFs1sfY0OAacyJ/0WFmP9ciovUAmM425yYAo9OjccxvjWlEZNo8SeqCQxYeM86cfd9V.N1RiiHW2zN0 + + ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + + + + + + $1$nq.N1UsY$JxA/ESAj3KuXseXE597gg0 + + ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + + + + + + + + 830 + + + + + vsrx + + + * + + any + + + + + messages + + any + + + + authorization + + + + + interactive-commands + + interactive-commands + + + + + + + + https://ae1.juniper.net/junos/key_retrieval + + + + + 78.46.194.186 + + 2 + + + 78.44.194.186 + + + 172.44.194.186 + 10000 + 3 + + + + 48.46.194.186 + 34 + 2 + + rt1 + + + 48.45.194.186 + 34 + 2 + + + + 172.16.255.255 + rt1 + 50 + 3 + 200 + + + 192.16.255.255 + rt2 + 50 + 3 + 200 + + + +
224.0.0.1
+
+ 3000 + 2000 + + 300 + accept + + + 172.45.194.186 + rt1 + + + 171.45.194.186 + rt2 + +
+
+ + + fxp0 + + 0 + + + + + + + + + + + + rt1 + rt1 + + + rt2 + rt2 + + +
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/gathered.yaml new file mode 100644 index 000000000..8c1a988af --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/gathered.yaml @@ -0,0 +1,29 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_hostname gathered integration tests on connection={{ ansible_connection }} + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + - name: Initial configuration + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_hostname: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['gathered'] == result['gathered'] }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_hostname gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/merged.yaml new file mode 100644 index 000000000..a49fb9e45 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/merged.yaml @@ -0,0 +1,59 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_hostname merged integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_hostname: &merged + config: + hostname: "vsrx" + + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_hostname: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_hostname: + config: + hostname: "vsrx14" + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Reset configuration + ansible.builtin.debug: + msg: "END junos_hostname merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/overridden.yaml new file mode 100644 index 000000000..365df590b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/overridden.yaml @@ -0,0 +1,46 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_hostname overridden integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial configuration + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_hostname: &overridden + config: + hostname: "vsrx14" + state: overridden + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['gathered'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_hostname: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_hostname overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/parsed.yaml new file mode 100644 index 000000000..1591fec93 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/parsed.yaml @@ -0,0 +1,23 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_hostname parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided hostname config to agnostic model + register: result + junipernetworks.junos.junos_hostname: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_hostname parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rendered.yaml new file mode 100644 index 000000000..83d106858 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rendered.yaml @@ -0,0 +1,26 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_hostname rendered integration tests on connection={{ + ansible_connection }} + +- name: Set facts + ansible.builtin.set_fact: + expected_rendered_output: 'vsrx14' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_hostname: + config: + hostname: "vsrx14" + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- name: Debug task + ansible.builtin.debug: + msg: END junos_hostname rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/replaced.yaml new file mode 100644 index 000000000..d7b35b962 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/replaced.yaml @@ -0,0 +1,45 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_hostname replaced integration tests on connection={{ ansible_connection }}" + +- block: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + + - name: Initial configuration + ansible.builtin.include_tasks: _initial_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_hostname: &replaced + config: + hostname: "vsrx14" + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['gathered'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_hostname: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_hostname replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rtt.yml new file mode 100644 index 000000000..c08892aac --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/tests/netconf/rtt.yml @@ -0,0 +1,60 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_hostname round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_hostname: + config: + hostname: vsrx + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - hostname + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_hostname: + config: + hostname: "vsrx14" + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_hostname: + config: "{{ ansible_facts['network_resources']['hostname'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - name: Reset configuration + ansible.builtin.include_tasks: _reset_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_hostname round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/vars/main.yaml new file mode 100644 index 000000000..13d4c1954 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_hostname/vars/main.yaml @@ -0,0 +1,12 @@ +--- +merged: + before: {} + + after: + hostname: "vsrx" + + updated: + hostname: "vsrx14" + + gathered: + hostname: "vsrx12" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..b2c608df6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_initial_config.yaml @@ -0,0 +1,15 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: "START junos_interfaces initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to interfaces + junipernetworks.junos.junos_config: + lines: + - set interfaces fe-0/0/2 vlan-tagging + - set interfaces fe-0/0/2.10 vlan-id 10 + - set interfaces fe-0/0/2.11 vlan-id 11 + +- name: Debug task + ansible.builtin.debug: + msg: "END junos_interfaces initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..875fd360b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/_remove_config.yaml @@ -0,0 +1,21 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + Start junos_nterfaces deleted remove interface config ansible_connection={{ + ansible_connection }} + +- name: Setup - remove interface config + junipernetworks.junos.junos_config: + lines: + - delete interfaces ge-0/0/1 + - delete interfaces ge-0/0/2 + - delete interfaces ge-0/0/3 + - delete interfaces lo0 + - delete interfaces fe-0/0/2 + +- name: Debug task + ansible.builtin.debug: + msg: + End junos_nterfaces deleted remove interface config ansible_connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..524476f20 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,105 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_interfaces deleted integration tests on connection={{ ansible_connection + }} + +- name: Reset configuration + ansible.builtin.include_tasks: _remove_config.yaml + +- name: Set facts + ansible.builtin.set_fact: + expected_deleted_output: + - name: fxp0 + enabled: true + - name: ge-0/0/2 + enabled: true + +- block: + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_interfaces: &id002 + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + hold_time: + up: 3000 + down: 3200 + units: + - name: 0 + description: "Logical interface UNIT 0" + state: merged + + - name: Delete the provided interface configuration from running configuration + register: result + junipernetworks.junos.junos_interfaces: &id001 + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Delete the provided interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_interfaces: *id002 + + - name: Delete the all interface configuration from running configuration + register: result + junipernetworks.junos.junos_interfaces: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: Delete the all interface configuration from running configuration (IDEMPOTENT) + register: result + junipernetworks.junos.junos_interfaces: + state: deleted + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - name: Reset configuration + ansible.builtin.include_tasks: _remove_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_interfaces deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..26d323fcc --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,53 @@ + + + + + + ge-0/0/1 + Configured by Ansible + + 100m + 1024 + + 2000 + 2200 + + full-duplex + + 0 + + + access + + vlan100 + + + + + + + ge-0/0/2 + Configured by Ansible + 400 + 10m + 2048 + + 3000 + 3200 + + + 0 + + + trunk + + vlan200 + vlan300 + + + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/gathered.yaml new file mode 100644 index 000000000..05e8b095f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/gathered.yaml @@ -0,0 +1,77 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: START junos_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- name: Reset configuration + ansible.builtin.include_tasks: _remove_config.yaml + +- name: Set facts + ansible.builtin.set_fact: + expected_merged_output: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + enabled: true + hold_time: + up: 3000 + down: 3200 + + - name: fxp0 + enabled: true + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_interfaces: &id001 + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + hold_time: + up: 3000 + down: 3200 + state: merged + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_interfaces: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_merged_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - name: Reset configuration + ansible.builtin.include_tasks: _remove_config.yaml + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_interfaces gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/groups.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/groups.yaml new file mode 100644 index 000000000..f69602758 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/groups.yaml @@ -0,0 +1,59 @@ +--- +- name: Debug task + ansible.builtin.debug: + msg: + START junos_interfaces groups integration tests on connection={{ ansible_connection + }} + +- name: Reset configuration + ansible.builtin.include_tasks: _remove_config.yaml + +- name: Set facts + ansible.builtin.set_fact: + expected_group_output: + - name: ge-0/0/11 + description: within test group + enabled: true + + - name: ge-0/0/12 + description: global interface config + enabled: true + + - name: fxp0 + enabled: true + +- name: Teardown delete interface configuration + junipernetworks.junos.junos_config: &id001 + lines: + - delete apply-groups test + - delete groups test interfaces ge-0/0/11 + - delete interfaces ge-0/0/12 + +- block: + - name: Setup interface configuration + junipernetworks.junos.junos_config: + lines: + - set groups test interfaces ge-0/0/11 description "within test group" + - set apply-groups test + - set interfaces ge-0/0/12 description "global interface config" + + - name: Get junos interfaces facts + register: result + junipernetworks.junos.junos_facts: + gather_subset: min + gather_network_resources: interfaces + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_group_output | symmetric_difference(result['ansible_facts']['ansible_network_resources']['interfaces'])|length\ + \ == 0 }}" + always: + - name: Teardown delete interface configuration + junipernetworks.junos.junos_config: *id001 + +- name: Debug task + ansible.builtin.debug: + msg: + END junos_interfaces merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..3d4f364eb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,94 @@ +--- +- ansible.builtin.debug: + msg: + START junos_interfaces merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _initial_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + enabled: true + hold_time: + up: 3000 + down: 3200 + + - enabled: true + name: fe-0/0/2 + units: + - description: "This is logical interface UNIT 10" + name: 10 + - description: "This is logical interface UNIT 11" + name: 11 + - name: fxp0 + enabled: true + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_interfaces: &id001 + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + hold_time: + up: 3000 + down: 3200 + - name: fe-0/0/2 + units: + - name: 10 + description: "This is logical interface UNIT 10" + - name: 11 + description: "This is logical interface UNIT 11" + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_interfaces merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 000000000..2cb15c8f2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,72 @@ +--- +- ansible.builtin.debug: + msg: + START junos_interfaces overridden integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - name: ge-0/0/1 + description: Overridden by Ansible - Interface 1 + enabled: true + + - name: fxp0 + enabled: true + +- block: + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_interfaces: + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + hold_time: + up: 3000 + down: 3200 + state: merged + + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_interfaces: &id001 + config: + - name: ge-0/0/1 + description: Overridden by Ansible - Interface 1 + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_interfaces overridden integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..0a1c50b1c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,42 @@ +--- +- ansible.builtin.debug: + msg: + START junos_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - description: Configured by Ansible + duplex: full-duplex + enabled: false + hold_time: + down: 2200 + up: 2000 + mtu: 1024 + name: ge-0/0/1 + speed: 100m + + - description: Configured by Ansible + enabled: true + hold_time: + down: 3200 + up: 3000 + mtu: 2048 + name: ge-0/0/2 + speed: 10m + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..e41c92b08 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,29 @@ +--- +- ansible.builtin.debug: + msg: START junos_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'ge-0/0/2Configured by Ansibull20m204832003200' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_interfaces: + config: + - name: ge-0/0/2 + description: Configured by Ansibull + mtu: 2048 + speed: 20m + hold_time: + up: 3200 + down: 3200 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..bcec623b7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,86 @@ +--- +- ansible.builtin.debug: + msg: + START junos_interfaces replaced integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_replaced_output: + - name: ge-0/0/1 + description: Replaced by Ansible - Interface 1 + mtu: 2048 + speed: 10m + enabled: true + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + enabled: true + hold_time: + up: 3000 + down: 3200 + + - name: fxp0 + enabled: true + +- block: + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_interfaces: + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + hold_time: + up: 3000 + down: 3200 + state: merged + + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_interfaces: &id001 + config: + - name: ge-0/0/1 + description: Replaced by Ansible - Interface 1 + mtu: 2048 + speed: 10m + enabled: true + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_interfaces replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rtt.yaml new file mode 100644 index 000000000..cb8bb6c2a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_interfaces/tests/netconf/rtt.yaml @@ -0,0 +1,105 @@ +--- +- ansible.builtin.debug: + msg: + START junos_interfaces round trip integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_revert_output: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + enabled: true + hold_time: + up: 3000 + down: 3200 + + - name: fxp0 + enabled: true + +- block: + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_interfaces: + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 + mtu: 1024 + speed: 100m + enabled: false + duplex: full-duplex + hold_time: + up: 2000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 + mtu: 2048 + speed: 10m + enabled: true + hold_time: + up: 3000 + down: 3200 + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_interfaces: + config: + - name: ge-0/0/1 + description: Configured by Ansible - Interface 1 modified + mtu: 3048 + speed: 10m + enabled: true + duplex: half-duplex + hold_time: + up: 3000 + down: 2200 + + - name: ge-0/0/2 + description: Configured by Ansible - Interface 2 modified + mtu: 4048 + speed: 100m + enabled: false + hold_time: + up: 4000 + down: 5200 + state: merged + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_interfaces: + config: "{{ ansible_facts['network_resources']['interfaces'] }}" + state: replaced + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + "{{ expected_revert_output | symmetric_difference(revert['after'])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..b88eee1c9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_base_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_base_config.yaml new file mode 100644 index 000000000..24bc9e1d1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_base_config.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_l2_interfaces base config ansible_connection={{ ansible_connection + }} + +- name: Configure vlan + junipernetworks.junos.junos_config: + lines: + - set vlans vlan100 vlan-id 100 + - set vlans vlan200 vlan-id 200 + - set vlans vlan300 vlan-id 300 + - set vlans vlan400 vlan-id 400 + +- ansible.builtin.debug: + msg: + End junos_l2_interfaces base config ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..2b814d639 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/_remove_config.yaml @@ -0,0 +1,22 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_l2_interfaces deleted remove l2 interface config ansible_connection={{ + ansible_connection }} + +- name: Setup - remove interface config + junipernetworks.junos.junos_config: + lines: + - delete interfaces ge-0/0/1 + - delete interfaces ge-0/0/2 + - delete interfaces ge-0/0/3 + - delete interfaces lo0 + - delete vlans vlan100 + - delete vlans vlan200 + - delete vlans vlan300 + - delete vlans vlan400 + +- ansible.builtin.debug: + msg: + End junos_l2_interfaces deleted remove l2 interface config ansible_connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..d26fa62d4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,90 @@ +--- +- ansible.builtin.debug: + msg: + START junos_l2_interfaces deleted integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_deleted_output: + - name: ge-0/0/1 + unit: 0 + enhanced_layer: true + access: + vlan: vlan100 + +- block: + - name: Configure initial state for l2 interface + register: result + junipernetworks.junos.junos_l2_interfaces: &id002 + config: + - name: ge-0/0/1 + access: + vlan: vlan100 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + state: merged + + - name: Delete the provided l2 interface configuration from running configuration + register: result + junipernetworks.junos.junos_l2_interfaces: &id001 + config: + - name: ge-0/0/2 + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Delete the provided l2 interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_l2_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_l2_interfaces: *id002 + + - name: Delete the all l2 interface configuration from running configuration + register: result + junipernetworks.junos.junos_l2_interfaces: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ result['after'] == [] }}" + + - name: Delete the all l2 interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_l2_interfaces: + state: deleted + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_l2_interfaces deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..26d323fcc --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,53 @@ + + + + + + ge-0/0/1 + Configured by Ansible + + 100m + 1024 + + 2000 + 2200 + + full-duplex + + 0 + + + access + + vlan100 + + + + + + + ge-0/0/2 + Configured by Ansible + 400 + 10m + 2048 + + 3000 + 3200 + + + 0 + + + trunk + + vlan200 + vlan300 + + + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/gathered.yaml new file mode 100644 index 000000000..1d66a9759 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/gathered.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: START junos_l2_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ge-0/0/1 + access: + vlan: vlan100 + enhanced_layer: true + unit: 0 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + enhanced_layer: true + unit: 0 + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_l2_interfaces: + config: + - name: ge-0/0/1 + access: + vlan: vlan100 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + state: merged + + - name: Gather l2_interfaces facts using gathered state + register: result + junipernetworks.junos.junos_l2_interfaces: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_merged_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_l2_interfaces gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..426f565ef --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,67 @@ +--- +- ansible.builtin.debug: + msg: + START junos_l2_interfaces merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ge-0/0/1 + access: + vlan: vlan100 + enhanced_layer: true + unit: 0 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + enhanced_layer: true + unit: 0 + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_l2_interfaces: &id001 + config: + - name: ge-0/0/1 + access: + vlan: vlan100 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: + Merge the provided l2 interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_l2_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_l2_interfaces merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 000000000..b418b355f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,71 @@ +--- +- ansible.builtin.debug: + msg: + START junos_l2_interfaces override integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan100 + native_vlan: "200" + enhanced_layer: true + unit: 0 + +- block: + - name: Setup initial l2 configuration + register: result + junipernetworks.junos.junos_l2_interfaces: + config: + - name: ge-0/0/1 + access: + vlan: vlan100 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + state: overridden + + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_l2_interfaces: &id001 + config: + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan100 + native_vlan: "200" + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Override the provided l2 interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_l2_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_l2_interfaces override integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..805d43ddf --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: + START junos_l2_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: ge-0/0/1 + access: + vlan: vlan100 + enhanced_layer: true + unit: 0 + + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + enhanced_layer: true + unit: 0 + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_l2_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_l2_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..ca1d574f7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,63 @@ +--- +- ansible.builtin.debug: + msg: START junos_l2_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: ' + + ge-0/0/1 + + 0 + + + access + + vlan100 + + + + + + + ge-0/0/2 + + 0 + + + trunk + + vlan200 + vlan300 + + + + + 400 + + ' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_l2_interfaces: + config: + - name: ge-0/0/1 + access: + vlan: vlan100 + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan200 + - vlan300 + native_vlan: "400" + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_l2_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..af2684505 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,67 @@ +--- +- ansible.builtin.debug: + msg: + START junos_l2_interfaces replaced integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_replaced_output: + - name: ge-0/0/1 + trunk: + allowed_vlans: + - vlan100 + - vlan300 + native_vlan: "400" + enhanced_layer: true + unit: 0 + + - name: ge-0/0/2 + access: + vlan: vlan200 + enhanced_layer: true + unit: 0 + +- block: + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_l2_interfaces: &id001 + config: + - name: ge-0/0/1 + trunk: + allowed_vlans: + - vlan100 + - vlan300 + native_vlan: "400" + + - name: ge-0/0/2 + access: + vlan: vlan200 + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Replace the provided interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_l2_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_l2_interfaces replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml new file mode 100644 index 000000000..4b5501a05 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml @@ -0,0 +1,76 @@ +--- +- ansible.builtin.debug: + msg: START junos_l2_interfaces round trip integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_revert_output: + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan100 + native_vlan: "200" + enhanced_layer: true + unit: 0 + +- block: + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_l2_interfaces: + config: + - name: ge-0/0/2 + trunk: + allowed_vlans: + - vlan100 + native_vlan: "200" + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - l2_interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_l2_interfaces: + config: + - name: ge-0/0/1 + trunk: + allowed_vlans: + - vlan100 + - vlan300 + native_vlan: "400" + + - name: ge-0/0/2 + access: + vlan: vlan200 + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_l2_interfaces: + config: "{{ ansible_facts['network_resources']['l2_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + "{{ expected_revert_output | symmetric_difference(revert['after'])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_l2_interfaces round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/main.yaml new file mode 100644 index 000000000..a6fc560ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..7be9e860a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tasks/netconf.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..bca8ef294 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,55 @@ + + + + + + ge-1/0/0 + + 0 + + +
+ 192.168.100.1/24 +
+
+ 10.200.16.20/24 +
+
+ +
+
+
+ + ge-2/0/0 + + 0 + + +
+ 192.168.100.2/24 +
+
+ 10.200.16.21/24 +
+
+ +
+
+ + 1 + + +
+ 192.178.100.2/24 +
+
+ 10.210.16.21/24 +
+
+ +
+
+
+
+
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml new file mode 100644 index 000000000..468974c71 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml @@ -0,0 +1,131 @@ +--- +- name: bootstrap interfaces + register: result + junipernetworks.junos.junos_l3_interfaces: + config: + - name: ge-1/0/0 + ipv4: + - address: 192.168.100.1/24 + + - address: 10.200.16.20/24 + + - name: ge-2/0/0 + ipv4: + - address: 192.168.100.2/24 + + - address: 10.200.16.21/24 + + - name: ge-3/0/0 + ipv4: + - address: 192.168.100.3/24 + + - address: 10.200.16.22/24 + state: replaced + +- ansible.builtin.assert: + that: + - result is changed + - "'192.168.100.1/24' in result.commands[0]" + - "'10.200.16.20/24' in result.commands[0]" + - result.after[0].name == 'ge-1/0/0' + - result.after[0].ipv4[0]['address'] == '192.168.100.1/24' + - result.after[0].ipv4[1]['address'] == '10.200.16.20/24' + +- name: bootstrap interfaces (idempotent) + register: result + junipernetworks.junos.junos_l3_interfaces: + config: + - name: ge-1/0/0 + ipv4: + - address: 192.168.100.1/24 + + - address: 10.200.16.20/24 + + - name: ge-2/0/0 + ipv4: + - address: 192.168.100.2/24 + + - address: 10.200.16.21/24 + + - name: ge-3/0/0 + ipv4: + - address: 192.168.100.3/24 + + - address: 10.200.16.22/24 + state: replaced + +- ansible.builtin.assert: + that: + - result is not changed + +- name: Gather l3_interfaces facts using gathered state + register: result + junipernetworks.junos.junos_l3_interfaces: + state: gathered + +- name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + - result.gathered[0].name == 'ge-1/0/0' + - result.gathered[0].ipv4[0]['address'] == '192.168.100.1/24' + - result.gathered[0].ipv4[1]['address'] == '10.200.16.20/24' + - result.gathered[1].name == 'ge-2/0/0' + - result.gathered[1].ipv4[0]['address'] == '192.168.100.2/24' + - result.gathered[1].ipv4[1]['address'] == '10.200.16.21/24' + - result.gathered[2].name == 'ge-3/0/0' + - result.gathered[2].ipv4[0]['address'] == '192.168.100.3/24' + - result.gathered[2].ipv4[1]['address'] == '10.200.16.22/24' + +- name: Add another interface ip + register: result + junipernetworks.junos.junos_l3_interfaces: + config: + - name: ge-1/0/0 + ipv4: + - address: 100.64.0.1/10 + + - address: 100.64.0.2/10 + state: merged + +- ansible.builtin.assert: + that: + - result is changed + - "'100.64.0.1/10' in result.commands[0]" + - "'100.64.0.2/10' in result.commands[0]" + - result.after[0].name == 'ge-1/0/0' + - result.after[0].ipv4[0]['address'] == '192.168.100.1/24' + - result.after[0].ipv4[1]['address'] == '10.200.16.20/24' + - result.after[0].ipv4[2]['address'] == '100.64.0.1/10' + - result.after[0].ipv4[3]['address'] == '100.64.0.2/10' + +- name: Delete ge-2/0/0 interface config + register: result + junipernetworks.junos.junos_l3_interfaces: + config: + - name: ge-2/0/0 + state: deleted + +- ansible.builtin.assert: + that: + - result is changed + - "'ge-2/0/00' in result.commands[0]" + +- name: Override all config + register: result + junipernetworks.junos.junos_l3_interfaces: + config: + - name: ge-1/0/0 + ipv4: + - address: dhcp + + - name: fxp0 + ipv4: + - address: dhcp + state: overridden + +- ansible.builtin.assert: + that: + - result is changed + - "'fxp00'\ + \ in result.commands[0]" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..37c27ba2f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,44 @@ +--- +- ansible.builtin.debug: + msg: + START junos_l3_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: ge-1/0/0 + ipv4: + - address: 192.168.100.1/24 + + - address: 10.200.16.20/24 + unit: 0 + + - name: ge-2/0/0 + ipv4: + - address: 192.168.100.2/24 + + - address: 10.200.16.21/24 + unit: 0 + + - name: ge-2/0/0 + ipv4: + - address: 192.178.100.2/24 + + - address: 10.210.16.21/24 + unit: 1 + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_l3_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_l3_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..f0756bb8f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l3_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: START junos_l3_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: ' + + ge-0/0/1 + + 0 + + + access + + vlan100 + + + + + + + ge-0/0/2 + + 0 + + + trunk + + vlan200 + vlan300 + + + + + 400 + + ' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_l3_interfaces: + config: + - name: ge-1/0/0 + ipv4: + - address: 192.168.100.1/24 + - address: 10.200.16.20/24 + unit: 0 + + - name: ge-2/0/0 + ipv4: + - address: 192.168.100.2/24 + - address: 10.200.16.21/24 + unit: 0 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_l3_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/main.yaml new file mode 100644 index 000000000..8248d55c6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf task + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..e15b129d6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_lacp deleted remove lacp config ansible_connection={{ ansible_connection + }} + +- name: Setup - remove lacp config + junipernetworks.junos.junos_config: + lines: + - delete chassis aggregated-devices ethernet lacp + +- ansible.builtin.debug: + msg: + End junos_lacp deleted remove lacp config ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/deleted.yaml new file mode 100644 index 000000000..31b72d419 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/deleted.yaml @@ -0,0 +1,47 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp deleted lacp tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_deleted_output: [] + +- block: + - name: Merge global LACP attributes + register: result + junipernetworks.junos.junos_lacp: + config: + system_priority: 63 + link_protection: revertive + state: merged + + - name: Delete global lacp attributes + register: result + junipernetworks.junos.junos_lacp: &id001 + config: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ result['after'] == {} }}" + + - name: + Delete the provided interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp deleted lacp integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..88c8729fc --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,16 @@ + + + + + + + + 63 + + + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/gathered.yaml new file mode 100644 index 000000000..bc3effbc1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/gathered.yaml @@ -0,0 +1,37 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp gathered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + system_priority: 63 + link_protection: revertive + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp: &id001 + config: + system_priority: 63 + link_protection: revertive + state: merged + + - name: Gather lacp facts using gathered state + register: result + junipernetworks.junos.junos_lacp: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ expected_merged_output == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/merged.yaml new file mode 100644 index 000000000..9776ac8fd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/merged.yaml @@ -0,0 +1,45 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - system_priority: 63 + link_protection: revertive + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp: &id001 + config: + system_priority: 63 + link_protection: revertive + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference([result['after']])\ + \ |length == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/parsed.yaml new file mode 100644 index 000000000..7f297c085 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/parsed.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + link_protection: revertive + system_priority: 63 + +- name: Parse externally provided lacp config to agnostic model + register: result + junipernetworks.junos.junos_lacp: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_lacp parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rendered.yaml new file mode 100644 index 000000000..6935d4904 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rendered.yaml @@ -0,0 +1,24 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '63' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_lacp: + config: + system_priority: 63 + link_protection: revertive + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_lacp rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/replaced.yaml new file mode 100644 index 000000000..d898a551e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/replaced.yaml @@ -0,0 +1,50 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp replaced integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_replaced_output: + - system_priority: 73 + +- block: + - name: Set initial config + junipernetworks.junos.junos_lacp: + config: + system_priority: 73 + link_protection: revertive + state: replaced + + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp: &id001 + config: + system_priority: 73 + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference([result['after']])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rtt.yaml new file mode 100644 index 000000000..eca820939 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp/tests/netconf/rtt.yaml @@ -0,0 +1,58 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp RTT integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_revert_output: + - system_priority: 63 + link_protection: non-revertive + +- block: + - name: Apply the provided configuration (base config) + junipernetworks.junos.junos_lacp: + config: + system_priority: 63 + link_protection: non-revertive + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - lacp + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_lacp: + config: + system_priority: 73 + link_protection: revertive + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_lacp: + config: "{{ ansible_facts['network_resources']['lacp'] }}" + state: replaced + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + "{{ expected_revert_output | symmetric_difference([revert['after']])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp RTT integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/meta/main.yaml new file mode 100644 index 000000000..7f867d73b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/meta/main.yaml @@ -0,0 +1,2 @@ +--- +dependencies: diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/main.yaml new file mode 100644 index 000000000..61aebceb0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf play + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_base_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_base_config.yaml new file mode 100644 index 000000000..56113e5d5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_base_config.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_lacp_interfaces base config ansible_connection={{ ansible_connection + }} + +- name: Configure base lag interface + junipernetworks.junos.junos_config: + lines: + - set interfaces ae1 description "Configured by Ansible" + - set interfaces ae2 description "Configured by Ansible" + - set interfaces ge-0/0/1 ether-options 802.3ad ae1 + - set interfaces ge-0/0/2 ether-options 802.3ad ae1 + - set interfaces ge-0/0/3 ether-options 802.3ad ae2 + - set interfaces ge-0/0/4 ether-options 802.3ad ae2 + +- ansible.builtin.debug: + msg: + End junos_lacp_interfaces base config ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..c180dc0a9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/_remove_config.yaml @@ -0,0 +1,21 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_nterfaces deleted remove interface config ansible_connection={{ + ansible_connection }} + +- name: Setup - remove interface config + junipernetworks.junos.junos_config: + lines: + - delete interfaces ae1 + - delete interfaces ae2 + - delete interfaces ge-0/0/1 + - delete interfaces ge-0/0/2 + - delete interfaces ge-0/0/3 + - delete interfaces ge-0/0/4 + - delete interfaces lo0 + +- ansible.builtin.debug: + msg: + End junos_nterfaces deleted remove interface config ansible_connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..2eec2f58d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,110 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp_interfaces deleted integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_deleted_output: + - name: ae2 + period: slow + sync_reset: disable + system: + priority: 200 + mac: + address: 00:00:00:00:00:04 + + - name: ge-0/0/3 + port_priority: 300 + +- block: + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_lacp_interfaces: &id002 + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + + - name: ae2 + period: slow + sync_reset: disable + system: + priority: 200 + mac: + address: 00:00:00:00:00:04 + + - name: ge-0/0/3 + port_priority: 300 + force_up: false + state: merged + + - name: Delete the provided interface configuration from running configuration + register: result + junipernetworks.junos.junos_lacp_interfaces: &id001 + config: + - name: ae1 + + - name: ge-0/0/1 + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Delete the provided lacp interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_lacp_interfaces: *id002 + + - name: Delete the all lacp interface configuration from running configuration + register: result + junipernetworks.junos.junos_lacp_interfaces: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ result['after'] == [] }}" + + - name: + Delete the all lacp interfaces configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp_interfaces: + state: deleted + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp_interfaces deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..d7bd3d84c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,130 @@ + + + + + + ge-0/0/1 + + + + + 100 + + ae1 + + + + + ge-0/0/2 + + + ae1 + + + + + ge-0/0/3 + + + ae2 + + + + + ge-0/0/4 + + + ae2 + + + + + ge-1/0/0 + + 0 + + +
+ 192.168.100.1/24 +
+
+ 10.200.16.20/24 +
+
+ +
+
+
+ + ge-2/0/0 + + 0 + + +
+ 192.168.100.2/24 +
+
+ 10.200.16.21/24 +
+
+ +
+
+
+ + ge-3/0/0 + + 0 + + +
+ 192.168.100.3/24 +
+
+ 10.200.16.22/24 +
+
+ +
+
+
+ + ae1 + Configured by Ansible + + + fast + enable + 100 + 00:00:00:00:00:02 + + + + + ae2 + Configured by Ansible + + + em1 + TEST + + + fxp0 + ANSIBLE + 1g + automatic + + 0 + + +
+ 10.8.38.38/24 +
+
+
+
+
+
+
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/gathered.yaml new file mode 100644 index 000000000..87e3ac1b1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/gathered.yaml @@ -0,0 +1,59 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp_interfaces: &id001 + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + state: merged + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_lacp_interfaces: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_merged_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp_interfaces gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..5b057b7a2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp_interfaces merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp_interfaces: &id001 + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp_interfaces merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/overridden.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/overridden.yml new file mode 100644 index 000000000..4f3e33f77 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/overridden.yml @@ -0,0 +1,85 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp_interfaces overide integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:01 + +- block: + - name: Configure initial state for lacp interface + register: result + junipernetworks.junos.junos_lacp_interfaces: + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + + - name: ae2 + period: slow + sync_reset: disable + system: + priority: 200 + mac: + address: 00:00:00:00:00:04 + + - name: ge-0/0/3 + port_priority: 300 + force_up: false + state: merged + + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp_interfaces: &id001 + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:01 + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp_interfaces override integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..52bf84add --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,35 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_lacp_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_lacp_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..99299abd0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,33 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'ae1fastenable00:00:00:00:00:02100ge-0/0/1100' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_lacp_interfaces: + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_lacp_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..34fc141cb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,117 @@ +--- +- ansible.builtin.debug: + msg: START junos_lacp_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_replaced_output: + - name: ae1 + period: slow + sync_reset: disable + system: + priority: 10 + mac: + address: 00:00:00:00:00:03 + + - name: ae2 + period: fast + system: + priority: 300 + + - name: ge-0/0/1 + force_up: true + port_priority: 100 + + - name: ge-0/0/2 + port_priority: 250 + + - name: ge-0/0/3 + port_priority: 300 + + - name: ge-0/0/4 + port_priority: 400 + force_up: true + +- block: + - name: Configure initial state for lacp interface + register: result + junipernetworks.junos.junos_lacp_interfaces: + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:02 + + - name: ge-0/0/1 + port_priority: 100 + force_up: true + + - name: ae2 + period: slow + sync_reset: disable + system: + priority: 200 + mac: + address: 00:00:00:00:00:04 + + - name: ge-0/0/3 + port_priority: 300 + force_up: false + state: merged + + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lacp_interfaces: &id001 + config: + - name: ae1 + period: slow + sync_reset: disable + system: + priority: 10 + mac: + address: 00:00:00:00:00:03 + + - name: ge-0/0/2 + port_priority: 250 + force_up: false + + - name: ae2 + period: fast + system: + priority: 300 + + - name: ge-0/0/4 + port_priority: 400 + force_up: true + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lacp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lacp_interfaces replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rtt.yaml new file mode 100644 index 000000000..11c497b29 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lacp_interfaces/tests/netconf/rtt.yaml @@ -0,0 +1,81 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lacp_interfaces round trip integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_revert_output: &base_config + - name: ae1 + period: slow + sync_reset: disable + system: + priority: 10 + mac: + address: 00:00:00:00:00:03 + + - name: ae2 + period: fast + system: + priority: 300 + + - name: ge-0/0/2 + port_priority: 250 + force_up: true + + - name: ge-0/0/4 + port_priority: 400 + force_up: true + +- block: + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_lacp_interfaces: + config: *base_config + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - lacp_interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_lacp_interfaces: + config: + - name: ae1 + period: fast + sync_reset: enable + system: + priority: 100 + mac: + address: 00:00:00:00:00:01 + state: merged + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_lacp_interfaces: + config: "{{ ansible_facts['network_resources']['lacp_interfaces'] }}" + state: overridden + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + "{{ expected_revert_output | symmetric_difference(revert['after'])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: END junos_lacp_interfaces round trip integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/main.yaml new file mode 100644 index 000000000..a6fc560ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_base_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_base_config.yaml new file mode 100644 index 000000000..8239e190e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_base_config.yaml @@ -0,0 +1,16 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_lag_interfaces base config ansible_connection={{ ansible_connection + }} + +- name: Configure base lag interface + junipernetworks.junos.junos_config: + lines: + - set interfaces ae1 description "Configured by Ansible" + - set interfaces ae2 description "Configured by Ansible" + +- ansible.builtin.debug: + msg: + End junos_lag_interfaces base config ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..acdbafbac --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/_remove_config.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_lag_interfaces teardown ansible_connection={{ ansible_connection + }} + +- name: Remove interface config + junipernetworks.junos.junos_config: + lines: + - delete interfaces ge-0/0/1 + - delete interfaces ge-0/0/2 + - delete interfaces ge-0/0/3 + - delete interfaces ge-0/0/4 + - delete interfaces ae1 + - delete interfaces ae2 + +- ansible.builtin.debug: + msg: + End junos_lag_interfaces teardown ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..02a7be520 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,99 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lag_interfaces deleted integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_deleted_1_output: + - name: ae1 + members: + - member: ge-0/0/1 + + - member: ge-0/0/2 + mode: active + expected_deleted_2_output: [] + +- block: + - name: Base LAG configuration + junipernetworks.junos.junos_lag_interfaces: &id002 + config: + - name: ae1 + members: + - member: ge-0/0/1 + + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + state: merged + + - name: Delete the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lag_interfaces: &id001 + config: + - name: ae2 + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_1_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Delete the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + - name: Configure initial state for lag interface + register: result + junipernetworks.junos.junos_lag_interfaces: *id002 + + - name: Delete the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lag_interfaces: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_2_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Delete the provided configuration with the exisiting running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lag_interfaces: + state: deleted + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lag_interfaces deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..99a37d1c7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,135 @@ + + + + + + ge-0/0/1 + + + ae1 + + + + + ge-0/0/2 + + + ae1 + + + + + ge-0/0/3 + + + ae2 + + + + + + ge-0/0/4 + + + ae2 + + + + + + ge-1/0/0 + + 0 + + +
+ 192.168.100.1/24 +
+
+ 10.200.16.20/24 +
+
+ + +
+
+
+ + ge-2/0/0 + + 0 + + +
+ 192.168.100.2/24 +
+
+ 10.200.16.21/24 +
+
+ + +
+
+
+ + ge-3/0/0 + + 0 + + +
+ 192.168.100.3/24 +
+
+ 10.200.16.22/24 +
+
+ + +
+
+
+ + ae1 + Configured by Ansible + + + + + + + + ae2 + Configured by Ansible + + + + + + + + + + em1 + TEST + + + fxp0 + ANSIBLE + 1g + automatic + + 0 + + +
+ 10.8.38.38/24 +
+
+
+
+
+
+
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/gathered.yaml new file mode 100644 index 000000000..e61242861 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/gathered.yaml @@ -0,0 +1,66 @@ +--- +- ansible.builtin.debug: + msg: START junos_lag_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ae1 + members: + - member: ge-0/0/1 + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lag_interfaces: &id001 + config: + - name: ae1 + members: + - member: ge-0/0/1 + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + - member: ge-0/0/4 + link_type: backup + mode: passive + state: merged + + - name: Gather lag interfaces facts using gathered state + register: result + junipernetworks.junos.junos_lag_interfaces: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_merged_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lag_interfaces gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..abbd1c74b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,75 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lag_interfaces merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ae1 + members: + - member: ge-0/0/1 + + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lag_interfaces: &id001 + config: + - name: ae1 + members: + - member: ge-0/0/1 + + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lag_interfaces merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 000000000..0607e5818 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,71 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lag_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - name: ae1 + members: + - member: ge-0/0/2 + mode: active + +- block: + - name: Base LAG configuration + junipernetworks.junos.junos_lag_interfaces: + config: + - name: ae1 + members: + - member: ge-0/0/1 + + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + state: merged + + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lag_interfaces: &id001 + config: + - name: ae1 + members: + - member: ge-0/0/2 + mode: active + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: END junos_lag_interfaces overridden integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..309be925c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lag_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: ae1 + members: + - member: ge-0/0/1 + - member: ge-0/0/2 + mode: active + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_lag_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_lag_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..a5abcfac1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,36 @@ +--- +- ansible.builtin.debug: + msg: START junos_lag_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'ae1ge-0/0/1ae1ge-0/0/2ae1ae2ge-0/0/3ae2ge-0/0/4ae2' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_lag_interfaces: + config: + - name: ae1 + members: + - member: ge-0/0/1 + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + - member: ge-0/0/4 + link_type: backup + mode: passive + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_lag_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..67d352205 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lag_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,81 @@ +--- +- ansible.builtin.debug: + msg: START junos_lag_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_replaced_output: + - name: ae1 + members: + - member: ge-0/0/1 + mode: passive + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + +- block: + - name: Base LAG configuration + junipernetworks.junos.junos_lag_interfaces: + config: + - name: ae1 + members: + - member: ge-0/0/1 + + - member: ge-0/0/2 + mode: active + + - name: ae2 + link_protection: true + members: + - member: ge-0/0/3 + link_type: primary + + - member: ge-0/0/4 + link_type: backup + mode: passive + state: merged + + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lag_interfaces: &id001 + config: + - name: ae1 + members: + - member: ge-0/0/1 + mode: passive + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lag_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_lag_interfaces replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/main.yaml new file mode 100644 index 000000000..a6fc560ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..9d317f61d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_lldp_global deleted remove interface config ansible_connection={{ + ansible_connection }} + +- name: Setup - remove lldp global config + junipernetworks.junos.junos_config: + lines: + - delete protocols lldp + +- ansible.builtin.debug: + msg: + End junos_lldp_global deleted remove interface config ansible_connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/deleted.yaml new file mode 100644 index 000000000..88d00b316 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/deleted.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_global deleted integration tests on connection={{ ansible_connection + }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_deleted_output: [] + + - name: Configure initial state for lldp global + register: result + junipernetworks.junos.junos_lldp_global: + config: + interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + state: merged + + - name: Delete the provided configuration from running configuration + register: result + junipernetworks.junos.junos_lldp_global: &id001 + config: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ result['after'] == {} }}" + + - name: Delete the provided configuration from running configuration (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_global: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_global deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..28735efbf --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,28 @@ + + + + + + + 0.0.0.0 + + ge-0/0/0.0 + + + + + 10.1.1.1 + 10000 + 400 + 10 + + ge-0/0/1 + + + ge-0/0/2 + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/gathered.yaml new file mode 100644 index 000000000..1d18ea0f9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/gathered.yaml @@ -0,0 +1,56 @@ +--- +- ansible.builtin.debug: + msg: START junos_lldp_global gathered integration tests on connection={{ + ansible_connection }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- ansible.builtin.set_fact: + expected_merged_output: + - interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 1 + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_global: &id001 + config: + interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + state: merged + + - name: Gather lldp_global facts using gathered state + register: result + junipernetworks.junos.junos_lldp_global: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ expected_merged_output == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_global gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/merged.yaml new file mode 100644 index 000000000..ba65dca5f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/merged.yaml @@ -0,0 +1,66 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_global merged integration tests on connection={{ ansible_connection + }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_merged_output: + - interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_global: &id001 + config: + interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference([result['after']])\ + \ |length == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_global: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_global merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/parsed.yaml new file mode 100644 index 000000000..7a8b2eeca --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/parsed.yaml @@ -0,0 +1,27 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_global parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + address: 10.1.1.1 + hold_multiplier: 10 + interval: 10000 + transmit_delay: 400 + +- name: Parse externally provided lldp_global config to agnostic model + register: result + junipernetworks.junos.junos_lldp_global: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_lldp_global parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rendered.yaml new file mode 100644 index 000000000..c79ad52ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rendered.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: START junos_lldp_global rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '10.1.1.11000040010' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_lldp_global: + config: + interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_lldp_global rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/replaced.yaml new file mode 100644 index 000000000..6f0f50ea6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/replaced.yaml @@ -0,0 +1,78 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_global replaced integration tests on connection={{ ansible_connection + }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_replaced_output: + - interval: 20000 + address: 10.1.1.2 + transmit_delay: 500 + hold_multiplier: 5 + enabled: false + + - name: Configure initial state for lldp global + register: result + junipernetworks.junos.junos_lldp_global: + config: + interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + state: merged + + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_global: &id001 + config: + interval: 20000 + address: 10.1.1.2 + transmit_delay: 500 + hold_multiplier: 5 + enabled: false + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference([result['after']])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_global: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_global replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rtt.yaml new file mode 100644 index 000000000..e7537bf5e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_global/tests/netconf/rtt.yaml @@ -0,0 +1,83 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_global round trip integration tests on connection={{ ansible_connection + }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_revert_output: + - interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_lldp_global: + config: + interval: 10000 + address: 10.1.1.1 + transmit_delay: 400 + hold_multiplier: 10 + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - lldp_global + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_lldp_global: + config: + interval: 20000 + address: 10.1.1.2 + transmit_delay: 500 + hold_multiplier: 5 + enabled: false + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_lldp_global: + config: "{{ ansible_facts['network_resources']['lldp_global'] }}" + state: replaced + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + "{{ expected_revert_output | symmetric_difference([revert['after']])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_global round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/main.yaml new file mode 100644 index 000000000..a6fc560ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..5c1c477ac --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_lldp_interfaces deleted remove interface config ansible_connection={{ + ansible_connection }} + +- name: Setup - remove lldp interfaces config + junipernetworks.junos.junos_config: + lines: + - delete protocols lldp + +- ansible.builtin.debug: + msg: + End junos_lldp_interfaces deleted remove interface config ansible_connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..31849facf --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,95 @@ +--- +- ansible.builtin.debug: + msg: START junos_lldp_interfaces deleted integration tests on connection={{ + ansible_connection }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_deleted_output: + - name: ge-0/0/1 + + - name: Configure initial state for lldp interfaces + register: result + junipernetworks.junos.junos_lldp_interfaces: &id002 + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + state: merged + + - name: Delete the provided lldp interface configuration from running configuration + register: result + junipernetworks.junos.junos_lldp_interfaces: &id001 + config: + - name: ge-0/0/2 + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_deleted_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Delete the provided lldp interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_lldp_interfaces: *id002 + + - name: Delete the all lldp interface configuration from running configuration + register: result + junipernetworks.junos.junos_lldp_interfaces: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ result['after'] == []}}" + + - name: + Delete the all lldp interface configuration from running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_interfaces: + state: deleted + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_interfaces deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..7875abecb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,24 @@ + + + + + + + 0.0.0.0 + + ge-0/0/0.0 + + + + + + ge-0/0/1 + + + ge-0/0/2 + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/gathered.yaml new file mode 100644 index 000000000..05765490e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/gathered.yaml @@ -0,0 +1,58 @@ +--- +- ansible.builtin.debug: + msg: START junos_lldp_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- ansible.builtin.set_fact: + expected_merged_output: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_interfaces: &id001 + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + state: merged + + - name: Gather lag interfaces facts using gathered state + register: result + junipernetworks.junos.junos_lldp_interfaces: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_merged_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_interfaces gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..9454ac5f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,66 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_interfaces merged integration tests on connection={{ ansible_connection + }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_merged_output: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_interfaces: &id001 + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_interfaces merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 000000000..ad3f8e540 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,69 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_interfaces overridden integration tests on connection={{ + ansible_connection }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_overridden_output: + - name: ge-0/0/2 + + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_lldp_interfaces: + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + state: merged + + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_interfaces: &id001 + config: + - name: ge-0/0/2 + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: END junos_lldp_interfaces overridden integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..8ef4a0879 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,28 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + +- name: Parse externally provided lldp interfaces config to agnostic model + register: result + junipernetworks.junos.junos_lldp_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_lldp_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..b37382624 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: START junos_lldp_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'ge-0/0/1ge-0/0/2' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_lldp_interfaces: + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_lldp_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..aa791070f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,73 @@ +--- +- ansible.builtin.debug: + msg: START junos_lldp_interfaces replaced integration tests on connection={{ + ansible_connection }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_replaced_output: + - name: ge-0/0/1 + enabled: false + + - name: ge-0/0/2 + enabled: false + + - name: Configure initial state for interface + register: result + junipernetworks.junos.junos_lldp_interfaces: + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_lldp_interfaces: &id001 + config: + - name: ge-0/0/1 + enabled: false + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_lldp_interfaces: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: + END junos_lldp_interfaces replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml new file mode 100644 index 000000000..db6c7c20a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_lldp_interfaces/tests/netconf/rtt.yaml @@ -0,0 +1,78 @@ +--- +- ansible.builtin.debug: + msg: + START junos_lldp_interfaces round trip integration tests on connection={{ + ansible_connection }} + +- name: get supported protocols + register: result + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show lldp + +- name: lldp supported + ansible.builtin.set_fact: + lldp_supported: true + when: not result.failed + +- name: lldp not supported + ansible.builtin.set_fact: + lldp_supported: false + when: result.failed + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.set_fact: + expected_revert_output: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_lldp_interfaces: + config: + - name: ge-0/0/1 + + - name: ge-0/0/2 + enabled: false + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - lldp_interfaces + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_lldp_interfaces: + config: + - name: ge-0/0/2 + state: overridden + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_lldp_interfaces: + config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}" + state: replaced + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + "{{ expected_revert_output | symmetric_difference(revert['after'])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + when: lldp_supported + +- ansible.builtin.debug: + msg: END junos_lldp_interfaces round trip integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases new file mode 100644 index 000000000..e69de29bb diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml new file mode 100644 index 000000000..5f709c5aa --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml new file mode 100644 index 000000000..eace31d3f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml new file mode 100644 index 000000000..6071adcfe --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + register: test_cases + connection: local + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml new file mode 100644 index 000000000..030ce9e69 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml @@ -0,0 +1,407 @@ +--- +- ansible.builtin.debug: + msg="START junos_logging netconf/basic.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove file logging + junipernetworks.junos.junos_logging: + dest: file + name: test + facility: pfe + level: error + state: absent + +- name: Create file logging + register: result + junipernetworks.junos.junos_logging: + dest: file + name: test_file + facility: pfe + level: error + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_file' in config.xml" + - "'pfe' in config.xml" + - "'' in config.xml" + +- name: Create file logging (idempotent) + register: result + junipernetworks.junos.junos_logging: + dest: file + name: test_file + facility: pfe + level: error + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate logging configuration + register: result + junipernetworks.junos.junos_logging: + dest: file + name: test_file + facility: pfe + level: error + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - ''''' in config.xml' + - ''''' in config.xml' + +- name: Activate logging configuration + register: result + junipernetworks.junos.junos_logging: + dest: file + name: test_file + facility: pfe + level: error + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_file' in config.xml" + - "'pfe' in config.xml" + - "'' in config.xml" + +- name: Delete logging configuration + register: result + junipernetworks.junos.junos_logging: + dest: file + name: test_file + facility: pfe + level: error + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_file' not in config.xml" + +- name: Configure console logging + register: result + junipernetworks.junos.junos_logging: + dest: console + facility: kernel + level: emergency + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'' in config.xml" + - "'kernel' in config.xml" + - "'' in config.xml" + +- name: Configure console logging (idempotent) + register: result + junipernetworks.junos.junos_logging: + dest: console + facility: kernel + level: emergency + state: present + active: true + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Disable console logging + register: result + junipernetworks.junos.junos_logging: + dest: console + facility: kernel + level: emergency + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - ''''' in config.xml' + +- name: Delete console logging + register: result + junipernetworks.junos.junos_logging: + dest: console + facility: kernel + level: emergency + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'' not in config.xml" + +- name: Configure logging parameters + register: result + junipernetworks.junos.junos_logging: + size: 65536 + files: 40 + rotate_frequency: 20 + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'64k' in config.xml" + - "'40' in config.xml" + - "'20' in config.xml" + +- name: Configure logging parameters (idempotent) + register: result + junipernetworks.junos.junos_logging: + size: 65536 + files: 40 + rotate_frequency: 20 + state: present + active: true + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Disable logging parameters + register: result + junipernetworks.junos.junos_logging: + size: 65536 + files: 40 + rotate_frequency: 20 + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - '''64k'' in config.xml' + - '''40'' in config.xml' + - "'20'\ + \ in config.xml" + +- name: Activate logging parameters + register: result + junipernetworks.junos.junos_logging: + size: 65536 + files: 40 + rotate_frequency: 20 + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'64k' in config.xml" + - "'40' in config.xml" + - "'20' in config.xml" + +- name: Delete logging parameters + register: result + junipernetworks.junos.junos_logging: + size: 65536 + files: 40 + rotate_frequency: 20 + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'64k' not in config.xml" + - "'40' not in config.xml" + - "'20' not in config.xml" + +- name: Seup file logging using aggregate + register: result + junipernetworks.junos.junos_logging: + aggregate: + - dest: file + name: test-1 + facility: pfe + level: critical + state: absent + + - dest: file + name: test-2 + facility: kernel + level: emergency + state: absent + +- name: Configure file logging using aggregate + register: result + junipernetworks.junos.junos_logging: + aggregate: + - dest: file + name: test-1 + facility: pfe + level: critical + active: true + + - dest: file + name: test-2 + facility: kernel + level: emergency + active: true + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\+ *file test-1") + - result.diff.prepared is search("\+ *pfe critical") + - result.diff.prepared is search("\+ *file test-2") + - result.diff.prepared is search("\+ *kernel emergency") + +- name: Deactivate file logging configuration using aggregate + register: result + junipernetworks.junos.junos_logging: + aggregate: + - dest: file + name: test-1 + facility: pfe + level: critical + + - dest: file + name: test-2 + facility: kernel + level: emergency + active: false + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("! *inactive[:] file test-1") + - result.diff.prepared is search("! *inactive[:] pfe") + - result.diff.prepared is search("! *inactive[:] file test-2") + - result.diff.prepared is search("! *inactive[:] kernel") + +- name: activate file logging configuration using aggregate + register: result + junipernetworks.junos.junos_logging: + aggregate: + - dest: file + name: test-1 + facility: pfe + level: critical + + - dest: file + name: test-2 + facility: kernel + level: emergency + active: true + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("! *active[:] file test-1") + - result.diff.prepared is search("! *active[:] pfe") + - result.diff.prepared is search("! *active[:] file test-2") + - result.diff.prepared is search("! *active[:] kernel") + +- name: Delete file logging using aggregate + register: result + junipernetworks.junos.junos_logging: + aggregate: + - dest: file + name: test-1 + facility: pfe + level: critical + + - dest: file + name: test-2 + facility: kernel + level: emergency + state: absent + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\- *file test-1") + - result.diff.prepared is search("\- *pfe critical") + - result.diff.prepared is search("\- *file test-2") + - result.diff.prepared is search("\- *kernel emergency") + +- name: Delete file logging using aggregate (idempotent) + register: result + junipernetworks.junos.junos_logging: + aggregate: + - dest: file + name: test-1 + facility: pfe + level: critical + + - dest: file + name: test-2 + facility: kernel + level: emergency + state: absent + +- ansible.builtin.assert: + that: + - result.changed == false + +- ansible.builtin.debug: + msg="END junos_logging netconf/basic.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/main.yaml new file mode 100644 index 000000000..a6fc560ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..289c92300 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_initial_config.yaml @@ -0,0 +1,11 @@ +--- +- ansible.builtin.debug: + msg: "START junos_logging_global initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to logging global + junipernetworks.junos.junos_config: + lines: + - set routing-instances inst11 description "inst11" + +- ansible.builtin.debug: + msg: "END junos_logging_global initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..72d9d08cc --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/_reset_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_logging_global reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to logging global resource + junipernetworks.junos.junos_config: + lines: + - delete system syslog + - delete routing-instances + +- ansible.builtin.debug: + msg: "END junos_logging_global reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/backups/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/backups/empty_config.yaml new file mode 100644 index 000000000..c2d74d60a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/backups/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- ansible.builtin.debug: + msg: START junos_bgp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/deleted.yaml new file mode 100644 index 000000000..88e25a4db --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/deleted.yaml @@ -0,0 +1,99 @@ +--- +- ansible.builtin.debug: + msg: "START junos_logging_global deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.set_fact: + config: {} + - name: Pre gathered operation configuration + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: 65578 + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: 65578 + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: merged + - name: Delete all ospf config from the device + junipernetworks.junos.junos_logging_global: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_logging_global deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..2afd92339 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: + START junos_logging_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_logging_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_logging_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_logging_global: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_logging_global: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_logging_global: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..5c1e3dc41 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,152 @@ + + + + 18.4R1-S2.4 + + + + vagrant + 2000 + super-user + + $6$QiBkxU5N$QY11GzNuFs1sfY0OAacyJ/0WFmP9ciovUAmM425yYAo9OjccxvjWlEZNo8SeqCQxYeM86cfd9V.N1RiiHW2zN0 + + ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + + + + + + $1$nq.N1UsY$JxA/ESAj3KuXseXE597gg0 + + ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + + + + + + + + 830 + + + + + vsrx + + + 5m + 10 + + + + + user1 + + + + user2 + + any + + + + user + + + + + + host111 + + any + + + ^set* + + 1231 + ftp + field + 11.1.1.11 + inst11 + + ^delete + ^prompt + + + + + + + file101 + + + + file102 + + any + + + + + + + + file103 + ^set* + + 65578 + 10 + + + + + ^delete + ^prompt + + + any + + + + authorization + + + + ftp + + + + change-log + + + + + + + 33.33.33.33 + inst11 + 45 + + + + + https://ae1.juniper.net/junos/key_retrieval + + + + + + + + 172.16.17.0/24 + + + + 10.200.16.75 + + 65432 + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/gathered.yaml new file mode 100644 index 000000000..df3ebfd42 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/gathered.yaml @@ -0,0 +1,99 @@ +--- +- ansible.builtin.debug: + msg: START junos_logging_global gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Pre gathered operation configuration + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: merged + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_logging_global: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_logging_global gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/merged.yaml new file mode 100644 index 000000000..9bcfcd7c8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/merged.yaml @@ -0,0 +1,136 @@ +--- +- ansible.builtin.debug: + msg: "START junos_logging_global merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_logging_global: &merged + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + + routing_instance: "inst11" + + log_rotate_frequency: 45 + + source_address: "33.33.33.33" + + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_logging_global: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_logging_global: + config: + files: + - name: "file101" + allow_duplicates: true + - name: "file104" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_logging_global merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/overridden.yaml new file mode 100644 index 000000000..fbdc80f3b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/overridden.yaml @@ -0,0 +1,175 @@ +--- +- ansible.builtin.debug: + msg: "START junos_logging_global overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Pre overridden operation configuration + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: merged + + - name: Override configuration + junipernetworks.junos.junos_logging_global: &overridden + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + files: + - name: "file101" + allow_duplicates: true + - name: "file104" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: overridden + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_logging_global: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_logging_global overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/parsed.yaml new file mode 100644 index 000000000..e3cd47f98 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/parsed.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + START junos_logging_global parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided logging_global config to agnostic model + register: result + junipernetworks.junos.junos_logging_global: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_logging_global parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rendered.yaml new file mode 100644 index 000000000..b9555f5d4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rendered.yaml @@ -0,0 +1,29 @@ +--- +- ansible.builtin.debug: + msg: START junos_logging_global rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '1065578' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_logging_global rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/replaced.yaml new file mode 100644 index 000000000..fbfb074e3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/replaced.yaml @@ -0,0 +1,175 @@ +--- +- ansible.builtin.debug: + msg: "START junos_logging_global replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Pre replaced operation configuration + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: merged + + - name: Replace configuration + junipernetworks.junos.junos_logging_global: &replaced + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + files: + - name: "file101" + allow_duplicates: true + - name: "file104" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_logging_global: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_logging_global replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rtt.yml new file mode 100644 index 000000000..984a52afb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/tests/netconf/rtt.yml @@ -0,0 +1,141 @@ +--- +- ansible.builtin.debug: + msg: + START junos_logging_global round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + set: true + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - logging_global + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_logging_global: + config: + allow_duplicates: true + archive: + set: true + no_binary_data: true + files: 12 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "info" + change_log: + level: "info" + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_logging_global: + config: "{{ ansible_facts['network_resources']['logging_global'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_logging_global round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/vars/main.yaml new file mode 100644 index 000000000..ba51d3683 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging_global/vars/main.yaml @@ -0,0 +1,206 @@ +--- +merged: + before: {} + + after: + allow_duplicates: true + archive: + file_size: "5m" + files: 10 + no_binary_data: true + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info + updated: + allow_duplicates: true + archive: + no_binary_data: true + files: 10 + file_size: "5m" + no_world_readable: true + console: + any: + level: "info" + authorization: + level: "any" + change_log: + level: "critical" + ftp: + level: "none" + files: + - name: "file101" + allow_duplicates: true + - name: "file102" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + - name: "file104" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info +replaced: + after: + allow_duplicates: true + archive: + file_size: "5m" + files: 10 + no_binary_data: true + no_world_readable: true + files: + - name: "file101" + allow_duplicates: true + - name: "file104" + allow_duplicates: true + any: + level: "any" + structured_data: + set: true + - name: "file103" + archive: + no_binary_data: true + files: 10 + file_size: "65578" + no_world_readable: true + explicit_priority: true + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + hosts: + - name: host111 + exclude_hostname: true + allow_duplicates: true + any: + level: "any" + structured_data: + brief: true + facility_override: "ftp" + log_prefix: "field" + match: "^set*" + match_strings: + - "^delete" + - "^prompt" + port: 1231 + routing_instance: "inst11" + source_address: "11.1.1.11" + routing_instance: "inst11" + log_rotate_frequency: 45 + source_address: "33.33.33.33" + time_format: + millisecond: true + year: true + users: + - name: "user1" + allow_duplicates: true + - name: "user2" + allow_duplicates: true + any: + level: "any" + user: + level: info diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/cli.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/cli.yaml new file mode 100644 index 000000000..0637e8c16 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/cli.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect all cli test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + connection: local + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.network_cli + tags: + - network_cli diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/main.yaml new file mode 100644 index 000000000..aed90a6c6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: cli.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/changeport.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/changeport.yaml new file mode 100644 index 000000000..ae84d4b98 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/changeport.yaml @@ -0,0 +1,123 @@ +--- +- ansible.builtin.debug: + msg="START netconf/changeport.yaml on connection={{ ansible_connection + }}" + +- name: Setup + junipernetworks.junos.junos_netconf: + state: present + +- name: Change port + register: result + junipernetworks.junos.junos_netconf: + state: present + netconf_port: 8022 + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: idempotent tests + register: result + junipernetworks.junos.junos_netconf: + state: present + netconf_port: 8022 + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: wait for netconf port tcp/8022 to be open + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 8022 + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can communicate over 8022 + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 8022 + is_ignore_errors: false + +- name: wait for netconf port tcp/830 to be closed + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + state: stopped + with_inventory_hostnames: junos + +- name: Ensure we can NOT communicate over default port + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: true + +- ansible.builtin.assert: + that: + - result.failed == true + +- name: Set back netconf to default port + junipernetworks.junos.junos_netconf: + state: present + +- name: wait for netconf port tcp/830 to be open + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can communicate over netconf + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: false + +- name: Change port (check mode) + register: result + check_mode: true + junipernetworks.junos.junos_netconf: + state: present + netconf_port: 12345 + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: wait for netconf port tcp/12345 to be closed + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 12345 + state: stopped + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can NOT communicate over non-default port + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 12345 + is_ignore_errors: true + +- ansible.builtin.assert: + that: + - result.failed == true + +- name: Ensure we can communicate over default port + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: false + +- ansible.builtin.debug: msg="END netconf/changeport.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/netconf.yaml new file mode 100644 index 000000000..97cf4f3ec --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/cli/netconf.yaml @@ -0,0 +1,133 @@ +--- +- ansible.builtin.debug: msg="START netconf/netconf.yaml on connection={{ ansible_connection }}" + +- name: Ensure netconf is enabled + junipernetworks.junos.junos_netconf: + state: present + +- name: idempotent tests + register: result + junipernetworks.junos.junos_netconf: + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: wait for netconf port tcp/830 to be open + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can communicate over netconf + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: false + +- name: Disable netconf (check mode) + register: result + check_mode: true + junipernetworks.junos.junos_netconf: + state: absent + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: wait for netconf port tcp/830 to be open + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can communicate over netconf + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: false + +- name: Disable netconf + register: result + junipernetworks.junos.junos_netconf: + state: absent + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: idempotent tests + register: result + junipernetworks.junos.junos_netconf: + state: absent + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: wait for netconf port tcp/830 to be closed + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + state: stopped + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can NOT talk via netconf + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: true + +- ansible.builtin.assert: + that: + - result.failed == true + +- name: Enable netconf (check mode) + register: result + check_mode: true + junipernetworks.junos.junos_netconf: + state: present + +- ansible.builtin.assert: + that: + - result.changed == true + +- name: wait for netconf port tcp/830 to be closed + wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + state: stopped + with_inventory_hostnames: junos + +- name: Reset ansible connections + meta: reset_connection + +- name: Ensure we can NOT talk via netconf + ansible.builtin.include_tasks: "{{ role_path }}/tests/utils/junos_command.yaml" + vars: + ansible_connection: ansible.netcommon.netconf + ansible_port: 830 + is_ignore_errors: true + +- ansible.builtin.assert: + that: + - result.failed == true + +- name: re-enable netconf + junipernetworks.junos.junos_netconf: + state: present + +- ansible.builtin.debug: msg="END netconf/netconfg.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/utils/junos_command.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/utils/junos_command.yaml new file mode 100644 index 000000000..76fa9c4d6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_netconf/tests/utils/junos_command.yaml @@ -0,0 +1,6 @@ +--- +- name: run junos_command to check netconf connectivity + register: result + ignore_errors: "{{ is_ignore_errors }}" + junipernetworks.junos.junos_command: + rpcs: get-software-information diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/main.yaml new file mode 100644 index 000000000..a6fc560ad --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..dc07e5102 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_initial_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ntp_global initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to ntp global + junipernetworks.junos.junos_config: + lines: + - set routing-instances rt1 description "rt1" + - set routing-instances rt2 description "rt2" + +- ansible.builtin.debug: + msg: "END junos_ntp_global initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_populate_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_populate_config.yaml new file mode 100644 index 000000000..c42d5eb5b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_populate_config.yaml @@ -0,0 +1,21 @@ +--- +- name: Populate config + junipernetworks.junos.junos_config: + lines: + - "set system ntp boot-server 78.46.194.186" + - "set system ntp broadcast 172.16.255.255 key 50 ttl 200 version 3 routing-instance-name rt1" + - "set system ntp broadcast 192.16.255.255 key 50 ttl 200 version 3 routing-instance-name rt2" + - "set system ntp broadcast-client" + - "set system ntp multicast-client 224.0.0.1" + - "set system ntp interval-range 2" + - "set system ntp peer 78.44.194.186" + - "set system ntp peer 172.44.194.186 key 10000 prefer version 3" + - "set system ntp server 48.46.194.186" + - "set system ntp server 48.46.194.186 key 34 prefer routing-instance rt1 version 2" + - "set system ntp server 48.45.194.186 key 34 prefer version 2" + - "set system ntp source-address 172.45.194.186 routing-instance rt1" + - "set system ntp source-address 171.45.194.186 routing-instance rt2" + - "set system ntp trusted-key 2000" + - "set system ntp trusted-key 3000" + - "set system ntp threshold 300 action accept" + - "set system ntp trusted-key 3000" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..0c08a7ced --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/_reset_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ntp_global reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to ntp global resource + junipernetworks.junos.junos_config: + lines: + - delete system ntp + - delete routing-instances + +- ansible.builtin.debug: + msg: "END junos_ntp_global reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/backups/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/backups/empty_config.yaml new file mode 100644 index 000000000..c2d74d60a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/backups/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- ansible.builtin.debug: + msg: START junos_bgp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/deleted.yaml new file mode 100644 index 000000000..cd29f7ddb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/deleted.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ntp_global deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - ansible.builtin.set_fact: + config: {} + - name: Delete all ospf config from the device + junipernetworks.junos.junos_ntp_global: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ntp_global deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..53b90ed0a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- ansible.builtin.debug: + msg: START junos_ntp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ntp_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ntp_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ntp_global: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ntp_global: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ntp_global: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..6619c8d64 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,156 @@ + + + + 18.4R1-S2.4 + + + + vagrant + 2000 + super-user + + $6$QiBkxU5N$QY11GzNuFs1sfY0OAacyJ/0WFmP9ciovUAmM425yYAo9OjccxvjWlEZNo8SeqCQxYeM86cfd9V.N1RiiHW2zN0 + + ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + + + + + + $1$nq.N1UsY$JxA/ESAj3KuXseXE597gg0 + + ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key + + + + + + + + 830 + + + + + vsrx + + + * + + any + + + + + messages + + any + + + + authorization + + + + + interactive-commands + + interactive-commands + + + + + + + + https://ae1.juniper.net/junos/key_retrieval + + + + + 78.46.194.186 + + 2 + + + 78.44.194.186 + + + 172.44.194.186 + 10000 + 3 + + + + 48.46.194.186 + 34 + 2 + + rt1 + + + 48.45.194.186 + 34 + 2 + + + + 172.16.255.255 + rt1 + 50 + 3 + 200 + + + 192.16.255.255 + rt2 + 50 + 3 + 200 + + + +
224.0.0.1
+
+ 3000 + 2000 + + 300 + accept + + + 172.45.194.186 + rt1 + + + 171.45.194.186 + rt2 + +
+
+ + + fxp0 + + 0 + + + + + + + + + + + + rt1 + rt1 + + + rt2 + rt2 + + +
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/gathered.yaml new file mode 100644 index 000000000..b14ab74f8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/gathered.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: START junos_ntp_global gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_ntp_global: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_ntp_global gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/merged.yaml new file mode 100644 index 000000000..78e943cd6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/merged.yaml @@ -0,0 +1,101 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ntp_global merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ntp_global: &merged + config: + boot_server: "78.46.194.186" + broadcasts: + - address: "172.16.255.255" + key: "50" + ttl: 200 + version: 3 + routing_instance_name: "rt1" + - address: "192.16.255.255" + key: "50" + ttl: 200 + version: 3 + routing_instance_name: "rt2" + broadcast_client: true + interval_range: 2 + multicast_client: "224.0.0.1" + peers: + - peer: "78.44.194.186" + - peer: "172.44.194.186" + key_id: 10000 + prefer: true + version: 3 + servers: + - server: "48.46.194.186" + key_id: 34 + prefer: true + version: 2 + routing_instance: "rt1" + - server: "48.45.194.186" + key_id: 34 + prefer: true + version: 2 + source_addresses: + - source_address: "172.45.194.186" + routing_instance: "rt1" + - source_address: "171.45.194.186" + routing_instance: "rt2" + threshold: + value: 300 + action: "accept" + trusted_keys: + - key_id: 3000 + - key_id: 2000 + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ntp_global: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_ntp_global: + config: + interval_range: 3 + peers: + - peer: "172.44.194.188" + key_id: 10000 + prefer: true + version: 3 + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ntp_global merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/overridden.yaml new file mode 100644 index 000000000..81db02e3d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/overridden.yaml @@ -0,0 +1,47 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ntp_global overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_ntp_global: &overridden + config: + multicast_client: "224.0.0.1" + interval_range: 3 + peers: + - peer: "172.44.194.188" + key_id: 10000 + prefer: true + version: 3 + state: overridden + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ntp_global: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ntp_global overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/parsed.yaml new file mode 100644 index 000000000..821d2c13f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/parsed.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + START junos_ntp_global parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided ntp_global config to agnostic model + register: result + junipernetworks.junos.junos_ntp_global: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_ntp_global parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rendered.yaml new file mode 100644 index 000000000..ba768e131 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rendered.yaml @@ -0,0 +1,30 @@ +--- +- ansible.builtin.debug: + msg: START junos_ntp_global rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '2224.0.0.178.44.194.186172.44.194.186100003' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_ntp_global: + config: + interval_range: 2 + multicast_client: "224.0.0.1" + peers: + - peer: "78.44.194.186" + - peer: "172.44.194.186" + key_id: 10000 + prefer: true + version: 3 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_ntp_global rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/replaced.yaml new file mode 100644 index 000000000..fdca062c1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/replaced.yaml @@ -0,0 +1,47 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ntp_global replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_ntp_global: &replaced + config: + multicast_client: "224.0.0.1" + interval_range: 3 + peers: + - peer: "172.44.194.188" + key_id: 10000 + prefer: true + version: 3 + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ntp_global: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ntp_global replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rtt.yml new file mode 100644 index 000000000..8e24da5ff --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/tests/netconf/rtt.yml @@ -0,0 +1,105 @@ +--- +- ansible.builtin.debug: + msg: START junos_ntp_global round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_ntp_global: + config: + boot_server: "78.46.194.186" + broadcasts: + - address: "172.16.255.255" + key: "50" + ttl: 200 + version: 3 + routing_instance_name: "rt1" + - address: "192.16.255.255" + key: "50" + ttl: 200 + version: 3 + routing_instance_name: "rt2" + broadcast_client: true + interval_range: 2 + multicast_client: "224.0.0.1" + peers: + - peer: "78.44.194.186" + - peer: "172.44.194.186" + key_id: 10000 + prefer: true + version: 3 + servers: + - server: "48.46.194.186" + key_id: 34 + prefer: true + version: 2 + routing_instance: "rt1" + - server: "48.45.194.186" + key_id: 34 + prefer: true + version: 2 + source_addresses: + - source_address: "172.45.194.186" + routing_instance: "rt1" + - source_address: "171.45.194.186" + routing_instance: "rt2" + threshold: + value: 300 + action: "accept" + trusted_keys: + - key_id: 3000 + - key_id: 2000 + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - ntp_global + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_ntp_global: + config: + multicast_client: "224.0.0.1" + interval_range: 3 + peers: + - peer: "172.44.194.188" + key_id: 10000 + prefer: true + version: 3 + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_ntp_global: + config: "{{ ansible_facts['network_resources']['ntp_global'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_ntp_global round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/vars/main.yaml new file mode 100644 index 000000000..1122d40ae --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ntp_global/vars/main.yaml @@ -0,0 +1,104 @@ +--- +merged: + before: {} + + after: + boot_server: "78.46.194.186" + broadcast_client: true + broadcasts: + - address: "172.16.255.255" + key: "50" + routing_instance_name: "rt1" + ttl: 200 + version: 3 + - address: "192.16.255.255" + key: "50" + routing_instance_name: "rt2" + ttl: 200 + version: 3 + interval_range: 2 + multicast_client: "224.0.0.1" + peers: + - peer: "78.44.194.186" + - key_id: 10000 + peer: "172.44.194.186" + prefer: true + version: 3 + servers: + - key_id: 34 + prefer: true + routing_instance: "rt1" + server: "48.46.194.186" + version: 2 + - key_id: 34 + prefer: true + server: "48.45.194.186" + version: 2 + source_addresses: + - routing_instance: "rt1" + source_address: "172.45.194.186" + - routing_instance: "rt2" + source_address: "171.45.194.186" + threshold: + action: "accept" + value: 300 + trusted_keys: + - key_id: 2000 + - key_id: 3000 + + updated: + boot_server: "78.46.194.186" + broadcasts: + - address: "172.16.255.255" + key: "50" + ttl: 200 + version: 3 + routing_instance_name: "rt1" + - address: "192.16.255.255" + key: "50" + ttl: 200 + version: 3 + routing_instance_name: "rt2" + broadcast_client: true + interval_range: 3 + multicast_client: "224.0.0.1" + peers: + - peer: "78.44.194.186" + - peer: "172.44.194.186" + key_id: 10000 + prefer: true + version: 3 + - peer: "172.44.194.188" + key_id: 10000 + prefer: true + version: 3 + servers: + - server: "48.46.194.186" + key_id: 34 + prefer: true + version: 2 + routing_instance: "rt1" + - server: "48.45.194.186" + key_id: 34 + prefer: true + version: 2 + source_addresses: + - source_address: "172.45.194.186" + routing_instance: "rt1" + - source_address: "171.45.194.186" + routing_instance: "rt2" + threshold: + value: 300 + action: "accept" + trusted_keys: + - key_id: 2000 + - key_id: 3000 +replaced: + after: + interval_range: 3 + multicast_client: "224.0.0.1" + peers: + - peer: "172.44.194.188" + key_id: 10000 + prefer: true + version: 3 diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/main.yaml new file mode 100644 index 000000000..e9b22ba68 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: ["netconf"] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..41932e7dd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_initial_config.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv2 initial config on connection={{ ansible_connection }}" + +- name: Set initial configuration for ospf + junos_ospfv2: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + +- ansible.builtin.debug: + msg: "END junos_ospfv2 initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..6c3974c8f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/_reset_config.yaml @@ -0,0 +1,11 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv2 reset config on connection={{ ansible_connection }}" + +- name: Reset configuration for ospf and routing-options + junipernetworks.junos.junos_config: + lines: + - delete protocols ospf + - delete routing-options +- ansible.builtin.debug: + msg: "END junos_ospfv2 reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/deleted.yaml new file mode 100644 index 000000000..3318258e6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/deleted.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv2 deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Delete all ospf config from the device + junos_ospfv2: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ []|symmetric_difference(result.after) == [] }}" + + tags: deleted + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv2 deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..8d455dbaf --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv2 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv2: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv2: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Override with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv2: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv2: + running_config: + state: parsed + +- ansible.builtin.debug: + msg: result +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv2: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..01d8294e2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,32 @@ + + + + 18.4R1-S2.4 + + + + 0.0.0.200 + + so-0/0/0.1 + 3 + 5 + + + + 0.0.0.100 + + 200 + + + so-0/0/0.0 + 5 + 3 + + + + + + 10.200.16.7 + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/gathered.yaml new file mode 100644 index 000000000..304246381 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/gathered.yaml @@ -0,0 +1,50 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv2 gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_gathered_output: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ospfv2: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + state: merged + + - name: Gather OSPFv2 facts using gathered state + register: result + junipernetworks.junos.junos_ospfv2: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_gathered_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_ospfv2 gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/merged.yaml new file mode 100644 index 000000000..7207f62b6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/merged.yaml @@ -0,0 +1,57 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv2 merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + config: + - areas: + - area_id: 0.0.0.100 + interfaces: + - metric: 5 + name: so-0/0/0.0 + priority: 3 + stub: + default_metric: 200 + set: true + router_id: 10.200.16.75 + + - name: Merge the provided configuration with the exisiting running configuration + junos_ospfv2: &merged + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ospfv2: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv2 merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/overridden.yaml new file mode 100644 index 000000000..6cabbe25b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/overridden.yaml @@ -0,0 +1,64 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv2 overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + flood_reduction: true + passive: true + - area_id: 0.0.0.200 + interfaces: + - name: ge-1/1/0.0 + - name: ge-2/2/0.0 + + - name: Override Junos OSPF config + junos_ospfv2: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + flood_reduction: true + passive: true + - area_id: 0.0.0.200 + interfaces: + - name: ge-1/1/0.0 + - name: ge-2/2/0.0 + state: overridden + register: result + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv2 overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/parsed.yaml new file mode 100644 index 000000000..67e573c33 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/parsed.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: + START junos_ospfv2 parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - areas: + - area_id: 0.0.0.200 + interfaces: + - metric: 3 + name: so-0/0/0.1 + priority: 5 + - area_id: 0.0.0.100 + interfaces: + - metric: 5 + name: so-0/0/0.0 + priority: 3 + stub: + default_metric: 200 + set: true + router_id: 10.200.16.7 + +- name: Parse OSPFV2 running-config to agnostic model + register: result + junipernetworks.junos.junos_ospfv2: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_ospfv2 parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rendered.yaml new file mode 100644 index 000000000..8e123b746 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rendered.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv2 rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '0.0.0.200so-0/0/0.1530.0.0.100so-0/0/0.035200' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_ospfv2: + config: + - areas: + - area_id: 0.0.0.200 + interfaces: + - metric: 3 + name: so-0/0/0.1 + priority: 5 + - area_id: 0.0.0.100 + interfaces: + - metric: 5 + name: so-0/0/0.0 + priority: 3 + stub: + default_metric: 200 + set: true + router_id: 10.200.16.7 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + - result.changed == False + +- ansible.builtin.debug: + msg: END junos_ospfv2 rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/replaced.yaml new file mode 100644 index 000000000..5c7f1967d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/replaced.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv2 replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + + - name: Replace configuration + junos_ospfv2: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + state: replaced + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - "{{ config|symmetric_difference(result.after) == [] }}" + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv2 replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rtt.yaml new file mode 100644 index 000000000..7e8080a63 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf/tests/netconf/rtt.yaml @@ -0,0 +1,73 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv2 round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_ospfv2: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - ospf + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_ospfv2: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_ospfv2: + config: "{{ ansible_facts['network_resources']['ospfv2'] }}" + state: overridden + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] | symmetric_difference( revert['before'])\ + \ |length == 0 }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] | symmetric_difference( revert['after'])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_ospfv2 round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/main.yaml new file mode 100644 index 000000000..e9b22ba68 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: ["netconf"] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..8ee537f2c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_initial_config.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospf_interfaces initial config on connection={{ ansible_connection }}" + +- name: Set initial configuration for ospf interfaces + junipernetworks.junos.junos_ospf_interfaces: + config: + - router_id: "10.200.16.75" + name: "ge-0/0/2.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + state: merged + +- ansible.builtin.debug: + msg: "END junos_ospf_interfaces initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..8ed9385eb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml @@ -0,0 +1,11 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 reset config on connection={{ ansible_connection }}" + +- name: Reset configuration for ospf3 and routing-options + junipernetworks.junos.junos_config: + lines: + - delete protocols ospf + - delete routing-options +- ansible.builtin.debug: + msg: "END junos_ospfv3 reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/deleted.yaml new file mode 100644 index 000000000..4ac54eb97 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/deleted.yaml @@ -0,0 +1,69 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospf_interfaces deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_config: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + name: "ge-0/0/2.0" + router_id: "10.200.16.75" + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ospf_interfaces: &merged + config: + - router_id: "10.200.16.75" + name: "ge-0/0/3.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.3" + priority: 3 + metric: 5 + state: merged + - name: Delete single ospf interface configuration + junipernetworks.junos.junos_ospf_interfaces: + config: + - router_id: 10.200.16.75 + name: "ge-0/0/3.0" + state: deleted + register: result + + - ansible.builtin.debug: + var: result.after + + - ansible.builtin.debug: + var: config + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ expected_config|symmetric_difference(result.after) == [] }}" + + - ansible.builtin.set_fact: + expected_config: [] + + - name: Delete all ospf config from the device + junipernetworks.junos.junos_ospf_interfaces: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: deleted + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospf_interfaces deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..4b865a5ac --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/empty_config.yaml @@ -0,0 +1,50 @@ +--- +- ansible.builtin.debug: + msg: + START junos_ospf_interfaces empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospf_interfaces: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospf_interfaces: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospf_interfaces: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospf_interfaces: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parse_ospf_router_id.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parse_ospf_router_id.cfg new file mode 100644 index 000000000..750b3d814 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parse_ospf_router_id.cfg @@ -0,0 +1,23 @@ + + + + + + + 0.0.0.2 + + 200 + + + ge-0/0/2.0 + 5 + 3 + + + + + + 10.200.16.75 + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..dc2e6145e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,20 @@ + + + + + + + 0.0.0.2 + + 200 + + + ge-0/0/2.0 + 5 + 3 + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/gathered.yaml new file mode 100644 index 000000000..01e0c4b23 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/gathered.yaml @@ -0,0 +1,39 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospf_interfaces gathered integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_gathered_output: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + name: "ge-0/0/2.0" + router_id: "10.200.16.75" + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_ospf_interfaces: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_gathered_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_ospf_interfaces gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged.yaml new file mode 100644 index 000000000..5d7d1980c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged.yaml @@ -0,0 +1,56 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospf_interfaces merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + expected_config: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + name: "ge-0/0/2.0" + router_id: "10.200.16.75" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ospf_interfaces: &merged + config: + - router_id: "10.200.16.75" + name: "ge-0/0/2.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_config | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ospf_interfaces: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospf_interfaces merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged_update.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged_update.yaml new file mode 100644 index 000000000..067698e19 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/merged_update.yaml @@ -0,0 +1,66 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospf_interfaces merged update integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_config: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + name: "ge-0/0/2.0" + router_id: "10.200.16.75" + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.3" + priority: 3 + metric: 5 + name: "ge-0/0/3.0" + router_id: "10.200.16.75" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ospf_interfaces: &merged + config: + - router_id: "10.200.16.75" + name: "ge-0/0/3.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.3" + priority: 3 + metric: 5 + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_config | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ospf_interfaces: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged_update + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospf_interfaces merged update integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/overridden.yaml new file mode 100644 index 000000000..ad7df535d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/overridden.yaml @@ -0,0 +1,69 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospf_interfaces overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_config: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.1" + priority: 6 + metric: 7 + name: "ge-0/0/1.0" + router_id: "10.200.16.75" + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ospf_interfaces: &merged + config: + - router_id: "10.200.16.75" + name: "ge-0/0/3.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.3" + priority: 3 + metric: 5 + state: merged + - name: Override configuration + junipernetworks.junos.junos_ospf_interfaces: &overridden + config: + - router_id: "10.200.16.75" + name: "ge-0/0/1.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.1" + priority: 6 + metric: 7 + state: overridden + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_config | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Override the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ospf_interfaces: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospf_interfaces overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/parsed.yaml new file mode 100644 index 000000000..6c0b740f1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/parsed.yaml @@ -0,0 +1,57 @@ +--- +- ansible.builtin.debug: + msg: + START junos_ospf_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + metric: 5 + priority: 3 + name: "ge-0/0/2.0" + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_ospf_interfaces: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" + +- ansible.builtin.set_fact: + expected_parsed_output: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + metric: 5 + priority: 3 + name: "ge-0/0/2.0" + router_id: "10.200.16.75" + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_ospf_interfaces: + running_config: "{{ lookup('file', './fixtures/parse_ospf_router_id.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" + +- ansible.builtin.debug: + msg: + END junos_ospf_interfaces parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/rendered.yaml new file mode 100644 index 000000000..c837c8ba1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/rendered.yaml @@ -0,0 +1,31 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospf_interfaces rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '0.0.0.2ge-0/0/2.035' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_ospf_interfaces: + config: + - router_id: "10.200.16.75" + name: "ge-0/0/2.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.2" + priority: 3 + metric: 5 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_ospf_interfaces rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/replaced.yaml new file mode 100644 index 000000000..488f97906 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/replaced.yaml @@ -0,0 +1,46 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospf_interfaces replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_config: + - address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.1" + priority: 6 + metric: 7 + name: "ge-0/0/2.0" + router_id: "10.200.16.75" + + - name: Replace configuration + junipernetworks.junos.junos_ospf_interfaces: + config: + - router_id: "10.200.16.75" + name: "ge-0/0/2.0" + address_family: + - afi: "ipv4" + processes: + area: + area_id: "0.0.0.1" + priority: 6 + metric: 7 + state: replaced + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - "{{ expected_config|symmetric_difference(result.after) == [] }}" + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospf_interfaces replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/meta/main.yaml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/meta/main.yaml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/main.yaml new file mode 100644 index 000000000..e9b22ba68 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- name: Invoke netconf + ansible.builtin.include_tasks: netconf.yaml + tags: ["netconf"] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..36c3ef921 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_initial_config.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 initial config on connection={{ ansible_connection }}" + +- name: Set initial configuration for ospf + junipernetworks.junos.junos_ospfv3: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + +- ansible.builtin.debug: + msg: "END junos_ospfv3 initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..c5cab9852 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/_reset_config.yaml @@ -0,0 +1,11 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 reset config on connection={{ ansible_connection }}" + +- name: Reset configuration for ospf3 and routing-options + junipernetworks.junos.junos_config: + lines: + - delete protocols ospf3 + - delete routing-options +- ansible.builtin.debug: + msg: "END junos_ospfv3 reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/deleted.yaml new file mode 100644 index 000000000..b2733d48f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/deleted.yaml @@ -0,0 +1,56 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + + - name: Delete an area + junipernetworks.junos.junos_ospfv3: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + state: deleted + register: result + + - ansible.builtin.debug: + var: result.after + + - ansible.builtin.debug: + var: config + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - ansible.builtin.set_fact: + config: [] + + - name: Delete all ospf config from the device + junipernetworks.junos.junos_ospfv3: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: deleted + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv3 deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..b98618d17 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv3 empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv3: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv3: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv3: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_ospfv3: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..5f9a871ff --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,34 @@ + + + + + + + 0.0.0.100 + + 200 + + + so-0/0/0.0 + + 5 + 3 + + + + + 0.0.0.200 + + ge-1/1/0.0 + + + ge-2/2/0.0 + + + + + + 10.200.16.75 + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/gathered.yaml new file mode 100644 index 000000000..e8c32a8fa --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/gathered.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv3 gathered integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_gathered_output: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_ospfv3: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_gathered_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_ospfv3 gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/merged.yaml new file mode 100644 index 000000000..c0ff17516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/merged.yaml @@ -0,0 +1,57 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - metric: 5 + name: so-0/0/0.0 + priority: 3 + stub: + default_metric: 200 + set: true + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_ospfv3: &merged + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_ospfv3: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv3 merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/overridden.yaml new file mode 100644 index 000000000..552c80fa2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/overridden.yaml @@ -0,0 +1,64 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + flood_reduction: true + passive: true + - area_id: 0.0.0.200 + interfaces: + - name: ge-1/1/0.0 + - name: ge-2/2/0.0 + + - name: Override Junos OSPF config + junipernetworks.junos.junos_ospfv3: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + flood_reduction: true + passive: true + - area_id: 0.0.0.200 + interfaces: + - name: ge-1/1/0.0 + - name: ge-2/2/0.0 + state: overridden + register: result + + - name: Assert changed + ansible.builtin.assert: &changed + that: + - result.changed == True + - "{{ config|symmetric_difference(result.after) == [] }}" + + - name: Assert changed + ansible.builtin.assert: *changed + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv3 overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/parsed.yaml new file mode 100644 index 000000000..613ffd2c5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/parsed.yaml @@ -0,0 +1,40 @@ +--- +- ansible.builtin.debug: + msg: + START junos_ospfv3 parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + flood_reduction: true + passive: true + - area_id: 0.0.0.200 + interfaces: + - name: ge-1/1/0.0 + - name: ge-2/2/0.0 + +- name: Parse externally provided interfaces config to agnostic model + register: result + junipernetworks.junos.junos_ospfv3: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" +- ansible.builtin.debug: + msg: + END junos_ospfv3 parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/rendered.yaml new file mode 100644 index 000000000..9bb6a48c0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/rendered.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: START junos_ospfv3 rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '0.0.0.100so-0/0/0.0352000.0.0.200ge-1/1/0.0ge-2/2/0.0' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_ospfv3: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + stub: + default_metric: 200 + set: true + interfaces: + - name: so-0/0/0.0 + priority: 3 + metric: 5 + flood_reduction: true + passive: true + - area_id: 0.0.0.200 + interfaces: + - name: ge-1/1/0.0 + - name: ge-2/2/0.0 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_ospfv3 rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/replaced.yaml new file mode 100644 index 000000000..6750990f2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospfv3/tests/netconf/replaced.yaml @@ -0,0 +1,41 @@ +--- +- ansible.builtin.debug: + msg: "START junos_ospfv3 replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.200 + interfaces: + - name: ge-2/2/0.0 + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + + - name: Replace configuration + junipernetworks.junos.junos_ospfv3: + config: + - router_id: 10.200.16.75 + areas: + - area_id: 0.0.0.100 + interfaces: + - name: so-0/0/0.0 + state: replaced + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - "{{ config|symmetric_difference(result.after) == [] }}" + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_ospfv3 replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..280b43ff5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/_reset_config.yaml @@ -0,0 +1,10 @@ +--- +- ansible.builtin.debug: + msg: "START junos_prefix_lists reset config on connection={{ ansible_connection }}" + +- name: Reset the prefix lists configuration + junipernetworks.junos.junos_config: + lines: + - delete policy-options +- ansible.builtin.debug: + msg: "END junos_prefix_lists reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/deleted.yaml new file mode 100644 index 000000000..ee5dc577e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/deleted.yaml @@ -0,0 +1,78 @@ +--- +- ansible.builtin.debug: + msg: "START junos_prefix_lists deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + expected_deleted_output: + - dynamic_db: true + name: Test1 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &merged + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test1 + dynamic_db: true + - name: Test2 + address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + state: merged + + - name: Delete existing prefix list configuration identified with name + junipernetworks.junos.junos_prefix_lists: &deleted + config: + - name: Test2 + - name: Internal + state: deleted + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_deleted_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete the existing running configuration (IDEMPOTENT) + junos_prefix_lists: *deleted + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - ansible.builtin.set_fact: + expected_deleted_output: [] + + - name: Merge the existing config with provided configuration + junos_prefix_lists: *merged + register: result + + - name: Delete complete existing bgp address family configuration + junipernetworks.junos.junos_prefix_lists: &deleted_res + config: + state: deleted + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_deleted_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + tags: deleted + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_prefix_lists deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..c8df9e36e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/empty_config.yaml @@ -0,0 +1,62 @@ +--- +- ansible.builtin.debug: + msg: + START junos_prefix_lists empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_prefix_lists: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_prefix_lists: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Override with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_prefix_lists: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_prefix_lists: + running_config: + state: parsed + +- ansible.builtin.debug: + msg: result +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_prefix_lists: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..3ed5f856f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,21 @@ + + + + 18.4R1-S2.4 + + + 64510 + + + 64500 + + + 172.16.1.16/28 + + + 172.16.1.32/28 + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/gathered.yaml new file mode 100644 index 000000000..18c9d6f8c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/gathered.yaml @@ -0,0 +1,56 @@ +--- +- ansible.builtin.debug: + msg: START junos_prefix_lists gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + expected_gathered_output: + - address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + name: Internal + - dynamic_db: true + name: Test1 + - address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + name: Test2 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &merged + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test1 + dynamic_db: true + - name: Test2 + address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + state: merged + register: result + + - name: Gather prefix-lists facts using gathered state + register: result + junipernetworks.junos.junos_prefix_lists: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + - "{{ expected_gathered_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_prefix_lists gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/merged.yaml new file mode 100644 index 000000000..140601233 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/merged.yaml @@ -0,0 +1,93 @@ +--- +- ansible.builtin.debug: + msg: "START junos_prefix_lists merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + expected_merged_output: + - address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + name: Internal + - dynamic_db: true + name: Test1 + - address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + name: Test2 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &merged + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test1 + dynamic_db: true + - name: Test2 + address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + state: merged + register: result + + - name: Assert the correct configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_prefix_lists: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - ansible.builtin.set_fact: + expected_merged_output: + - address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - 172.16.1.48/28 + name: Internal + - dynamic_db: true + name: Test1 + - address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + name: Test2 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - 172.16.1.48/28 + state: merged + register: result + + - name: Assert the correct configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_prefix_lists merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/overridden.yaml new file mode 100644 index 000000000..5f1b7970d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/overridden.yaml @@ -0,0 +1,70 @@ +--- +- ansible.builtin.debug: + msg: "START junos_prefix_lists overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + expected_overridden_output: + - address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + name: Internal + - address_prefixes: + - 172.16.2.48/28 + - 172.16.3.32/28 + name: Test2 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &merged + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test1 + dynamic_db: true + - name: Test2 + address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + state: merged + + - name: Override the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &overridden + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test2 + address_prefixes: + - 172.16.3.32/28 + - 172.16.2.48/28 + state: overridden + register: result + + - name: Assert the correct configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_overridden_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Override existing running prefix lists configuration with provided (IDEMPOTENT) + junos_prefix_lists: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_prefix_lists overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/parsed.yaml new file mode 100644 index 000000000..18fec21b7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/parsed.yaml @@ -0,0 +1,30 @@ +--- +- ansible.builtin.debug: + msg: + START junos_prefix_lists parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: "64510" + - address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + dynamic_db: true + name: "64500" + +- name: Parse externally provided prefix_lists config to agnostic model + register: result + junipernetworks.junos.junos_prefix_lists: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output | symmetric_difference(result['parsed']) |length\ + \ == 0 }}" +- ansible.builtin.debug: + msg: + END junos_prefix_lists parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/rendered.yaml new file mode 100644 index 000000000..05650bfa7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/rendered.yaml @@ -0,0 +1,34 @@ +--- +- ansible.builtin.debug: + msg: START junos_prefix_lists rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'Internal172.16.1.16/28172.16.1.32/28Test1Test2172.16.2.16/28172.16.2.32/28172.16.2.48/28' +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_prefix_lists: + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test1 + dynamic_db: true + - name: Test2 + address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - result.changed == False + - "{{ expected_rendered_output | symmetric_difference(result['rendered']) |length\ + \ == 0 }}" + +- ansible.builtin.debug: + msg: END junos_prefix_lists rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/replaced.yaml new file mode 100644 index 000000000..375813c1d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_prefix_lists/tests/netconf/replaced.yaml @@ -0,0 +1,72 @@ +--- +- ansible.builtin.debug: + msg: "START junos_prefix_lists replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.set_fact: + expected_replaced_output: + - address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + name: Internal + - dynamic_db: true + name: Test1 + - address_prefixes: + - 172.16.2.48/28 + - 172.16.3.32/28 + name: Test2 + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &merged + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test1 + dynamic_db: true + - name: Test2 + address_prefixes: + - 172.16.2.16/28 + - 172.16.2.32/28 + - 172.16.2.48/28 + state: merged + + - name: Replace the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_prefix_lists: &replaced + config: + - name: Internal + address_prefixes: + - 172.16.1.16/28 + - 172.16.1.32/28 + - name: Test2 + address_prefixes: + - 172.16.3.32/28 + - 172.16.2.48/28 + state: replaced + register: result + + - name: Assert the correct configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_replaced_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Replace existing running prefix lists configuration with provided (IDEMPOTENT) + junos_prefix_lists: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_prefix_lists replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..c2ffc16ea --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_initial_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances reset config on connection={{ ansible_connection }}" + +- name: Configure policy options w.r.t routing-instances + junipernetworks.junos.junos_config: + lines: + - set policy-options policy-statement test-policy term t1 then reject + - set policy-options policy-statement test-policy-1 term t1 then reject + +- ansible.builtin.debug: + msg: "END junos_routing_instances reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..dd2e4faa8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/_reset_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to bgp address family resource + junipernetworks.junos.junos_config: + lines: + - delete routing-instances + - delete policy-options + +- ansible.builtin.debug: + msg: "END junos_routing_instances reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/deleted.yaml new file mode 100644 index 000000000..e759b7c97 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/deleted.yaml @@ -0,0 +1,84 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_deleted_output: + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_routing_instances: &merged + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + state: merged + + - name: Delete existing configuration with running configuration + junipernetworks.junos.junos_routing_instances: &deleted + config: + - name: "test" + state: deleted + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_deleted_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Delete the existing running configuration (IDEMPOTENT) + junos_routing_instances: *deleted + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - ansible.builtin.set_fact: + expected_deleted_rints_output: [] + + - name: Merge the existing config with provided configuration + junos_routing_instances: *merged + register: result + + - name: Delete complete existing bgp address family configuration + junipernetworks.junos.junos_routing_instances: &deleted_res + config: + state: deleted + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_deleted_rints_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + tags: deleted + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_instances deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..2d4c4b63d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/empty_config.yaml @@ -0,0 +1,62 @@ +--- +- ansible.builtin.debug: + msg: + START junos_routing_instances empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_instances: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_instances: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Override with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_instances: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_instances: + running_config: + state: parsed + +- ansible.builtin.debug: + msg: result +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_instances: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..bbbb40400 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,30 @@ + + + + 18.4R1-S2.4 + + + forwardinst + Configured by Ansible Content Team + forwarding + + + test + vrf + + gr-0/0/0.0 + + + sp-0/0/0.0 + + + 10.58.255.1:37 + + test-policy + test-policy + test-policy-1 + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/gathered.yaml new file mode 100644 index 000000000..a311f835b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/gathered.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: START junos_routing_instances gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_gathered_output: + - description: "Configured by Ansible Content Team" + name: "forwardinst" + type: "forwarding" + + - connector_id_advertise: true + interfaces: + - name: "gr-0/0/0.0" + - name: "sp-0/0/0.0" + name: "test" + route_distinguisher: "10.58.255.1:37" + type: "vrf" + vrf_exports: + - "test-policy" + - "test-policy-1" + vrf_imports: + - "test-policy" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_routing_instances: &merged + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + state: merged + + - name: Gather bgp address family facts using gathered state + register: result + junipernetworks.junos.junos_routing_instances: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + "{{ expected_gathered_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_routing_instances gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/merged.yaml new file mode 100644 index 000000000..35d1168b4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/merged.yaml @@ -0,0 +1,71 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_merged_output: + - description: "Configured by Ansible Content Team" + name: "forwardinst" + type: "forwarding" + + - connector_id_advertise: true + interfaces: + - name: "gr-0/0/0.0" + - name: "sp-0/0/0.0" + name: "test" + route_distinguisher: "10.58.255.1:37" + type: "vrf" + vrf_exports: + - "test-policy" + - "test-policy-1" + vrf_imports: + - "test-policy" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_routing_instances: &merged + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + state: merged + register: result + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_routing_instances: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_instances merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/overridden.yaml new file mode 100644 index 000000000..ea49cc6ea --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/overridden.yaml @@ -0,0 +1,111 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_overridden_output: + - description: "Configured by Ansible Content Team" + name: "forwardinst" + type: "forwarding" + - connector_id_advertise: true + interfaces: + - name: "gr-0/0/0.0" + - name: "sp-0/0/0.0" + name: "test" + route_distinguisher: "10.58.255.1:37" + type: "vrf" + vrf_exports: + - "test-policy" + - "test-policy-1" + vrf_imports: + - "test-policy" + - name: "vtest1" + type: "virtual-router" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_routing_instances: &merged + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + state: merged + + - name: Replace existing configuration with running configuration + junipernetworks.junos.junos_routing_instances: &replaced + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.57.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: false + description: "Configured by Ansible Content Team" + state: replaced + + - name: Override existing configuration with running configuration + junipernetworks.junos.junos_routing_instances: &overridden + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + - name: "vtest1" + type: "virtual-router" + state: overridden + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_overridden_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Override the existing running configuration with the provided configuration (IDEMPOTENT) + junos_routing_instances: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_instances overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/parsed.yaml new file mode 100644 index 000000000..e88c5730d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/parsed.yaml @@ -0,0 +1,39 @@ +--- +- ansible.builtin.debug: + msg: + START junos_routing_instances parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - description: "Configured by Ansible Content Team" + name: "forwardinst" + type: "forwarding" + + - connector_id_advertise: true + interfaces: + - name: "gr-0/0/0.0" + - name: "sp-0/0/0.0" + name: "test" + route_distinguisher: "10.58.255.1:37" + type: "vrf" + vrf_exports: + - "test-policy" + - "test-policy-1" + vrf_imports: + - "test-policy" + +- name: Parse externally provided routing_instances config to agnostic model + register: result + junipernetworks.junos.junos_routing_instances: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_routing_instances parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/rendered.yaml new file mode 100644 index 000000000..60081f955 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/rendered.yaml @@ -0,0 +1,37 @@ +--- +- ansible.builtin.debug: + msg: + START junos_routing_instances rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'testvrfsp-0/0/0.0gr-0/0/0.010.58.255.1:37test-policytest-policytest-policy-1forwardinstConfigured by Ansible Content Teamforwarding' +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_routing_instances: + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_routing_instances rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/replaced.yaml new file mode 100644 index 000000000..33e88d048 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_instances/tests/netconf/replaced.yaml @@ -0,0 +1,87 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_replaced_output: + - description: "Configured by Ansible Content Team" + name: "forwardinst" + type: "forwarding" + + - description: "Configured by Ansible Content Team" + interfaces: + - name: "gr-0/0/0.0" + - name: "sp-0/0/0.0" + name: "test" + route_distinguisher: "10.57.255.1:37" + type: "vrf" + vrf_exports: + - "test-policy" + vrf_imports: + - "test-policy" + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_routing_instances: &merged + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.58.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + - "test-policy-1" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: true + - name: "forwardinst" + type: "forwarding" + description: "Configured by Ansible Content Team" + state: merged + + - name: Replace existing configuration with running configuration + junipernetworks.junos.junos_routing_instances: &replaced + config: + - name: "test" + type: "vrf" + route_distinguisher: "10.57.255.1:37" + vrf_imports: + - "test-policy" + vrf_exports: + - "test-policy" + interfaces: + - name: "sp-0/0/0.0" + - name: "gr-0/0/0.0" + connector_id_advertise: false + description: "Configured by Ansible Content Team" + state: replaced + register: result + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ expected_replaced_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_routing_instances: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_instances replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_populate_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_populate_config.yaml new file mode 100644 index 000000000..5b2bacc96 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_populate_config.yaml @@ -0,0 +1,8 @@ +--- +- name: Populate config + junipernetworks.junos.junos_config: + lines: + - "set routing-options autonomous-system asdot-notation" + - "set routing-options autonomous-system loops 4" + - "set routing-options autonomous-system 2" + - "set routing-options router-id 12.12.12.12" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..46c861644 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/_reset_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_options reset config on connection={{ ansible_connection }}" + +- name: Reset routing options configuration + junipernetworks.junos.junos_config: + lines: + - delete routing-options router-id + - delete routing-options autonomous-system + +- ansible.builtin.debug: + msg: "END junos_routing_options reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/deleted.yaml new file mode 100644 index 000000000..bf5a7906b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/deleted.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_options deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - ansible.builtin.set_fact: + config: {} + - name: Delete all ospf config from the device + junipernetworks.junos.junos_routing_options: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_options deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..3065f768f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: + START junos_routing_options empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_options: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_options: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_options: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_options: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_routing_options: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..c430edf7f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,14 @@ + + + + 18.4R1-S2.4 + + 12.12.12.12 + + 2 + 4 + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/gathered.yaml new file mode 100644 index 000000000..cc2369a2b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/gathered.yaml @@ -0,0 +1,24 @@ +--- +- ansible.builtin.debug: + msg: START junos_routing_options gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_routing_options: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['updated'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_routing_options gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/merged.yaml new file mode 100644 index 000000000..48b4fad6f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/merged.yaml @@ -0,0 +1,59 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_options merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_routing_options: &merged + config: + autonomous_system: + as_number: 2 + asdot_notation: true + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_routing_options: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_routing_options: + config: + autonomous_system: + as_number: 2 + loops: 4 + router_id: "12.12.12.12" + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_options merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/overridden.yaml new file mode 100644 index 000000000..63d5e08dd --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/overridden.yaml @@ -0,0 +1,44 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_options overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_routing_options: &overridden + config: + autonomous_system: + as_number: 1 + asdot_notation: true + router_id: "10.10.10.10" + + state: overridden + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['updated'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_routing_options: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_options overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/parsed.yaml new file mode 100644 index 000000000..04e98a0a6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/parsed.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + START junos_routing_options parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided routing_options config to agnostic model + register: result + junipernetworks.junos.junos_routing_options: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['updated'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_routing_options parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rendered.yaml new file mode 100644 index 000000000..6429cb1ca --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rendered.yaml @@ -0,0 +1,27 @@ +--- +- ansible.builtin.debug: + msg: START junos_routing_options rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: '2412.12.12.12' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_routing_options: + config: + autonomous_system: + as_number: 2 + asdot_notation: true + loops: 4 + router_id: 12.12.12.12 + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_routing_options rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/replaced.yaml new file mode 100644 index 000000000..60c0c9aff --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/replaced.yaml @@ -0,0 +1,44 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_options overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_routing_options: &replaced + config: + autonomous_system: + as_number: 1 + asdot_notation: true + router_id: "10.10.10.10" + + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['updated'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_routing_options: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_routing_options overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rtt.yml new file mode 100644 index 000000000..b23153fd7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/tests/netconf/rtt.yml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: + START junos_routing_options round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_routing_options: + config: + autonomous_system: + as_number: 2 + asdot_notation: true + lo ops: 4 + router_id: 12.12.12.12 + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - routing_options + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_routing_options: + config: + autonomous_system: + as_number: 1 + asdot_notation: true + router_id: "10.10.10.10" + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_routing_options: + config: "{{ ansible_facts['network_resources']['routing_options'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_routing_options round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/vars/main.yaml new file mode 100644 index 000000000..d9e9d26f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_routing_options/vars/main.yaml @@ -0,0 +1,21 @@ +--- +merged: + before: {} + + after: + autonomous_system: + as_number: "2" + asdot_notation: true + + updated: + autonomous_system: + as_number: "2" + asdot_notation: true + loops: 4 + router_id: "12.12.12.12" +replaced: + after: + autonomous_system: + as_number: "1" + asdot_notation: true + router_id: "10.10.10.10" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/main.yaml new file mode 100644 index 000000000..ac951c8f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/netconf.yaml new file mode 100644 index 000000000..3fa0553b5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + register: test_cases + connection: local + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tests/netconf/rpc.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tests/netconf/rpc.yaml new file mode 100644 index 000000000..3036980c8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_rpc/tests/netconf/rpc.yaml @@ -0,0 +1,69 @@ +--- +- ansible.builtin.debug: msg="START netconf/rpc.yaml on connection={{ ansible_connection }}" + +- name: Execute RPC on device + register: result + junipernetworks.junos.junos_rpc: + rpc: get-interface-information + +- ansible.builtin.assert: + that: + - result.changed == false + - "'\nlo0\n' in result['xml']" + - "'\nem0\n' not in result['xml']" + - "'\fxp0\n' not in result['xml']" + +- name: Execute RPC on device and get output in text format + register: result + junipernetworks.junos.junos_rpc: + rpc: get-interface-information + output: text + +- ansible.builtin.assert: + that: + - result.changed == false + - result.output is defined + - result.output_lines is defined + - "'Physical interface' in result['output']" + +- name: Execute RPC on device and get output in json format + register: result + junipernetworks.junos.junos_rpc: + rpc: get-interface-information + output: json + args: + interface-name: lo0 + media: true + +- ansible.builtin.assert: + that: + - result.changed == false + - result.output is defined + - result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] + == "lo0" + +- name: Execute invalid RPC + register: result + ignore_errors: true + junipernetworks.junos.junos_rpc: + rpc: show-interface-information + +- ansible.builtin.assert: + that: + - result.failed == true + +- ansible.builtin.debug: msg="END netconf/rpc.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..11b82c1a4 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_initial_config.yaml @@ -0,0 +1,37 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies initial config on connection={{ ansible_connection }}" + +- name: Generate ssl certificates for ssl proxy profile-name + junipernetworks.junos.junos_command: + commands: + - request security pki generate-key-pair certificate-id SECURITY-cert size 2048 type rsa + - request security pki local-certificate generate-self-signed certificate-id SECURITY-cert domain-name labs.abc.net subject DC=mydomain.net,L=Sunnyvale,O=Mydomain,OU=LAB,CN=SECURITY email lab@labs.abc.net add-ca-constraint + +- name: Configure basic config relevant to security policies + junipernetworks.junos.junos_config: + lines: + - set class-of-service application-traffic-control rule-sets test_traffic_control rule test_rule match application-known + - set class-of-service application-traffic-control rule-sets test_traffic_control rule test_rule then log + - set security address-book global address a1 200.0.113.0/24 + - set security address-book global address a2 201.0.113.0/24 + - set security address-book global address a3 202.0.113.0/24 + - set security address-book global address a4 203.0.113.0/24 + - set security dynamic-application profile test_dyn_app redirect-message type custom-text content hello_world + - set security gprs gtp profile gtp1 + - set interfaces ge-0/0/0 unit 0 family inet address 200.0.113.1/24 + - set interfaces ge-0/0/1 unit 0 family inet address 201.0.113.1/24 + - set interfaces ge-0/0/2 unit 0 family inet address 202.0.113.1/24 + - set security zones security-zone one interfaces ge-0/0/0 + - set security zones security-zone two interfaces ge-0/0/1 + - set security zones security-zone three interfaces ge-0/0/2 + - set services icap-redirect profile test_icap server test_icap_server host 10.10.10.11 + - set services user-identification device-information end-user-profile profile-name test_end_user_profile attribute device-identity string Windows + - set services user-identification device-information end-user-profile profile-name test_end_user_profile domain-name test_domain + - set services ssl proxy profile SECURITY-SSL-PROXY root-ca SECURITY-cert + - set access profile WEBAUTH client FWClient1 firewall-user password pwd + - set access firewall-authentication web-authentication default-profile WEBAUTH + - set services ssl termination profile test_ssl_term server-certificate SECURITY-cert + +- ansible.builtin.debug: + msg: "END junos_security_policies initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_populate_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_populate_config.yaml new file mode 100644 index 000000000..b32dc1af8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_populate_config.yaml @@ -0,0 +1,53 @@ +--- +- name: Populate config + junipernetworks.junos.junos_config: + lines: + - set security policies from-zone one to-zone two policy test_policy_1 match source-address a1 + - set security policies from-zone one to-zone two policy test_policy_1 match source-address a3 + - set security policies from-zone one to-zone two policy test_policy_1 match destination-address a2 + - set security policies from-zone one to-zone two policy test_policy_1 match destination-address a4 + - set security policies from-zone one to-zone two policy test_policy_1 match application junos-dhcp-relay + - set security policies from-zone one to-zone two policy test_policy_1 match application junos-finger + - set security policies from-zone one to-zone two policy test_policy_1 match source-identity authenticated-user + - set security policies from-zone one to-zone two policy test_policy_1 match source-identity unknown-user + - set security policies from-zone one to-zone two policy test_policy_1 match source-end-user-profile test_end_user_profile + - set security policies from-zone one to-zone two policy test_policy_1 match source-address-excluded + - set security policies from-zone one to-zone two policy test_policy_1 match destination-address-excluded + - set security policies from-zone one to-zone two policy test_policy_1 match dynamic-application any + - set security policies from-zone one to-zone two policy test_policy_1 match url-category Enhanced_Web_Chat + - set security policies from-zone one to-zone two policy test_policy_1 then deny + - set security policies from-zone one to-zone two policy test_policy_1 then log session-close + - set security policies from-zone one to-zone two policy test_policy_1 then count + - set security policies from-zone one to-zone two policy test_policy_2 match source-address a1 + - set security policies from-zone one to-zone two policy test_policy_2 match destination-address any-ipv6 + - set security policies from-zone one to-zone two policy test_policy_2 match application any + - set security policies from-zone one to-zone two policy test_policy_2 then reject + - set security policies from-zone one to-zone two policy test_policy_2 then reject profile test_dyn_app + - set security policies from-zone one to-zone two policy test_policy_2 then reject ssl-proxy profile-name SECURITY-SSL-PROXY + - set security policies from-zone one to-zone three policy test_policy_3 match source-address a1 + - set security policies from-zone one to-zone three policy test_policy_3 match destination-address a2 + - set security policies from-zone one to-zone three policy test_policy_3 match application any + - set security policies from-zone one to-zone three policy test_policy_3 then permit application-services application-traffic-control rule-set test_traffic_control + - set security policies from-zone one to-zone three policy test_policy_3 then permit application-services gprs-gtp-profile gtp1 + - set security policies from-zone one to-zone three policy test_policy_3 then permit application-services icap-redirect test_icap + - set security policies from-zone one to-zone three policy test_policy_3 then permit application-services reverse-redirect-wx + - set security policies from-zone one to-zone three policy test_policy_3 then permit application-services uac-policy + - set security policies from-zone one to-zone three policy test_policy_3 then permit destination-address drop-untranslated + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication pass-through auth-user-agent Opera1 + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication pass-through auth-only-browser + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication push-to-identity-management + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication user-firewall access-profile WEBAUTH + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication user-firewall auth-only-browser + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication user-firewall auth-user-agent Opera1 + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication user-firewall web-redirect-to-https + - set security policies from-zone one to-zone three policy test_policy_3 then permit firewall-authentication web-authentication client-match FWClient1 + - set security policies from-zone one to-zone three policy test_policy_3 then permit tcp-options initial-tcp-mss 64 + - set security policies from-zone one to-zone three policy test_policy_3 then permit tcp-options window-scale + - set security policies global policy test_glob_1 match source-address any-ipv6 + - set security policies global policy test_glob_1 match destination-address any-ipv6 + - set security policies global policy test_glob_1 match application any + - set security policies global policy test_glob_1 then deny + - set security policies global policy test_glob_2 match source-address any-ipv6 + - set security policies global policy test_glob_2 match destination-address any-ipv6 + - set security policies global policy test_glob_2 match application any + - set security policies global policy test_glob_2 then deny diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..746e64090 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/_reset_config.yaml @@ -0,0 +1,22 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to security policies resources + junipernetworks.junos.junos_config: + lines: + - delete security + - delete services + - delete class-of-service + - delete access + - delete interfaces ge-0/0/0 + - delete interfaces ge-0/0/1 + - delete interfaces ge-0/0/2 + +- name: Reset the generated security certificates + junipernetworks.junos.junos_command: + commands: + - clear security pki local-certificate all + +- ansible.builtin.debug: + msg: "END junos_security_policies reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/deleted.yaml new file mode 100644 index 000000000..caf0ec02a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/deleted.yaml @@ -0,0 +1,27 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - ansible.builtin.set_fact: + config: {} + + - name: Delete all security policies from the device + junipernetworks.junos.junos_security_policies: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..c4e646fa6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/fixtures/parsed.xml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/fixtures/parsed.xml new file mode 100644 index 000000000..48895bce7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/fixtures/parsed.xml @@ -0,0 +1,301 @@ + + + + 18.4R1-S3.1 + + + + + test_ssl_term + SECURITY-cert + + + + + SECURITY-SSL-PROXY + SECURITY-cert + + + + + + test_icap + + test_icap_server + 10.10.10.11 + + + + + + + + test_end_user_profile + test_domain + + device-identity + Windows + + + + + + + + + global +
+ a1 + 200.0.113.0/24 +
+
+ a2 + 201.0.113.0/24 +
+
+ a3 + 202.0.113.0/24 +
+
+ a4 + 203.0.113.0/24 +
+
+ + + test_dyn_app + + + + hello_world + + + + + + + + one + two + + test_policy_1 + + a1 + a3 + a2 + a4 + + + junos-dhcp-relay + junos-finger + authenticated-user + unknown-user + + test_end_user_profile + + any + Enhanced_Web_Chat + + + + + + + + + + + test_policy_2 + + a1 + any-ipv6 + any + + + + test_dyn_app + + SECURITY-SSL-PROXY + + + + + + + one + three + + test_policy_3 + + a1 + a2 + any + + + + + + FWClient1 + + + + + + + + gtp1 + + test_icap + + test_traffic_control + + + + + 64 + + + + + + + + + test_glob_1 + + any-ipv6 + any-ipv6 + any + + + + + + + test_glob_2 + + any-ipv6 + any-ipv6 + any + + + + + + + + + + one + + ge-0/0/0.0 + + + + two + + ge-0/0/1.0 + + + + three + + ge-0/0/2.0 + + + + + + + gtp1 + + + +
+ + + ge-0/0/0 + + 0 + + +
+ 200.0.113.1/24 +
+
+
+
+
+ + ge-0/0/1 + + 0 + + +
+ 201.0.113.1/24 +
+
+
+
+
+ + ge-0/0/2 + + 0 + + +
+ 202.0.113.1/24 +
+
+
+
+
+ + fxp0 + + 0 + + + + + + + +
+ + + + test_traffic_control + + test_rule + + + + + + + + + + + + + WEBAUTH + + FWClient1 + + $9$kq5Ftu1cSe + + + + + + WEBAUTH + + + +
+ +
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/gathered.yaml new file mode 100644 index 000000000..585837f36 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/gathered.yaml @@ -0,0 +1,31 @@ +--- +- ansible.builtin.debug: + msg: START junos_security_policies gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Gather security policies facts using gathered state + register: result + junipernetworks.junos.junos_security_policies: + state: gathered + + - ansible.builtin.debug: + msg: "{{ result['gathered'] }}" + + - ansible.builtin.debug: + msg: "{{ merged['after'] }}" + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_security_policies gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/merged.yaml new file mode 100644 index 000000000..4b8a5915d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/merged.yaml @@ -0,0 +1,171 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_security_policies: &merged + config: + from_zones: + - name: one + to_zones: + - name: two + policies: + - match: + application: + names: + - junos-dhcp-relay + - junos-finger + destination_address: + addresses: + - a2 + - a4 + destination_address_excluded: true + dynamic_application: + names: + - any + source_address: + addresses: + - a1 + - a3 + source_address_excluded: true + source_end_user_profile: test_end_user_profile + source_identity: + authenticated_user: true + unknown_user: true + url_category: + names: + - Enhanced_Web_Chat + name: test_policy_1 + then: + count: true + deny: true + log: + session_close: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + name: test_policy_2 + then: + reject: + enable: true + profile: test_dyn_app + ssl_proxy: + enable: true + profile_name: SECURITY-SSL-PROXY + - name: three + policies: + - match: + application: + any: true + destination_address: + addresses: + - a2 + source_address: + addresses: + - a1 + name: test_policy_3 + then: + permit: + application_services: + application_traffic_control_rule_set: test_traffic_control + gprs_gtp_profile: gtp1 + icap_redirect: test_icap + reverse_redirect_wx: "True" + uac_policy: + enable: true + firewall_authentication: + push_to_identity_management: true + web_authentication: + - FWClient1 + tcp_options: + initial_tcp_mss: 64 + window_scale: true + global: + policies: + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_1 + then: + deny: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_2 + then: + deny: true + + state: merged + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_security_policies: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with provided configuration + junipernetworks.junos.junos_security_policies: + config: + global: + policies: + - name: test_glob_3 + description: test update + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any: true + then: + deny: true + state: merged + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/overridden.yaml new file mode 100644 index 000000000..fcb34c0b0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/overridden.yaml @@ -0,0 +1,53 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_security_policies: &overridden + config: + global: + policies: + - description: test update + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any: true + name: test_glob_3 + then: + deny: true + state: overridden + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result['changed'] == True + - "{{ replaced['after'] == result['after'] }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_security_policies: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/parsed.yaml new file mode 100644 index 000000000..08e14d1b8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/parsed.yaml @@ -0,0 +1,23 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided security_policies config to agnostic model + register: result + junipernetworks.junos.junos_security_policies: + running_config: "{{ lookup('file', './fixtures/parsed.xml') }}" + state: parsed + +- ansible.builtin.debug: + msg: "{{ result['parsed'] }}" + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_security_policies parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rendered.yaml new file mode 100644 index 000000000..acb1b00e6 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rendered.yaml @@ -0,0 +1,124 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'onetwotest_policy_1a1a3a2a4junos-dhcp-relayjunos-fingertest_end_user_profileunknown-userEnhanced_Web_Chatany test_policy_2a1any-ipv6any test_dyn_app SECURITY-SSL-PROXYonethreetest_policy_3a1a2anytest_traffic_controlgtp1test_icap FWClient1 64test_glob_1any-ipv6any-ipv6anytest_glob_2any-ipv6any-ipv6any' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_security_policies: + config: + from_zones: + - name: one + to_zones: + - name: two + policies: + - match: + application: + names: + - junos-dhcp-relay + - junos-finger + destination_address: + addresses: + - a2 + - a4 + destination_address_excluded: true + dynamic_application: + names: + - any + source_address: + addresses: + - a1 + - a3 + source_address_excluded: true + source_end_user_profile: test_end_user_profile + source_identity: + unknown_user: true + url_category: + names: + - Enhanced_Web_Chat + name: test_policy_1 + then: + count: true + deny: true + log: + session_close: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + name: test_policy_2 + then: + reject: + enable: true + profile: test_dyn_app + ssl_proxy: + enable: true + profile_name: SECURITY-SSL-PROXY + - name: three + policies: + - match: + application: + any: true + destination_address: + addresses: + - a2 + source_address: + addresses: + - a1 + name: test_policy_3 + then: + permit: + application_services: + application_traffic_control_rule_set: test_traffic_control + gprs_gtp_profile: gtp1 + icap_redirect: test_icap + reverse_redirect_wx: "True" + uac_policy: + enable: true + firewall_authentication: + push_to_identity_management: true + web_authentication: + - FWClient1 + tcp_options: + initial_tcp_mss: 64 + window_scale: true + global: + policies: + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_1 + then: + deny: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_2 + then: + deny: true + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_security_policies rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/replaced.yaml new file mode 100644 index 000000000..a9c835c0b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/replaced.yaml @@ -0,0 +1,53 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Replace configuration + junipernetworks.junos.junos_security_policies: &replaced + config: + global: + policies: + - description: test update + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any: true + name: test_glob_3 + then: + deny: true + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_security_policies: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rtt.yml new file mode 100644 index 000000000..a35e2e9ae --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/tests/netconf/rtt.yml @@ -0,0 +1,197 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_security_policies: + config: + from_zones: + - name: one + to_zones: + - name: two + policies: + - name: test_policy_1 + description: "hello world" + match: + application: + names: + - junos-dhcp-relay + - junos-finger + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + - a2 + source_identity: + authenticated_user: true + unknown_user: true + source_end_user_profile: test_end_user_profile + source_address_excluded: true + destination_address_excluded: true + dynamic_application: + any: true + url_category: + names: + - Enhanced_Web_Chat + then: + deny: true + log: + session_close: true + count: true + - name: test_policy_2 + description: hello world + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + then: + reject: + profile: test_dyn_app + ssl_proxy: + profile_name: SECURITY-SSL-PROXY + - name: two + policies: + - name: test_policy_2 + description: hello world + match: + application: + any: true + destination_address: + addresses: + - a2 + source_address: + addresses: + - a1 + then: + permit: + application_services: + application_traffic_control_rule_set: test_traffic_control + gprs_gtp_profile: gtp1 + icap_redirect: test_icap + reverse_redirect_wx: true + uac_policy: + enable: true + destination_address: drop-untranslated + firewall_authentication: + pass_through: + auth_user_agent: Opera1 + auth_only_browser: true + push_to_identity_management: true + user_firewall: + access_profile: WEBAUTH + auth_only_browser: true + auth_user_agent: Opera1 + web_redirect_to_https: true + web_authentication: + - client_match: FWClient1 + tcp_options: + initial_tcp_mss: 64 + window_scale: true + - name: two + to_zones: + - name: three + policies: + - name: test_policy_4 + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + then: + deny: true + global: + policies: + - name: test_glob_1 + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + then: + deny: true + - name: test_glob_2 + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + then: + deny: true + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - security_policies + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_security_policies: + config: + global: + policies: + - name: test_glob_1 + description: replaced + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + then: + deny: true + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_security_policies: + config: "{{ ansible_facts['network_resources']['security_policies'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_security_policies round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/vars/main.yaml new file mode 100644 index 000000000..9076a631e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies/vars/main.yaml @@ -0,0 +1,235 @@ +--- +merged: + before: {} + + after: + from_zones: + - name: one + to_zones: + - name: two + policies: + - match: + application: + names: + - junos-dhcp-relay + - junos-finger + destination_address: + addresses: + - a2 + - a4 + destination_address_excluded: true + dynamic_application: + any: true + source_address: + addresses: + - a1 + - a3 + source_address_excluded: true + source_end_user_profile: test_end_user_profile + source_identity: + authenticated_user: true + unknown_user: true + url_category: + names: + - Enhanced_Web_Chat + name: test_policy_1 + then: + count: true + deny: true + log: + session_close: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + name: test_policy_2 + then: + reject: + enable: true + profile: test_dyn_app + ssl_proxy: + enable: true + profile_name: SECURITY-SSL-PROXY + - name: three + policies: + - match: + application: + any: true + destination_address: + addresses: + - a2 + source_address: + addresses: + - a1 + name: test_policy_3 + then: + permit: + application_services: + application_traffic_control_rule_set: test_traffic_control + gprs_gtp_profile: gtp1 + icap_redirect: test_icap + reverse_redirect_wx: true + uac_policy: + enable: true + firewall_authentication: + push_to_identity_management: true + web_authentication: + - FWClient1 + tcp_options: + initial_tcp_mss: 64 + window_scale: true + global: + policies: + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_1 + then: + deny: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_2 + then: + deny: true + updated: + from_zones: + - name: one + to_zones: + - name: two + policies: + - match: + application: + names: + - junos-dhcp-relay + - junos-finger + destination_address: + addresses: + - a2 + - a4 + destination_address_excluded: true + dynamic_application: + any: true + source_address: + addresses: + - a1 + - a3 + source_address_excluded: true + source_end_user_profile: test_end_user_profile + source_identity: + authenticated_user: true + unknown_user: true + url_category: + names: + - Enhanced_Web_Chat + name: test_policy_1 + then: + count: true + deny: true + log: + session_close: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + addresses: + - a1 + name: test_policy_2 + then: + reject: + enable: true + profile: test_dyn_app + ssl_proxy: + enable: true + profile_name: SECURITY-SSL-PROXY + - name: three + policies: + - match: + application: + any: true + destination_address: + addresses: + - a2 + source_address: + addresses: + - a1 + name: test_policy_3 + then: + permit: + application_services: + application_traffic_control_rule_set: test_traffic_control + gprs_gtp_profile: gtp1 + icap_redirect: test_icap + reverse_redirect_wx: true + uac_policy: + enable: true + firewall_authentication: + push_to_identity_management: true + web_authentication: + - FWClient1 + tcp_options: + initial_tcp_mss: 64 + window_scale: true + global: + policies: + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_1 + then: + deny: true + - match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any_ipv6: true + name: test_glob_2 + then: + deny: true + - description: test update + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any: true + name: test_glob_3 + then: + deny: true + +replaced: + after: + global: + policies: + - description: test update + match: + application: + any: true + destination_address: + any_ipv6: true + source_address: + any: true + name: test_glob_3 + then: + deny: true diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..abfb5cff2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_initial_config.yaml @@ -0,0 +1,11 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to security policies global + junipernetworks.junos.junos_config: + lines: + - set system tracing destination-override syslog host 10.0.0.4 + +- ansible.builtin.debug: + msg: "END junos_security_policies_global initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_populate_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_populate_config.yaml new file mode 100644 index 000000000..47fc2c9ea --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_populate_config.yaml @@ -0,0 +1,22 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global populate config on connection={{ ansible_connection }}" + +- name: Populate config + junipernetworks.junos.junos_config: + lines: + - set security policies default-policy permit-all + - set security policies policy-rematch extensive + - set security policies policy-stats system-wide enable + - set security policies pre-id-default-policy then log session-init + - set security policies pre-id-default-policy then session-timeout icmp 10 + - set security policies pre-id-default-policy then session-timeout others 10 + - set security policies traceoptions no-remote-trace + - set security policies traceoptions flag all + - set security policies traceoptions file files 3 + - set security policies traceoptions file match /[A-Z]*/gm + - set security policies traceoptions file size 10240 + - set security policies traceoptions file no-world-readable + +- ansible.builtin.debug: + msg: "END junos_security_policies_global populate config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..d925b154a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/_reset_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to security policies global resource + junipernetworks.junos.junos_config: + lines: + - delete security policies + - delete system tracing + +- ansible.builtin.debug: + msg: "END junos_security_policies_global reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/deleted.yaml new file mode 100644 index 000000000..086dda3a2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/deleted.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - ansible.builtin.set_fact: + config: {} + - name: Delete all security policy config from the device + junipernetworks.junos.junos_security_policies_global: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies_global deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..e9b49b596 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies_global: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies_global: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_policies_global: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..72bd2d81e --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,42 @@ + + + + 18.4R1-S2.4 + + + + + + 10k + 3 + + /[A-Z]*/gm + + + all + + + + + + + + + + enable + + + + + + + + 10 + 10 + + + + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/gathered.yaml new file mode 100644 index 000000000..3bfd2f37f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/gathered.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: START junos_security_policies_global gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_security_policies_global: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_security_policies_global gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/merged.yaml new file mode 100644 index 000000000..c03a1e262 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/merged.yaml @@ -0,0 +1,95 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_security_policies_global: &merged + config: + default_policy: permit-all + policy_rematch: + enable: true + extensive: true + policy_stats: + enable: true + system_wide: true + pre_id_default_policy_action: + log: + session_init: true + session_timeout: + icmp: 10 + others: 10 + traceoptions: + file: + files: 3 + match: /[A-Z]*/gm + size: 10k + no_world_readable: true + flag: all + no_remote_trace: true + state: merged + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_security_policies_global: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with provided configuration + junipernetworks.junos.junos_security_policies_global: + config: + default_policy: deny-all + policy_rematch: + enable: true + policy_stats: + enable: true + pre_id_default_policy_action: + log: + session_init: true + session_timeout: + icmp: 10 + others: 10 + traceoptions: + file: + files: 4 + match: /[A-Z]*/gm + size: 10k + no_world_readable: true + flag: all + no_remote_trace: true + state: merged + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies_global merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/overridden.yaml new file mode 100644 index 000000000..fe53769db --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/overridden.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_security_policies_global: + config: + state: gathered + + - name: Override configuration + junipernetworks.junos.junos_security_policies_global: &overridden + config: + default_policy: deny-all + policy_rematch: + enable: true + policy_stats: + enable: true + pre_id_default_policy_action: + log: + session_init: true + traceoptions: + file: + files: 4 + match: /[A-Z]*/gm + size: 10k + flag: all + state: overridden + register: result + + - ansible.builtin.debug: + msg: "{{ merged['after'] }}" + + - ansible.builtin.debug: + msg: "{{ result['before'] }}" + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_security_policies_global: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies_global overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/parsed.yaml new file mode 100644 index 000000000..115a5d076 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/parsed.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies_global parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided security_policies_global config to agnostic model + register: result + junipernetworks.junos.junos_security_policies_global: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_security_policies_global parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rendered.yaml new file mode 100644 index 000000000..82db58810 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rendered.yaml @@ -0,0 +1,44 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies_global rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: ' enable10103/[A-Z]*/gm10k' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_security_policies_global: + config: + default_policy: permit-all + policy_rematch: + enable: true + extensive: true + policy_stats: + enable: true + system_wide: true + pre_id_default_policy_action: + log: + session_close: true + session_timeout: + icmp: 10 + others: 10 + traceoptions: + file: + files: 3 + match: "/[A-Z]*/gm" + no_world_readable: true + size: 10k + no_remote_trace: true + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: + END junos_security_policies_global rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/replaced.yaml new file mode 100644 index 000000000..d475025a7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/replaced.yaml @@ -0,0 +1,54 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_policies_global replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Replace configuration + junipernetworks.junos.junos_security_policies_global: &replaced + config: + default_policy: deny-all + policy_rematch: + enable: true + policy_stats: + enable: true + pre_id_default_policy_action: + log: + session_init: true + traceoptions: + file: + files: 4 + match: /[A-Z]*/gm + size: 10k + flag: all + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_security_policies_global: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_policies_global replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rtt.yml new file mode 100644 index 000000000..83aaecee3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/tests/netconf/rtt.yml @@ -0,0 +1,91 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_policies_global round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_security_policies_global: + config: + default_policy: permit-all + policy_rematch: + enable: true + extensive: true + policy_stats: + enable: true + system_wide: true + pre_id_default_policy_action: + log: + session_close: true + session_timeout: + icmp: 10 + others: 10 + traceoptions: + file: + files: 3 + match: "/[A-Z]*/gm" + no_world_readable: true + size: 10k + no_remote_trace: true + state: merged + + - name: Gather security policy facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - security_policies_global + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_security_policies_global: + config: + default_policy: deny-all + policy_rematch: + enable: true + policy_stats: + enable: true + pre_id_default_policy_action: + log: + session_init: true + traceoptions: + file: + files: 4 + match: /[A-Z]*/gm + size: 10k + flag: all + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_security_policies_global: + config: "{{ ansible_facts['network_resources']['security_policies_global'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_security_policies_global round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/vars/main.yaml new file mode 100644 index 000000000..76ea4dfc7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_policies_global/vars/main.yaml @@ -0,0 +1,65 @@ +--- +merged: + before: {} + + after: + default_policy: permit-all + policy_rematch: + enable: true + extensive: true + policy_stats: + enable: true + system_wide: true + pre_id_default_policy_action: + log: + session_init: true + session_timeout: + icmp: 10 + others: 10 + traceoptions: + file: + files: 3 + match: "/[A-Z]*/gm" + no_world_readable: true + size: 10k + flag: all + no_remote_trace: true + + updated: + default_policy: deny-all + policy_rematch: + enable: true + extensive: true + policy_stats: + enable: true + system_wide: true + pre_id_default_policy_action: + log: + session_init: true + session_timeout: + icmp: 10 + others: 10 + traceoptions: + file: + files: 4 + match: /[A-Z]*/gm + size: 10k + no_world_readable: true + flag: all + no_remote_trace: true +replaced: + after: + default_policy: deny-all + policy_rematch: + enable: true + policy_stats: + enable: true + pre_id_default_policy_action: + log: + session_init: true + traceoptions: + file: + files: 4 + match: /[A-Z]*/gm + size: 10k + flag: all diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..aa0bb0a7a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_initial_config.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_zones initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to security zones + junipernetworks.junos.junos_config: + lines: + - set security screen ids-option test_screen ip block-frag + - set interfaces ge-0/0/1 unit 0 family inet address 200.0.0.1/24 + - set interfaces ge-0/0/2 unit 0 family inet address 201.0.0.1/24 + - set interfaces ge-0/0/3 unit 0 family inet address 202.0.0.1/24 + - set interfaces ge-0/0/4 unit 0 family inet address 204.0.0.1/24 + - set security advance-policy-based-routing profile test_profile rule test_rule match category Enhanced_Bandwidth + - set routing-instances test_inst instance-type forwarding + - set security advance-policy-based-routing profile test_profile rule test_rule then routing-instance test_inst + +- ansible.builtin.debug: + msg: "END junos_security_zones initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_populate_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_populate_config.yaml new file mode 100644 index 000000000..77d36131a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_populate_config.yaml @@ -0,0 +1,38 @@ +--- +- name: Populate config + junipernetworks.junos.junos_config: + lines: + - set security zones functional-zone management description "test description" + - set security zones functional-zone management screen test_screen + - set security zones functional-zone management interfaces ge-0/0/1 + - set security zones functional-zone management interfaces ge-0/0/2 + - set security zones functional-zone management host-inbound-traffic protocols all + - set security zones functional-zone management host-inbound-traffic protocols bgp except + - set security zones functional-zone management host-inbound-traffic system-services all + - set security zones functional-zone management host-inbound-traffic system-services dhcp except + - set security zones security-zone test_sec_zone1 screen test_screen + - set security zones security-zone test_sec_zone1 interfaces ge-0/0/3 + - set security zones security-zone test_sec_zone1 interfaces ge-0/0/4 + - set security zones security-zone test_sec_zone1 source-identity-log + - set security zones security-zone test_sec_zone1 tcp-rst + - set security zones security-zone test_sec_zone1 enable-reverse-reroute + - set security zones security-zone test_sec_zone1 description "test description" + - set security zones security-zone test_sec_zone1 application-tracking + - set security zones security-zone test_sec_zone1 advance-policy-based-routing-profile test_profile + - set security zones security-zone test_sec_zone1 host-inbound-traffic protocols all + - set security zones security-zone test_sec_zone1 host-inbound-traffic protocols bgp except + - set security zones security-zone test_sec_zone1 host-inbound-traffic system-services all + - set security zones security-zone test_sec_zone1 host-inbound-traffic system-services dhcp except + - set security zones security-zone test_sec_zone1 address-book address test_adr1 10.0.0.0/24 description "test desc" + - set security zones security-zone test_sec_zone1 address-book address test_adr2 dns-name 1.1.1.1 ipv6-only + - set security zones security-zone test_sec_zone1 address-book address test_adr3 range-address 10.2.0.1 to 10.2.0.2 + - set security zones security-zone test_sec_zone1 address-book address test_adr4 wildcard-address 10.3.0.1/24 + - set security zones security-zone test_sec_zone1 address-book address test_adr5 10.1.0.0/24 description "test desc" + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset1 address test_adr1 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset1 address test_adr2 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset2 address test_adr3 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset2 address test_adr4 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset3 address test_adr5 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset3 address-set test_adrset1 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset3 address-set test_adrset2 + - set security zones security-zone test_sec_zone1 address-book address-set test_adrset3 description "test description" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..309e0d573 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/_reset_config.yaml @@ -0,0 +1,16 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_zones reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to security zones resource + junipernetworks.junos.junos_config: + lines: + - delete security + - delete routing-instances + - delete interfaces ge-0/0/1 + - delete interfaces ge-0/0/2 + - delete interfaces ge-0/0/3 + - delete interfaces ge-0/0/4 + +- ansible.builtin.debug: + msg: "END junos_security_zones reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/deleted.yaml new file mode 100644 index 000000000..1fc72a490 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/deleted.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_zones deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - ansible.builtin.set_fact: + config: {} + - name: Delete all security zones config from the device + junipernetworks.junos.junos_security_zones: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_zones deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..b2deccd43 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/empty_config.yaml @@ -0,0 +1,61 @@ +--- +- ansible.builtin.debug: + msg: + START junos_security_zones empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_zones: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_zones: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_zones: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_zones: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_security_zones: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..4c346a09f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,137 @@ + + + + 18.4R1-S2.4 + + + + + test description + + + all + + + bgp + + + + all + + + dhcp + + + + + ge-0/0/1.0 + + + ge-0/0/2.0 + + test_screen + + + + test_sec_zone1 + +
+ test_adr1 + 10.0.0.0/24 + test desc +
+
+ test_adr2 + + 1.1.1.1 + + +
+
+ test_adr3 + + 10.2.0.1 + + 10.2.0.2 + + +
+
+ test_adr4 + + 10.3.0.1/24 + +
+
+ test_adr5 + 10.1.0.0/24 + test desc +
+ + test_adrset1 +
+ test_adr1 +
+
+ test_adr2 +
+
+ + test_adrset2 +
+ test_adr3 +
+
+ test_adr4 +
+
+ + test_adrset3 +
+ test_adr5 +
+ + test_adrset1 + + + test_adrset2 + + test description +
+
+ + test_profile + + + test description + + + + all + + + bgp + + + + all + + + dhcp + + + + + ge-0/0/3.0 + + + ge-0/0/4.0 + + test_screen + + +
+
+
+
+
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/gathered.yaml new file mode 100644 index 000000000..5c389667f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/gathered.yaml @@ -0,0 +1,23 @@ +--- +- ansible.builtin.debug: + msg: START junos_security_zones gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_security_zones: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: END junos_security_zones gathered integration tests on connection={{ ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/merged.yaml new file mode 100644 index 000000000..d9099f679 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/merged.yaml @@ -0,0 +1,143 @@ +--- +- ansible.builtin.debug: + msg: "START junos_security_zones merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_security_zones: &merged + config: + functional_zone_management: + description: test description + host_inbound_traffic: + protocols: + - name: all + - name: bgp + except: true + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + state: merged + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junipernetworks.junos.junos_security_zones: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_security_zones: + config: + functional_zone_management: + description: test description 2 + host_inbound_traffic: + protocols: + - name: all + - name: bgp + except: true + - name: bfd + except: true + system_services: + - except: true + name: dhcp + - except: true + name: dhcpv6 + - name: all + zones: + - name: test_sec_zone2 + source_identity_log: true + tcp_rst: true + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_security_zones merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/overridden.yaml new file mode 100644 index 000000000..375d0fd57 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/overridden.yaml @@ -0,0 +1,104 @@ +--- +- ansible.builtin.debug: + msg: >- + START junos_security_zones overridden integration tests on connection={{ + ansible_connection }} +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - name: Override configuration + junipernetworks.junos.junos_security_zones: &ref_0 + config: + functional_zone_management: + description: test description 2 + host_inbound_traffic: + protocols: + - name: all + system_services: + - name: all + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + state: overridden + register: result + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + - name: >- + Replaced the provided configuration with the existing running + configuration (IDEMPOTENT) + junipernetworks.junos.junos_security_zones: *ref_0 + register: result + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml +- ansible.builtin.debug: + msg: >- + END junos_security_zones overridden integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/parsed.yaml new file mode 100644 index 000000000..63e8dc391 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/parsed.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg: >- + START junos_security_zones parsed integration tests on connection={{ + ansible_connection }} +- name: Parse externally provided security_zones config to agnostic model + register: result + junipernetworks.junos.junos_security_zones: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: >- + END junos_security_zones parsed integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rendered.yaml new file mode 100644 index 000000000..c144a48f0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rendered.yaml @@ -0,0 +1,90 @@ +--- +- ansible.builtin.debug: + msg: >- + START junos_security_zones rendered integration tests on connection={{ + ansible_connection }} +- ansible.builtin.set_fact: + expected_rendered_output: 'test descriptionallbgpalldhcpge-0/0/1.0ge-0/0/2.0test_screentest_sec_zone1test_adr110.0.0.0/24test desctest_adr21.1.1.1test_adr310.2.0.110.2.0.2test_adr410.3.0.1/24test_adr510.1.0.0/24test desctest_adrset1test_adr1test_adr2test_adrset2test_adr3test_adr4test_adrset3test_adr5test_adrset1test_adrset2test descriptiontest_profiletest descriptionallbgpalldhcpge-0/0/3.0ge-0/0/4.0test_screen' +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_security_zones: + config: + functional_zone_management: + description: test description + host_inbound_traffic: + protocols: + - name: all + - name: bgp + except: true + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + state: rendered +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" +- ansible.builtin.debug: + msg: >- + END junos_security_zones rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/replaced.yaml new file mode 100644 index 000000000..168463579 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/replaced.yaml @@ -0,0 +1,104 @@ +--- +- ansible.builtin.debug: + msg: >- + START junos_security_zones replaced integration tests on connection={{ + ansible_connection }} +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - name: Override configuration + junipernetworks.junos.junos_security_zones: &ref_0 + config: + functional_zone_management: + description: test description 2 + host_inbound_traffic: + protocols: + - name: all + system_services: + - name: all + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + state: replaced + register: result + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result.after }}" + - name: >- + Replaced the provided configuration with the existing running + configuration (IDEMPOTENT) + junipernetworks.junos.junos_security_zones: *ref_0 + register: result + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml +- ansible.builtin.debug: + msg: >- + END junos_security_zones replaced integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rtt.yml new file mode 100644 index 000000000..30ba201b9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/tests/netconf/rtt.yml @@ -0,0 +1,184 @@ +--- +- ansible.builtin.debug: + msg: >- + START junos_security_zones round trip integration tests on connection={{ + ansible_connection }} +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_security_zones: + config: + functional_zone_management: + description: test description + host_inbound_traffic: + protocols: + - name: all + - name: bgp + except: true + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + state: merged + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - security_zones + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_security_zones: + config: + functional_zone_management: + description: test description 2 + host_inbound_traffic: + protocols: + - name: all + system_services: + - name: all + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + state: replaced + - name: Assert that changes were applied + ansible.builtin.assert: + that: "result['changed'] == true" + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_security_zones: + config: "{{ ansible_facts['network_resources']['security_zones'] }}" + state: replaced + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml +- ansible.builtin.debug: + msg: >- + END junos_security_zones round trip integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/vars/main.yaml new file mode 100644 index 000000000..418236a9f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_security_zones/vars/main.yaml @@ -0,0 +1,220 @@ +--- +merged: + before: {} + after: + functional_zone_management: + description: test description + host_inbound_traffic: + protocols: + - name: all + - name: bgp + except: true + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + updated: + functional_zone_management: + description: test description 2 + host_inbound_traffic: + protocols: + - name: all + - name: bgp + except: true + - name: bfd + except: true + system_services: + - name: all + - except: true + name: dhcp + - except: true + name: dhcpv6 + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true + - name: test_sec_zone2 + source_identity_log: true + tcp_rst: true +replaced: + after: + functional_zone_management: + description: test description 2 + host_inbound_traffic: + protocols: + - name: all + system_services: + - name: all + interfaces: + - ge-0/0/1.0 + - ge-0/0/2.0 + screen: test_screen + zones: + - address_book: + address_sets: + - addresses: + - test_adr1 + - test_adr2 + name: test_adrset1 + - addresses: + - test_adr3 + - test_adr4 + name: test_adrset2 + - address_sets: + - test_adrset1 + - test_adrset2 + addresses: + - test_adr5 + description: test description + name: test_adrset3 + addresses: + - description: test desc + ip_prefix: 10.0.0.0/24 + name: test_adr1 + - dns_name: + ipv6_only: true + name: 1.1.1.1 + name: test_adr2 + - name: test_adr3 + range_address: + from: 10.2.0.1 + to: 10.2.0.2 + - name: test_adr4 + wildcard_address: 10.3.0.1/24 + - description: test desc + ip_prefix: 10.1.0.0/24 + name: test_adr5 + advance_policy_based_routing_profile: test_profile + application_tracking: true + description: test description + enable_reverse_reroute: true + host_inbound_traffic: + protocols: + - name: all + - except: true + name: bgp + system_services: + - name: all + - except: true + name: dhcp + interfaces: + - ge-0/0/3.0 + - ge-0/0/4.0 + name: test_sec_zone1 + screen: test_screen + source_identity_log: true + tcp_rst: true diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/cli.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/cli.yaml new file mode 100644 index 000000000..0092e0d5d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/cli.yaml @@ -0,0 +1,29 @@ +--- +- name: Collect cli test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.network_cli + +- name: Run test cases with single_user_mode (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ role_path }}/tests/cli/caching.yaml" + vars: + ansible_connection: ansible.netcommon.network_cli + ansible_network_single_user_mode: "True" + connection: "{{ cli }}" + + tags: + - network_cli diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/main.yaml new file mode 100644 index 000000000..08ec42d9a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/main.yaml @@ -0,0 +1,8 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: cli.yaml + tags: ["network_cli"] + +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: ["netconf"] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/netconf.yaml new file mode 100644 index 000000000..ab7d6689b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tasks/netconf.yaml @@ -0,0 +1,19 @@ +--- +- name: Collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/caching.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/caching.yaml new file mode 100644 index 000000000..86d005032 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/caching.yaml @@ -0,0 +1,52 @@ +--- +- block: + - ansible.builtin.debug: msg="START connection={{ ansible_connection }} cli/caching.yaml" + + - name: Remove description from interface + ignore_errors: true + junipernetworks.junos.junos_command: &rem + commands: + - configure + - delete interfaces ge-0/0/1 description + - commit + - exit + + - name: Fetch configuration + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show configuration interfaces ge-0/0/1 + register: result + + - ansible.builtin.assert: + that: + - '"description test-1;" not in result.stdout_lines' + + - name: Fetch configuration again (from cache) + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show configuration interfaces ge-0/0/1 + + - name: Configure description on interface + ignore_errors: true + junipernetworks.junos.junos_command: + commands: + - configure + - set interfaces ge-0/0/1 description test-1 + - commit + - exit + + - name: Fetch configuration from appliance + ignore_errors: true + junipernetworks.junos.junos_command: + commands: show configuration interfaces ge-0/0/1 + register: result + + - ansible.builtin.assert: + that: + - '"description test-1;" in result.stdout_lines[0]' + + always: + - name: Remove description from interface + ignore_errors: true + junipernetworks.junos.junos_command: *rem + when: ansible_connection == "ansible.netcommon.network_cli" and ansible_network_single_user_mode|d(False) diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/reboot.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/reboot.yaml new file mode 100644 index 000000000..4ed3094ee --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/cli/reboot.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: START cli/cli_reboot.yaml on connection={{ ansible_connection }} +- block: + - ansible.netcommon.cli_command: + command: request system reboot + prompt: + - Reboot the system? + answer: + - y + + - wait_for_connection: + delay: 30 + sleep: 20 + + - ansible.netcommon.cli_command: + command: show version + when: ansible_connection == 'ansible.netcommon.network_cli' + +- ansible.builtin.debug: msg="END cli/reboot.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/common_utils.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/common_utils.yaml new file mode 100644 index 000000000..015c05ad8 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/common_utils.yaml @@ -0,0 +1,24 @@ +--- +# junos interface -> remove_default_spec() conditional() +- ansible.builtin.debug: msg="START junos_interface netconf/common_utils.yaml on connection={{ ansible_connection }}" + +- name: get facts + junos_facts: + register: result + +- name: Define interface name for vSRX + ansible.builtin.set_fact: + intf_name: pp0 + when: result['ansible_facts']['ansible_net_model'] is search("vSRX*") + +- name: Define interface name for vsrx + ansible.builtin.set_fact: + intf_name: pp0 + when: result['ansible_facts']['ansible_net_model'] is search("vsrx") + +- name: Define interface name for vQFX + ansible.builtin.set_fact: + intf_name: gr-0/0/0 + when: result['ansible_facts']['ansible_net_model'] is search("vqfx*") + +- ansible.builtin.debug: msg="END junos_interface netconf/common_utils.yaml on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/module_utils_junos.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/module_utils_junos.yaml new file mode 100644 index 000000000..b5549a214 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_smoke/tests/netconf/module_utils_junos.yaml @@ -0,0 +1,53 @@ +--- +- ansible.builtin.debug: msg="START netconf/module_utils_junos.yaml on connection={{ ansible_connection }}" + +# hit get_capabilities() + +- name: get output for single command + junos_command: + commands: ["show version"] + format: json + register: result + +- ansible.builtin.assert: + that: + - "result.changed == false" + - "result.stdout is defined" + - "result.stdout_lines is defined" + +# hit commit_configuration() +- name: setup - remove login banner + junos_banner: + banner: login + state: absent + +- name: Create login banner + junos_banner: + banner: login + text: this is my login banner + state: present + register: result + +- name: Get running configuration + junos_rpc: + rpc: get-configuration + register: config + +- ansible.builtin.assert: + that: + - "result.changed == true" + - "'this is my login banner' in config.xml" + +# hit discard_changes() +- name: check mode + junos_banner: + banner: login + text: this is not the banner you're looking for + state: present + register: result + check_mode: true + +- ansible.builtin.assert: + that: + - "result.changed == true" + - "result.failed == false" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..5cfd90cfe --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_initial_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_snmp_server initial config on connection={{ ansible_connection }}" + +- name: Configure basic config relevant to ntp global + junipernetworks.junos.junos_config: + lines: + - set routing-instances clv1 description "clv1" + - set routing-instances clv2 description "clv2" + +- ansible.builtin.debug: + msg: "END junos_snmp_server initial config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_populate_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_populate_config.yaml new file mode 100644 index 000000000..9c0038236 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_populate_config.yaml @@ -0,0 +1,23 @@ +--- +- name: Populate config + junipernetworks.junos.junos_config: + lines: + - "set snmp arp" + - "set snmp arp host-name-resolution" + - "set snmp client-list cl1" + - "set snmp client-list cl2" + - "set snmp client-list cl1 192.16.1.0/24" + - "set snmp client-list cl1 192.16.2.0/24" + - "set snmp client-list cl1 11.11.11.11 restrict" + - "set snmp client-list cl2 192.16.4.0/24" + - "set snmp community comm1" + - "set snmp community comm2" + - "set snmp community comm1 authorization read-write" + - "set snmp community comm1 client-list-name cl1" + - "set snmp community comm1 clients 24.0.0.0/32 restrict" + - "set snmp community comm1 clients 30.0.0.0/32 restrict" + - 'set routing-instances clv1 description "clv1"' + - 'set routing-instances clv2 description "clv2"' + - "set snmp routing-instance-access" + - "set snmp routing-instance-access access-list clv1" + - "set snmp routing-instance-access access-list clv2" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_reset_config.yaml new file mode 100644 index 000000000..4bf7a9664 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/_reset_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_snmp_server reset config on connection={{ ansible_connection }}" + +- name: Reset the config releavent to ntp global resource + junipernetworks.junos.junos_config: + lines: + - delete snmp + - delete routing-instances + +- ansible.builtin.debug: + msg: "END junos_snmp_server reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/backups/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/backups/empty_config.yaml new file mode 100644 index 000000000..c2d74d60a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/backups/empty_config.yaml @@ -0,0 +1,49 @@ +--- +- ansible.builtin.debug: + msg: START junos_bgp_global empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_bgp_global: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/deleted.yaml new file mode 100644 index 000000000..a3651cc0d --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/deleted.yaml @@ -0,0 +1,26 @@ +--- +- ansible.builtin.debug: + msg: "START junos_snmp_server deleted integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + - ansible.builtin.set_fact: + config: {} + - name: Delete all snmp_server config from the device + junipernetworks.junos.junos_snmp_server: + state: deleted + register: result + + - name: Assert changed + ansible.builtin.assert: + that: + - result.changed == True + - "{{ config == result.after }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_snmp_server deleted integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..472ad0e3a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/empty_config.yaml @@ -0,0 +1,60 @@ +--- +- ansible.builtin.debug: + msg: START junos_snmp_server empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_snmp_server: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_snmp_server: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_snmp_server: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_snmp_server: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_snmp_server: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..9c1a5a962 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,62 @@ + + + + 18.4R1-S2.4 + + + cl1 + + 192.16.1.0/24 + + + 192.16.2.0/24 + + + 11.11.11.11/32 + + + + + cl2 + + 192.16.4.0/24 + + + + + clv1 + + + clv2 + + + + + + + + + fxp0 + + 0 + + + + + + + + + + + + rt1 + rt1 + + + rt2 + rt2 + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/gathered.yaml new file mode 100644 index 000000000..819e63cc9 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/gathered.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: START junos_snmp_server gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Gather interfaces facts using gathered state + register: result + junipernetworks.junos.junos_snmp_server: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: "{{ gathered['facts'] == result['gathered'] }}" + + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_snmp_server gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/merged.yaml new file mode 100644 index 000000000..f689a69e5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/merged.yaml @@ -0,0 +1,88 @@ +--- +- ansible.builtin.debug: + msg: "START junos_snmp_server merged integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Merge the provided configuration with the exisiting running configuration + junipernetworks.junos.junos_snmp_server: &merged + config: + arp: + set: true + host_name_resolution: true + client_lists: + - name: cl1 + addresses: + - address: "192.16.1.0/24" + - address: "192.16.2.0/24" + - address: "11.11.11.11" + restrict: true + - name: cl2 + addresses: + - address: "192.16.4.0/24" + routing_instance_access: + set: true + access_lists: + - "clv1" + - "clv2" + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['before'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['after'] == result['after'] }}" + + - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) + junos_snmp_server: *merged + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + - name: Update the running configuration with providede configuration + junipernetworks.junos.junos_snmp_server: + config: + communities: + - name: "comm1" + clients: + - address: "24.0.0.0/32" + restrict: true + - address: "30.0.0.0/32" + restrict: true + routing_instances: + - name: "clv1" + clients: + - address: "13.13.13.13/24" + restrict: true + - address: "24.0.0.0/32" + - address: "30.0.0.0/32" + - name: "clv2" + clients: + - address: "15.15.15.15/24" + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ merged['after'] == result['before'] }}" + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - result.changed == True + - "{{ merged['updated'] == result['after'] }}" + + tags: merged + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_snmp_server merged integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/overridden.yaml new file mode 100644 index 000000000..4f40e59e2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/overridden.yaml @@ -0,0 +1,53 @@ +--- +- ansible.builtin.debug: + msg: "START junos_snmp_server overridden integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_snmp_server: &overridden + config: + contact: "ansiblesupport11@redhat.com" + customization: + ether_stats_ifd_only: true + description: "Local SNMP Server" + engine_id: + use_mac_address: true + filter_duplicates: true + filter_interfaces: + all_internal_interfaces: true + interfaces: + - "eth1" + - "eth2" + set: true + state: overridden + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ gathered['facts'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result['after'] }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_snmp_server: *overridden + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: overridden + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_snmp_server overridden integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/parsed.yaml new file mode 100644 index 000000000..209a7acf7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/parsed.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: + START junos_snmp_server parsed integration tests on connection={{ ansible_connection + }} + +- name: Parse externally provided snmp_server config to agnostic model + register: result + junipernetworks.junos.junos_snmp_server: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ merged['after'] == result['parsed'] }}" +- ansible.builtin.debug: + msg: + END junos_snmp_server parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rendered.yaml new file mode 100644 index 000000000..abd27545a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rendered.yaml @@ -0,0 +1,30 @@ +--- +- ansible.builtin.debug: + msg: START junos_snmp_server rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'clv1clv2' + +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_snmp_server: + config: + arp: + set: true + host_name_resolution: true + routing_instance_access: + set: true + access_lists: + - "clv1" + - "clv2" + state: rendered + +- name: Assert that correct set of commands were rendered + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + +- ansible.builtin.debug: + msg: END junos_snmp_server rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/replaced.yaml new file mode 100644 index 000000000..d8b66546b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/replaced.yaml @@ -0,0 +1,53 @@ +--- +- ansible.builtin.debug: + msg: "START junos_snmp_server replaced integration tests on connection={{ ansible_connection }}" + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + - ansible.builtin.include_tasks: _populate_config.yaml + + - name: Override configuration + junipernetworks.junos.junos_snmp_server: &replaced + config: + contact: "ansiblesupport11@redhat.com" + customization: + ether_stats_ifd_only: true + description: "Local SNMP Server" + engine_id: + use_mac_address: true + filter_duplicates: true + filter_interfaces: + all_internal_interfaces: true + interfaces: + - "eth1" + - "eth2" + set: true + state: replaced + register: result + + - name: Assert that before dicts were correctly generated + ansible.builtin.assert: + that: "{{ gathered['facts'] == result['before'] }}" + + - name: Assert configuration + ansible.builtin.assert: + that: + - result.changed == True + - "{{ replaced['after'] == result['after'] }}" + + - name: Replaced the provided configuration with the existing running configuration (IDEMPOTENT) + junos_snmp_server: *replaced + register: result + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == False + + tags: replaced + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: "END junos_snmp_server replaced integration tests on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rtt.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rtt.yaml new file mode 100644 index 000000000..581b874fb --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/tests/netconf/rtt.yaml @@ -0,0 +1,86 @@ +--- +- ansible.builtin.debug: + msg: START junos_snmp_server round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _reset_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_snmp_server: + config: + arp: + set: true + host_name_resolution: true + client_lists: + - name: cl1 + addresses: + - address: "192.16.1.0/24" + - address: "192.16.2.0/24" + - address: "11.11.11.11" + restrict: true + - name: cl2 + addresses: + - address: "192.16.4.0/24" + routing_instance_access: + set: true + access_lists: + - "clv1" + - "clv2" + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - snmp_server + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_snmp_server: + config: + contact: "ansiblesupport11@redhat.com" + customization: + ether_stats_ifd_only: true + description: "Local SNMP Server" + engine_id: + use_mac_address: true + filter_duplicates: true + filter_interfaces: + set: true + all_internal_interfaces: true + interfaces: + - "eth1" + - "eth2" + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_snmp_server: + config: "{{ ansible_facts['network_resources']['snmp_server'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] == revert['before'] }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] == revert['after'] }}" + always: + - ansible.builtin.include_tasks: _reset_config.yaml + +- ansible.builtin.debug: + msg: + END junos_snmp_server round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/vars/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/vars/main.yaml new file mode 100644 index 000000000..fdb1d777c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_snmp_server/vars/main.yaml @@ -0,0 +1,97 @@ +--- +merged: + before: {} + after: + arp: + host_name_resolution: true + client_lists: + - addresses: + - address: "192.16.1.0/24" + - address: "192.16.2.0/24" + - address: "11.11.11.11/32" + restrict: true + name: "cl1" + - addresses: + - address: "192.16.4.0/24" + name: "cl2" + routing_instance_access: + access_lists: + - "clv1" + - "clv2" + + updated: + arp: + host_name_resolution: true + client_lists: + - addresses: + - address: "192.16.1.0/24" + - address: "192.16.2.0/24" + - address: "11.11.11.11/32" + restrict: true + name: "cl1" + - addresses: + - address: "192.16.4.0/24" + name: "cl2" + communities: + - clients: + - address: "24.0.0.0/32" + restrict: true + - address: "30.0.0.0/32" + restrict: true + name: "comm1" + routing_instances: + - clients: + - address: "13.13.13.13/24" + restrict: true + - address: "24.0.0.0/32" + - address: "30.0.0.0/32" + name: "clv1" + - clients: + - address: "15.15.15.15/24" + name: "clv2" + routing_instance_access: + access_lists: + - "clv1" + - "clv2" +gathered: + facts: + arp: + host_name_resolution: true + client_lists: + - addresses: + - address: "192.16.1.0/24" + - address: "192.16.2.0/24" + - address: "11.11.11.11/32" + restrict: true + name: "cl1" + - addresses: + - address: "192.16.4.0/24" + name: "cl2" + communities: + - authorization: "read-write" + clients: + - address: "24.0.0.0/32" + restrict: true + - address: "30.0.0.0/32" + restrict: true + name: "comm1" + - name: "comm2" + routing_instance_access: + access_lists: + - "clv1" + - "clv2" + +replaced: + after: + contact: "ansiblesupport11@redhat.com" + customization: + ether_stats_ifd_only: true + description: "Local SNMP Server" + engine_id: + use_mac_address: true + filter_duplicates: true + filter_interfaces: + all_internal_interfaces: true + interfaces: + - "eth1" + - "eth2" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/meta/main.yaml new file mode 100644 index 000000000..7f867d73b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/meta/main.yaml @@ -0,0 +1,2 @@ +--- +dependencies: diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_base_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_base_config.yaml new file mode 100644 index 000000000..c1acaf7ae --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_base_config.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_static_routes base config ansible_connection={{ ansible_connection + }} + +- name: Configure base static_routes + junipernetworks.junos.junos_static_routes: + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.168.0.0/24 + next_hop: + - forward_router_address: 192.168.0.1 + - afi: ipv6 + routes: + - dest: 2001:db8::5/128 + next_hop: + - forward_router_address: 2001:db8:0:1:2a0:a502:0:19da + +- ansible.builtin.debug: + msg: + End junos_static_routes base config ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..f8e907599 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/_remove_config.yaml @@ -0,0 +1,18 @@ +--- +- ansible.builtin.debug: + msg: + Start junos_static_routes teardown ansible_connection={{ ansible_connection + }} + +- name: Remove static route config + junipernetworks.junos.junos_static_routes: + config: + - address_families: + - afi: ipv4 + - afi: ipv6 + state: deleted + +- ansible.builtin.debug: + msg: + End junos_static_routes teardown ansible_connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/deleted.yaml new file mode 100644 index 000000000..3c701d9ca --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/deleted.yaml @@ -0,0 +1,43 @@ +--- +- ansible.builtin.debug: + msg: + START junos_static_routes deleted integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- block: + - name: Delete the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_static_routes: &id001 + config: + - address_families: + - afi: ipv4 + - afi: ipv6 + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - not result.after + debugger: on_failed + + - name: + Delete the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_static_routes deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/merged.yaml new file mode 100644 index 000000000..aeaa6d058 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/merged.yaml @@ -0,0 +1,78 @@ +--- +- ansible.builtin.debug: + msg: + START junos_static_routes merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8::5/128 + next_hop: + - forward_router_address: 2001:db8:0:1:2a0:a502:0:19da + - dest: ::/0 + next_hop: + - forward_router_address: 2001:db8:0:1:2a0:a502:0:19da + - afi: ipv4 + routes: + - dest: 192.168.0.0/24 + next_hop: + - forward_router_address: 192.168.0.1 + - dest: 192.168.1.0/24 + metric: 2 + next_hop: + - forward_router_address: 192.168.1.1 + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_static_routes: &id001 + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.168.0.0/24 + next_hop: + - forward_router_address: 192.168.0.1 + - dest: 192.168.1.0/24 + next_hop: + - forward_router_address: 192.168.1.1 + metric: 2 + - afi: ipv6 + routes: + - dest: 2001:db8::5/128 + next_hop: + - forward_router_address: 2001:db8:0:1:2a0:a502:0:19da + - dest: ::/0 + next_hop: + - forward_router_address: 2001:db8:0:1:2a0:a502:0:19da + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + debugger: on_failed + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_static_routes merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/overridden.yaml new file mode 100644 index 000000000..a24b890a1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/overridden.yaml @@ -0,0 +1,57 @@ +--- +- ansible.builtin.debug: + msg: START junos_static_routes overridden integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - address_families: + - afi: ipv4 + routes: + - dest: 192.168.20.0/24 + next_hop: + - forward_router_address: 192.168.20.1 + metric: 10 + +- block: + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_static_routes: &id001 + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.168.20.0/24 + next_hop: + - forward_router_address: 192.168.20.1 + metric: 10 + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + debugger: on_failed + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_static_routes overridden integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/replaced.yaml new file mode 100644 index 000000000..b0aa7b8c7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_static_routes/tests/netconf/replaced.yaml @@ -0,0 +1,60 @@ +--- +- ansible.builtin.debug: + msg: START junos_static_routes overridden integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - address_families: + - afi: ipv6 + routes: + - dest: 2001:db8::5/128 + next_hop: + - forward_router_address: 2001:db8:0:1:2a0:a502:0:19da + - afi: ipv4 + routes: + - dest: 192.168.0.0/24 + next_hop: + - forward_router_address: 192.168.20.1 + +- block: + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_static_routes: &id001 + config: + - address_families: + - afi: ipv4 + routes: + - dest: 192.168.0.0/24 + next_hop: + - forward_router_address: 192.168.20.1 + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + debugger: on_failed + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_static_routes: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_static_routes overridden integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/aliases b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/aliases new file mode 100644 index 000000000..e69de29bb diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/main.yaml new file mode 100644 index 000000000..ac951c8f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/netconf.yaml new file mode 100644 index 000000000..6071adcfe --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + register: test_cases + connection: local + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tests/netconf/basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tests/netconf/basic.yaml new file mode 100644 index 000000000..ef24717f0 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_system/tests/netconf/basic.yaml @@ -0,0 +1,370 @@ +--- +- ansible.builtin.debug: + msg="START junos_system netconf/basic.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove hostname + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: absent + +- name: Set hostname + register: result + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'vsrx01' in config.xml" + +- name: Set hostname (idempotent) + register: result + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate hostname configuration + register: result + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - ''''' in config.xml' + +- name: Activate hostname configuration + register: result + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'vsrx01' in config.xml" + +- name: Delete hostname configuration + register: result + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: absent + +- ansible.builtin.assert: + that: + - result.changed == true + - "'vsrx01' in config.xml" + +- name: Teardown - set hostname + junipernetworks.junos.junos_system: + hostname: vsrx01 + state: present + +- name: setup - remove domain name + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: absent + +- name: Set domain name + register: result + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'ansible.com' in config.xml" + +- name: Set domain name (idempotent) + register: result + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate domain name + register: result + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - ''''' in config.xml' + +- name: Activate domain name + register: result + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'ansible.com' in config.xml" + +- name: Delete domain name + register: result + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'ansible.com' not in config.xml" + +- name: Teardown - set domain name + junipernetworks.junos.junos_system: + domain_name: ansible.com + state: present + +- name: Setup - delete domain search + register: result + junipernetworks.junos.junos_system: + domain_search: + - test.com + - sample.com + state: absent + +- name: Set domain search + register: result + junipernetworks.junos.junos_system: + domain_search: + - test.com + - sample.com + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test.com' in config.xml" + - "'sample.com' in config.xml" + +- name: Set domain search (idempotency) + register: result + junipernetworks.junos.junos_system: + domain_search: + - test.com + - sample.com + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate domain search + register: result + junipernetworks.junos.junos_system: + domain_search: + - test.com + - sample.com + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - '''test.com'' in config.xml' + - '''sample.com'' in config.xml' + +- name: Activate domain search + register: result + junipernetworks.junos.junos_system: + domain_search: + - test.com + - sample.com + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test.com' in config.xml" + - "'sample.com' in config.xml" + +- name: Delete domain search + register: result + junipernetworks.junos.junos_system: + domain_search: + - test.com + - sample.com + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test.com' not in config.xml" + - "'sample.com' not in config.xml" + +- name: Setup - delete name servers + register: result + junipernetworks.junos.junos_system: + name_servers: + - 8.8.8.8 + - 8.8.4.4 + state: absent + +- name: Set name servers + register: result + junipernetworks.junos.junos_system: + name_servers: + - 8.8.8.8 + - 8.8.4.4 + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'8.8.8.8' in config.xml" + - "'8.8.4.4' in config.xml" + +- name: Set name servers (idempotent) + register: result + junipernetworks.junos.junos_system: + name_servers: + - 8.8.8.8 + - 8.8.4.4 + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate name servers + register: result + junipernetworks.junos.junos_system: + name_servers: + - 8.8.8.8 + - 8.8.4.4 + state: present + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - ''''' in config.xml' + +- name: Activate name servers + register: result + junipernetworks.junos.junos_system: + name_servers: + - 8.8.8.8 + - 8.8.4.4 + state: present + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'8.8.8.8' in config.xml" + - "'8.8.4.4' in config.xml" + +- name: Delete name servers + register: result + junipernetworks.junos.junos_system: + name_servers: + - 8.8.8.8 + - 8.8.4.4 + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'8.8.8.8' not in config.xml" + - "'8.8.4.4' not in config.xml" + +- ansible.builtin.debug: + msg="END junos_system netconf/basic.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/defaults/main.yaml new file mode 100644 index 000000000..822f2213a --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_cases: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/main.yaml new file mode 100644 index 000000000..ac951c8f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/netconf.yaml new file mode 100644 index 000000000..2f24bb1a3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + register: test_cases + connection: local + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tests/netconf/basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tests/netconf/basic.yaml new file mode 100644 index 000000000..119519a68 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_user/tests/netconf/basic.yaml @@ -0,0 +1,204 @@ +--- +- ansible.builtin.debug: + msg="START junos_user netconf/basic.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove user + junipernetworks.junos.junos_user: + name: test_user + state: absent + +- name: Create user + register: result + junipernetworks.junos.junos_user: + name: test_user + state: present + full_name: test_user + role: operator + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_user' in config.xml" + - "'test_user' in config.xml" + - "'operator' in config.xml" + +- name: Create user again (idempotent) + register: result + junipernetworks.junos.junos_user: + name: test_user + state: present + full_name: test_user + role: operator + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Deactivate user + register: result + junipernetworks.junos.junos_user: + name: test_user + state: present + full_name: test_user + role: operator + active: false + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - ''''' in config.xml' + - "'test_user' in config.xml" + +- name: Activate user + register: result + junipernetworks.junos.junos_user: + name: test_user + state: present + full_name: test_user + role: operator + active: true + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_user' in config.xml" + - "'test_user' in config.xml" + - "'operator' in config.xml" + +- name: Delete user + register: result + junipernetworks.junos.junos_user: + name: test_user + state: absent + full_name: test_user + role: operator + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_user' not in config.xml" + - "'test_user' not in config.xml" + +- name: Delete user again (idempotent check) + register: result + junipernetworks.junos.junos_user: + name: test_user + state: absent + full_name: test_user + role: operator + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Teardown list of users + register: result + junipernetworks.junos.junos_user: + aggregate: + - name: test_user1 + state: absent + + - name: test_user2 + state: absent + +- name: Create list of users + register: result + junipernetworks.junos.junos_user: + aggregate: + - name: test_user1 + full_name: test_user2 + role: operator + state: present + + - name: test_user2 + full_name: test_user2 + role: read-only + state: present + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_user1' in config.xml" + - "'test_user2' in config.xml" + +- name: Delete list of users + register: result + junipernetworks.junos.junos_user: + aggregate: + - name: test_user1 + full_name: test_user2 + role: operator + state: absent + + - name: test_user2 + full_name: test_user2 + role: read-only + state: absent + +- name: Get running configuration + register: config + junipernetworks.junos.junos_rpc: + rpc: get-configuration + +- ansible.builtin.assert: + that: + - result.changed == true + - "'test_user1' not in config.xml" + - "'test_user2' not in config.xml" + +- name: Create list of users + register: result + junipernetworks.junos.junos_user: + aggregate: + - name: "{{ ansible_user|default('ansible') }}" + + - name: test_user1 + full_name: test_user2 + role: operator + + - name: test_user2 + full_name: test_user2 + role: read-only + +- name: Purge users except the users in aggregate + register: result + junipernetworks.junos.junos_user: + aggregate: + - name: "{{ ansible_user|default('ansible') }}" + purge: true + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\- *user test_user1") + - result.diff.prepared is search("\- *user test_user2") + +- ansible.builtin.debug: + msg="END junos_user netconf/basic.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/meta/main.yaml new file mode 100644 index 000000000..7f867d73b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/meta/main.yaml @@ -0,0 +1,2 @@ +--- +dependencies: diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/main.yaml new file mode 100644 index 000000000..ee273606c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/netconf.yaml new file mode 100644 index 000000000..3db81d098 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tasks/netconf.yaml @@ -0,0 +1,20 @@ +--- +- name: Collect all netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + use_regex: true + connection: local + register: test_cases + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_base_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_base_config.yaml new file mode 100644 index 000000000..99fc71c5f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_base_config.yaml @@ -0,0 +1,13 @@ +--- +- ansible.builtin.debug: + msg: Start junos_vlans base config ansible_connection={{ ansible_connection + }} + +- name: Configure base vlans + junipernetworks.junos.junos_config: + lines: + - set vlans vlan1 vlan-id 1 + - set vlans vlan2 vlan-id 2 + +- ansible.builtin.debug: + msg: End junos_vlans base config ansible_connection={{ ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_initial_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_initial_config.yaml new file mode 100644 index 000000000..0ef2c2347 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_initial_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: "START junos_routing_instances reset config on connection={{ ansible_connection }}" + +- name: Configure policy options w.r.t routing-instances + junipernetworks.junos.junos_config: + lines: + - set vlans vlan1 vlan-id 1 + - set vlans vlan2 vlan-id 2 + - set vlans vlan2 vlan-id 2 l3-interface irb.12 +- ansible.builtin.debug: + msg: "END junos_routing_instances reset config on connection={{ ansible_connection }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_remove_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_remove_config.yaml new file mode 100644 index 000000000..11176a318 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/_remove_config.yaml @@ -0,0 +1,12 @@ +--- +- ansible.builtin.debug: + msg: Start junos_vlans teardown ansible_connection={{ ansible_connection }} + +- name: Remove interface config + junipernetworks.junos.junos_config: + lines: + - delete vlans vlan1 + - delete vlans vlan2 + +- ansible.builtin.debug: + msg: End junos_vlans teardown ansible_connection={{ ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/deleted.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/deleted.yaml new file mode 100644 index 000000000..25e75c370 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/deleted.yaml @@ -0,0 +1,39 @@ +--- +- ansible.builtin.debug: + msg: + START junos_vlans deleted integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- block: + - name: Delete the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_vlans: &id001 + config: + state: deleted + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - not result.after + + - name: + Delete the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_vlans: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_vlans deleted integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/empty_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/empty_config.yaml new file mode 100644 index 000000000..61e29a1e1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/empty_config.yaml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: START junos_vlans empty_config integration tests on connection={{ + ansible_connection }} + +- name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_vlans: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_vlans: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Override with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_vlans: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_vlans: + running_config: + state: parsed + +- ansible.builtin.debug: + msg: result +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + junipernetworks.junos.junos_vlans: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- ansible.builtin.debug: + msg: END junos_vlans empty_config integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/fixtures/parsed.cfg b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/fixtures/parsed.cfg new file mode 100644 index 000000000..ae9fbe0f7 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/fixtures/parsed.cfg @@ -0,0 +1,17 @@ + + + + 18.4R1-S2.4 + + + vlan1 + 1 + + + vlan2 + 2 + irb.12 + + + + diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/gathered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/gathered.yaml new file mode 100644 index 000000000..bd5c270b1 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/gathered.yaml @@ -0,0 +1,35 @@ +--- +- ansible.builtin.debug: + msg: START junos_vlans gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + + - ansible.builtin.include_tasks: _initial_config.yaml + + - ansible.builtin.set_fact: + expected_gathered_output: + - name: vlan1 + vlan_id: 1 + - name: vlan2 + vlan_id: 2 + l3_interface: "irb.12" + + - name: Gather bgp address family facts using gathered state + register: result + junipernetworks.junos.junos_vlans: + state: gathered + + - name: Assert that facts were correctly generated + ansible.builtin.assert: + that: + - "{{ expected_gathered_output | symmetric_difference(result['gathered']) |length\ + \ == 0 }}" + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_vlans gathered integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/merged.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/merged.yaml new file mode 100644 index 000000000..6456a2d23 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/merged.yaml @@ -0,0 +1,53 @@ +--- +- ansible.builtin.debug: + msg: + START junos_vlans merged integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.set_fact: + expected_merged_output: + - name: vlan1 + vlan_id: 1 + + - name: vlan2 + vlan_id: 2 + l3_interface: "irb.12" + +- block: + - name: Merge the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_vlans: &id001 + config: + - name: vlan1 + vlan_id: 1 + + - name: vlan2 + vlan_id: 2 + l3_interface: "irb.12" + state: merged + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_merged_output | symmetric_difference(result['after']) |length\ + \ == 0 }}" + + - name: + Merge the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_vlans: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_vlans merged integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/overridden.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/overridden.yaml new file mode 100644 index 000000000..3341f8f25 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/overridden.yaml @@ -0,0 +1,47 @@ +--- +- ansible.builtin.debug: + msg: + START junos_vlans overridden integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_overridden_output: + - name: vlan1 + vlan_id: 100 + +- block: + - name: Override the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_vlans: &id001 + config: + - name: vlan1 + vlan_id: 100 + state: overridden + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_overridden_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Override the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_vlans: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_vlans overridden integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/parsed.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/parsed.yaml new file mode 100644 index 000000000..4fa120c2b --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/parsed.yaml @@ -0,0 +1,29 @@ +--- +- ansible.builtin.debug: + msg: + START junos_vlans parsed integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.set_fact: + expected_parsed_output: + - name: vlan1 + vlan_id: 1 + - name: vlan2 + vlan_id: 2 + l3_interface: "irb.12" + +- name: Parse externally provided vlans config to agnostic model + register: result + junipernetworks.junos.junos_vlans: + running_config: "{{ lookup('file', './fixtures/parsed.cfg') }}" + state: parsed + +- name: Assert that config was correctly parsed + ansible.builtin.assert: + that: + - "{{ expected_parsed_output == result['parsed'] }}" + - result['changed'] == false +- ansible.builtin.debug: + msg: + END junos_vlans parsed integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rendered.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rendered.yaml new file mode 100644 index 000000000..95e7af258 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rendered.yaml @@ -0,0 +1,28 @@ +--- +- ansible.builtin.debug: + msg: START junos_vlans rendered integration tests on connection={{ + ansible_connection }} + +- ansible.builtin.set_fact: + expected_rendered_output: 'vlan11vlan22irb.12' +- name: Render platform specific commands from task input using rendered state + register: result + junipernetworks.junos.junos_vlans: + config: + - name: vlan1 + vlan_id: 1 + + - name: vlan2 + vlan_id: 2 + l3_interface: "irb.12" + state: rendered + +- name: Assert that correct set of commands were rendered and task changed is false. + ansible.builtin.assert: + that: + - "{{ expected_rendered_output == result['rendered'] }}" + - result['changed'] == false + +- ansible.builtin.debug: + msg: END junos_vlans rendered integration tests on connection={{ + ansible_connection }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/replaced.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/replaced.yaml new file mode 100644 index 000000000..d9f102c64 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/replaced.yaml @@ -0,0 +1,50 @@ +--- +- ansible.builtin.debug: + msg: + START junos_vlans replaced integration tests on connection={{ ansible_connection + }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _base_config.yaml + +- ansible.builtin.set_fact: + expected_replaced_output: + - name: vlan1 + vlan_id: 10 + + - name: vlan2 + vlan_id: 2 + +- block: + - name: Replace the provided configuration with the exisiting running configuration + register: result + junipernetworks.junos.junos_vlans: &id001 + config: + - name: vlan1 + vlan_id: 10 + state: replaced + + - name: Assert the configuration is reflected on host + ansible.builtin.assert: + that: + - "{{ expected_replaced_output | symmetric_difference(result['after'])\ + \ |length == 0 }}" + + - name: + Replace the provided configuration with the existing running configuration + (IDEMPOTENT) + register: result + junipernetworks.junos.junos_vlans: *id001 + + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_vlans replaced integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rtt.yml new file mode 100644 index 000000000..dbd77cd82 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vlans/tests/netconf/rtt.yml @@ -0,0 +1,65 @@ +--- +- ansible.builtin.debug: + msg: START junos_vlans round trip integration tests on connection={{ + ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _remove_config.yaml + - ansible.builtin.include_tasks: _initial_config.yaml + + - name: Apply the provided configuration (base config) + register: base_config + junipernetworks.junos.junos_vlans: + config: + - name: vlan1 + vlan_id: 1 + - name: vlan2 + vlan_id: 2 + l3_interface: "irb.12" + state: merged + + - name: Gather interfaces facts + junipernetworks.junos.junos_facts: + gather_subset: + - default + gather_network_resources: + - vlans + + - name: Apply the provided configuration (config to be reverted) + register: result + junipernetworks.junos.junos_vlans: + config: + - name: vlan1 + vlan_id: 10 + state: replaced + + - name: Assert that changes were applied + ansible.builtin.assert: + that: result['changed'] == true + + - name: Revert back to base config using facts round trip + register: revert + junipernetworks.junos.junos_vlans: + config: "{{ ansible_facts['network_resources']['vlans'] }}" + state: replaced + + - name: Assert that before dicts are correct + ansible.builtin.assert: + that: + - result.changed == True + - "{{ result['after'] | symmetric_difference( revert['before'])\ + \ |length == 0 }}" + + - name: Assert that config was reverted + ansible.builtin.assert: + that: + - result.changed == True + - "{{ base_config['after'] | symmetric_difference( revert['after'])\ + \ |length == 0 }}" + always: + - ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.debug: + msg: + END junos_vlans round trip integration tests on connection={{ ansible_connection + }} diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/defaults/main.yaml new file mode 100644 index 000000000..9ef5ba516 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "*" +test_items: [] diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/meta/main.yml new file mode 100644 index 000000000..d80f5fbf3 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - prepare_junos_tests diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/main.yaml new file mode 100644 index 000000000..ac951c8f5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- name: Invoke netconf tasks + ansible.builtin.include_tasks: netconf.yaml diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/netconf.yaml new file mode 100644 index 000000000..3fa0553b5 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tasks/netconf.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect netconf test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/netconf" + patterns: "{{ testcase }}.yaml" + register: test_cases + connection: local + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + +- name: Run test case (connection=ansible.netcommon.netconf) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + vars: + ansible_connection: ansible.netcommon.netconf + tags: + - netconf diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tests/netconf/basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tests/netconf/basic.yaml new file mode 100644 index 000000000..160500f9c --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_vrf/tests/netconf/basic.yaml @@ -0,0 +1,320 @@ +--- +- ansible.builtin.debug: + msg="START junos_vrf netconf/basic.yaml on connection={{ ansible_connection + }}" + +- name: setup - remove vrf + junipernetworks.junos.junos_vrf: + name: test-1 + state: absent + +- name: Configure vrf and its parameter + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/6 + - ge-0/0/5 + rd: 192.0.2.3:10 + target: target:65513:111 + state: present + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\+ *test-1") + - result.diff.prepared is search("\+ *description test-vrf-1") + - result.diff.prepared is search("\+ *instance-type vrf") + - result.diff.prepared is search("\+ *interface ge-0/0/5.0") + - result.diff.prepared is search("\+ *interface ge-0/0/6.0") + - result.diff.prepared is search("\+ *route-distinguisher 192.0.2.3:10") + - result.diff.prepared is search("\+ *vrf-target target:65513:111") + +- name: Configure vrf and its parameter (idempotent) + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/6 + - ge-0/0/5 + rd: 192.0.2.3:10 + target: target:65513:111 + state: present + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Change vrf parameter + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + state: present + +- ansible.builtin.assert: + that: + - result.changed == true + - "'[edit routing-instances test-1]' in result.diff.prepared" + - result.diff.prepared is search("\+ *interface ge-0/0/2.0") + - result.diff.prepared is search("\+ *interface ge-0/0/3.0") + - "'[edit routing-instances test-1]' in result.diff.prepared" + - result.diff.prepared is search("\+ *route-distinguisher 192.0.2.1:10") + - result.diff.prepared is search("\+ *vrf-target target:65514:113") + +- name: Deactivate vrf + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + state: present + active: false + +- ansible.builtin.assert: + that: + - result.changed == true + - "'[edit routing-instances]' in result.diff.prepared" + - result.diff.prepared is search("! *inactive[:] test-1") + - "'[edit routing-instances test-1]' in result.diff.prepared" + - result.diff.prepared is search("! *inactive[:] interface ge-0/0/2.0") + - result.diff.prepared is search("! *inactive[:] interface ge-0/0/3.0") + - "'[edit routing-instances test-1]' in result.diff.prepared" + - result.diff.prepared is search("! *inactive[:] route-distinguisher") + - result.diff.prepared is search("! *inactive[:] vrf-target") + +- name: Activate vrf + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + state: present + active: true + +- ansible.builtin.assert: + that: + - result.changed == true + - "'[edit routing-instances]' in result.diff.prepared" + - result.diff.prepared is search("! *active[:] test-1") + - "'[edit routing-instances test-1]' in result.diff.prepared" + - result.diff.prepared is search("! *active[:] interface ge-0/0/2.0") + - result.diff.prepared is search("! *active[:] interface ge-0/0/3.0") + - "'[edit routing-instances test-1]' in result.diff.prepared" + - result.diff.prepared is search("! *active[:] route-distinguisher") + - result.diff.prepared is search("! *active[:] vrf-target") + +- name: Delete vrf + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + state: absent + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\- *test-1") + - result.diff.prepared is search("\- *description test-vrf-1") + - result.diff.prepared is search("\- *instance-type vrf") + - result.diff.prepared is search("\- *interface ge-0/0/2.0") + - result.diff.prepared is search("\- *interface ge-0/0/3.0") + - result.diff.prepared is search("\- *route-distinguisher 192.0.2.1:10") + - result.diff.prepared is search("\- *vrf-target target:65514:113") + +- name: Delete vrf (idempotent) + register: result + junipernetworks.junos.junos_vrf: + name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + state: absent + +- ansible.builtin.assert: + that: + - result.changed == false + +- name: Setup vrf using aggregate + register: result + junipernetworks.junos.junos_vrf: + aggregate: + - name: test-1 + + - name: test-2 + state: absent + +- name: Create vrf using aggregate + register: result + junipernetworks.junos.junos_vrf: + aggregate: + - name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + + - name: test-2 + description: test-vrf-2 + interfaces: + - ge-0/0/4 + - ge-0/0/5 + rd: 192.0.2.2:10 + target: target:65515:114 + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\+ *test-1") + - result.diff.prepared is search("\+ *description test-vrf-1") + - result.diff.prepared is search("\+ *instance-type vrf") + - result.diff.prepared is search("\+ *interface ge-0/0/2.0") + - result.diff.prepared is search("\+ *interface ge-0/0/3.0") + - result.diff.prepared is search("\+ *route-distinguisher 192.0.2.1:10") + - result.diff.prepared is search("\+ *vrf-target target:65514:113") + - result.diff.prepared is search("\+ *test-2") + - result.diff.prepared is search("\+ *description test-vrf-2") + - result.diff.prepared is search("\+ *instance-type vrf") + - result.diff.prepared is search("\+ *interface ge-0/0/4.0") + - result.diff.prepared is search("\+ *interface ge-0/0/5.0") + - result.diff.prepared is search("\+ *route-distinguisher 192.0.2.2:10") + - result.diff.prepared is search("\+ *vrf-target target:65515:114") + +- name: Deactivate vrf configuration using aggregate + register: result + junipernetworks.junos.junos_vrf: + aggregate: + - name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + + - name: test-2 + description: test-vrf-2 + interfaces: + - ge-0/0/4 + - ge-0/0/5 + rd: 192.0.2.2:10 + target: target:65515:114 + active: false + +- ansible.builtin.assert: + that: + - result.changed == true + - "'edit routing-instances test-1' in result.diff.prepared" + - result.diff.prepared is search("! *inactive[:] interface ge-0/0/2.0") + - result.diff.prepared is search("! *inactive[:] interface ge-0/0/3.0") + - result.diff.prepared is search("! *inactive[:] route-distinguisher") + - result.diff.prepared is search("! *inactive[:] vrf-target") + - "'edit routing-instances test-2' in result.diff.prepared" + - result.diff.prepared is search("! *inactive[:] interface ge-0/0/4.0") + - result.diff.prepared is search("! *inactive[:] interface ge-0/0/5.0") + - result.diff.prepared is search("! *inactive[:] route-distinguisher") + - result.diff.prepared is search("! *inactive[:] vrf-target") + +- name: Deactivate vrf configuration using aggregate + register: result + junipernetworks.junos.junos_vrf: + aggregate: + - name: test-1 + description: test-vrf-1 + interfaces: + - ge-0/0/3 + - ge-0/0/2 + rd: 192.0.2.1:10 + target: target:65514:113 + + - name: test-2 + description: test-vrf-2 + interfaces: + - ge-0/0/4 + - ge-0/0/5 + rd: 192.0.2.2:10 + target: target:65515:114 + active: true + +- ansible.builtin.assert: + that: + - result.changed == true + - "'edit routing-instances test-1' in result.diff.prepared" + - result.diff.prepared is search("! *active[:] interface ge-0/0/2.0") + - result.diff.prepared is search("! *active[:] interface ge-0/0/3.0") + - result.diff.prepared is search("! *active[:] route-distinguisher") + - result.diff.prepared is search("! *active[:] vrf-target") + - "'edit routing-instances test-2' in result.diff.prepared" + - result.diff.prepared is search("! *active[:] interface ge-0/0/4.0") + - result.diff.prepared is search("! *active[:] interface ge-0/0/5.0") + - result.diff.prepared is search("! *active[:] route-distinguisher") + - result.diff.prepared is search("! *active[:] vrf-target") + +- name: Delete vrf configuration using aggregate + register: result + junipernetworks.junos.junos_vrf: + aggregate: + - name: test-1 + + - name: test-2 + state: absent + +- ansible.builtin.assert: + that: + - result.changed == true + - result.diff.prepared is search("\- *test-1") + - result.diff.prepared is search("\- *description test-vrf-1") + - result.diff.prepared is search("\- *instance-type vrf") + - result.diff.prepared is search("\- *interface ge-0/0/2.0") + - result.diff.prepared is search("\- *interface ge-0/0/3.0") + - result.diff.prepared is search("\- *route-distinguisher 192.0.2.1:10") + - result.diff.prepared is search("\- *vrf-target target:65514:113") + - result.diff.prepared is search("\- *test-2") + - result.diff.prepared is search("\- *description test-vrf-2") + - result.diff.prepared is search("\- *instance-type vrf") + - result.diff.prepared is search("\- *interface ge-0/0/4.0") + - result.diff.prepared is search("\- *interface ge-0/0/5.0") + - result.diff.prepared is search("\- *route-distinguisher 192.0.2.2:10") + - result.diff.prepared is search("\- *vrf-target target:65515:114") + +- name: Delete vrf configuration using aggregate (idempotent) + register: result + junipernetworks.junos.junos_vrf: + aggregate: + - name: test-1 + + - name: test-2 + state: absent + +- ansible.builtin.assert: + that: + - result.changed == false + +- ansible.builtin.debug: + msg="END junos_vrf netconf/basic.yaml on connection={{ ansible_connection + }}" diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/meta/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/meta/main.yaml new file mode 100644 index 000000000..61d3ffe4f --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/meta/main.yaml @@ -0,0 +1,2 @@ +--- +allow_duplicates: true diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml new file mode 100644 index 000000000..1b9977466 --- /dev/null +++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml @@ -0,0 +1,17 @@ +--- +- name: Debug task + ansible.builtin.debug: msg="START prepare_junos_tests/main.yaml" + +- name: Ensure netconf is enabled + connection: ansible.netcommon.network_cli + tags: netconf + junipernetworks.junos.junos_netconf: + state: present + +- name: Wait for netconf server to come up + delegate_to: localhost + tags: netconf + ansible.builtin.wait_for: + host: "{{ hostvars[item].ansible_host }}" + port: 830 + with_inventory_hostnames: junos -- cgit v1.2.3