From 6e2205a0464f5adff80b4c464f5f40ced89cb82e Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Mon, 6 May 2019 00:34:45 -0400 Subject: [PATCH] Adding Netbox --- netbox.yml | 23 + roles/ansible-network.cisco_ios/.gitignore | 113 +++ roles/ansible-network.cisco_ios/.yamllint | 10 + roles/ansible-network.cisco_ios/CHANGELOG.rst | 120 ++++ roles/ansible-network.cisco_ios/LICENSE | 674 ++++++++++++++++++ roles/ansible-network.cisco_ios/README.md | 37 + .../action_plugins/extract_banners.py | 137 ++++ .../action_plugins/ios_user_manager.py | 111 +++ .../action_plugins/parse_validate_acl.py | 262 +++++++ roles/ansible-network.cisco_ios/bindep.txt | 7 + .../cloud_vpn/providers/csr/initiator.yaml | 5 + .../defaults/main.yml | 15 + .../cloud_vpn/configure_routing_initiator.md | 24 + .../docs/cloud_vpn/configure_vpn_initiator.md | 33 + .../docs/config_manager/get.md | 78 ++ .../docs/config_manager/load.md | 86 +++ .../docs/get_facts.md | 166 +++++ .../filter_plugins/ios.py | 35 + .../handlers/main.yml | 2 + .../includes/args_adapter.yaml | 13 + .../includes/checkpoint/create.yaml | 26 + .../includes/checkpoint/remove.yaml | 15 + .../includes/checkpoint/restore.yaml | 32 + .../includes/configure/merge.yaml | 59 ++ .../includes/configure/replace.yaml | 59 ++ .../includes/configure/terminal.yaml | 41 ++ .../includes/init.yaml | 34 + .../includes/run_cli.yaml | 25 + .../includes/wrapper.yaml | 102 +++ .../library/ios_capabilities.py | 65 ++ .../library/ios_command.py | 241 +++++++ .../library/ios_user_manager.py | 48 ++ .../meta/.galaxy_install_info | 1 + roles/ansible-network.cisco_ios/meta/main.yml | 41 ++ .../cli/show_cdp_neighbors_detail.yaml | 51 ++ .../parser_templates/cli/show_interfaces.yaml | 119 ++++ .../cli/show_interfaces_transceiver.yaml | 75 ++ .../cli/show_ip_bgp_summary.yaml | 77 ++ .../cli/show_ip_vrf_detail.yaml | 138 ++++ .../cli/show_lldp_neighbors_detail.yaml | 52 ++ .../parser_templates/cli/show_version.yaml | 109 +++ .../config/show_ip_prefix_list.yaml | 87 +++ .../config/show_run_interface.yaml | 90 +++ .../config_manager/global.yaml | 23 + .../net_operations/show_ip_access_list.yaml | 38 + .../net_operations/show_logs_acl_logs.yaml | 10 + .../tasks/cloud_vpn/add_host_initiator.yaml | 3 + .../tasks/cloud_vpn/add_host_responder.yaml | 3 + .../configure_routing_initiator.yaml | 3 + .../configure_routing_responder.yaml | 3 + .../cloud_vpn/configure_vpn_initiator.yaml | 3 + .../cloud_vpn/configure_vpn_responder.yaml | 3 + .../tasks/cloud_vpn/noop.yaml | 1 + .../providers/csr/initiator/add_host.yaml | 17 + .../csr/initiator/configure_routing.yaml | 13 + .../csr/initiator/configure_vpn.yaml | 13 + .../csr/initiator/show_login_info.yaml | 6 + .../cloud_vpn/show_login_info_initiator.yaml | 3 + .../cloud_vpn/show_login_info_responder.yaml | 3 + .../cloud_vpn/unconfigure_initiator.yaml | 1 + .../cloud_vpn/unconfigure_responder.yaml | 1 + .../tasks/config_manager/get.yaml | 17 + .../tasks/config_manager/load.yaml | 109 +++ .../tasks/config_manager/save.yaml | 7 + .../tasks/configure_user.yaml | 49 ++ .../tasks/get_facts.yaml | 25 + .../ansible-network.cisco_ios/tasks/main.yml | 22 + .../net_operations/parse_validate_acl.yaml | 14 + .../pre_config_sink_device.yaml | 29 + .../sink_packet_capture_logs.yaml | 32 + .../ansible-network.cisco_ios/tasks/noop.yaml | 4 + .../aws_vpn/configure_routing_bgp.j2 | 13 + .../aws_vpn/configure_routing_static.j2 | 2 + .../csr/initiator/aws_vpn/configure_vpn.j2 | 115 +++ .../csr/initiator/configure_routing_bgp.j2 | 13 + .../csr/initiator/configure_routing_static.j2 | 1 + .../providers/csr/initiator/configure_vpn.j2 | 57 ++ .../templates/configure_user.j2 | 30 + .../test-requirements.txt | 2 + .../config_manager/tasks/get.yml | 12 + .../config_manager/tasks/load.yml | 61 ++ .../config_manager/tasks/main.yml | 13 + .../templates/csr01_config_error.j2 | 5 + .../templates/csr01_config_valid.j2 | 5 + .../config_manager/vars/default.yml | 6 + .../config_manager/vars/load.yml | 9 + .../tests/config_manager/test.yml | 3 + .../ansible-network.cisco_ios/tests/inventory | 1 + .../cli/show_interfaces/03.16.08.S.txt | 377 ++++++++++ .../cli/show_interfaces/main.yaml | 33 + .../cli/show_ip_bgp_summary/03.14.00.S.txt | 16 + .../cli/show_ip_bgp_summary/12.2(33)SXH5.txt | 16 + .../cli/show_ip_bgp_summary/15.1(2)T5.txt | 14 + .../show_ip_bgp_summary/bgp_not_active.txt | 1 + .../cli/show_ip_bgp_summary/main.yaml | 95 +++ .../cli/show_ip_vrf_detail/03.14.00.S.txt | 47 ++ .../cli/show_ip_vrf_detail/12.2(33)SXH5.txt | 47 ++ .../cli/show_ip_vrf_detail/main.yaml | 58 ++ .../cli/show_version/15.1.4.txt | 65 ++ .../cli/show_version/15.5.1.txt | 65 ++ .../cli/show_version/16.6.4.txt | 82 +++ .../cli/show_version/main.yaml | 72 ++ .../tests/test_config_manager.yaml | 5 + .../tests/test_parser_templates.yaml | 31 + roles/ansible-network.cisco_ios/tox.ini | 25 + .../vars/get_facts_command_map.yaml | 63 ++ roles/ansible-network.cisco_ios/vars/main.yml | 3 + .../ansible-network.config_manager/.gitignore | 1 + .../.travis.yml | 29 + .../CHANGELOG.rst | 30 + roles/ansible-network.config_manager/LICENSE | 674 ++++++++++++++++++ .../ansible-network.config_manager/README.md | 27 + .../changelogs/config.yaml | 22 + .../defaults/main.yml | 4 + .../docs/get.md | 64 ++ .../docs/load.md | 91 +++ .../docs/save.md | 34 + .../handlers/main.yml | 2 + .../includes/init.yaml | 14 + .../meta/.galaxy_install_info | 1 + .../meta/get_spec.yaml | 10 + .../meta/load_spec.yaml | 50 ++ .../meta/main.yml | 38 + .../meta/save_spec.yaml | 10 + .../tasks/edit.yaml | 9 + .../tasks/get.yaml | 9 + .../tasks/load.yaml | 74 ++ .../tasks/main.yml | 21 + .../tasks/noop.yaml | 4 + .../tasks/save.yaml | 9 + .../tests/inventory | 2 + .../tests/test.yml | 5 + .../vars/main.yml | 2 + .../.github/ISSUE_TEMPLATE.md | 53 ++ .../ansible-network.network-engine/.gitignore | 5 + .../ansible-network.network-engine/.yamllint | 14 + .../ANNOUNCE.md | 29 + .../CHANGELOG.rst | 433 +++++++++++ .../CONTRIBUTING.md | 91 +++ roles/ansible-network.network-engine/LICENSE | 674 ++++++++++++++++++ .../ansible-network.network-engine/README.md | 45 ++ .../action_plugins/cli.py | 174 +++++ .../action_plugins/command_parser.py | 416 +++++++++++ .../action_plugins/textfsm_parser.py | 81 +++ .../action_plugins/validate_role_spec.py | 127 ++++ .../verify_dependent_role_version.py | 188 +++++ .../ansible-network.network-engine/bindep.txt | 7 + .../changelogs/config.yaml | 22 + .../fragments/v0-initial-release.yaml | 13 + .../changelogs/fragments/v251-bugfixes.yaml | 5 + .../changelogs/fragments/v251-docs.yaml | 3 + .../fragments/v251-terminology-changes.yaml | 8 + .../changelogs/fragments/v252-bugfixes.yaml | 3 + .../fragments/v252-filter-plugins.yaml | 6 + .../fragments/v252-lookup-plugins.yaml | 6 + .../fragments/v252-minorchanges.yaml | 4 + .../changelogs/fragments/v252-tasks.yaml | 3 + .../fragments/v253-minorchanges.yaml | 3 + .../fragments/v253-removed-features.yaml | 3 + .../changelogs/fragments/v254-bugfixes.yaml | 4 + .../fragments/v254-minorchanges.yaml | 4 + .../fragments/v260-initial-release.yaml | 3 + .../changelogs/fragments/v261-bugfixes.yaml | 3 + .../changelogs/fragments/v261-docs.yaml | 3 + .../changelogs/fragments/v262-bugfixes.yaml | 3 + .../fragments/v262-filter-plugins.yaml | 3 + .../fragments/v262-lookup-plugins.yaml | 4 + .../changelogs/fragments/v262-modules.yaml | 3 + .../changelogs/fragments/v263-bugfixes.yaml | 3 + .../fragments/v263-minorchanges.yaml | 3 + .../changelogs/fragments/v264-bugfixes.yaml | 3 + .../changelogs/fragments/v264-docs.yaml | 3 + .../fragments/v264-removed-features.yaml | 4 + .../changelogs/fragments/v265-bugfixes.yaml | 3 + .../fragments/v266-minor-changes.yaml | 3 + .../fragments/v266-removed-features.yaml | 3 + .../changelogs/fragments/v270-bugfixes.yaml | 5 + .../fragments/v270-initial-release.yaml | 3 + .../fragments/v271-minorchanges.yaml | 3 + .../fragments/v272-minorchanges.yaml | 4 + .../fragments/v273-deprecated-features.yaml | 3 + .../fragments/v273-minor-changes.yaml | 3 + .../changelogs/fragments/v274-bugfixes.yaml | 4 + .../changelogs/fragments/v275-bugfixes.yaml | 3 + .../defaults/main.yml | 19 + .../docs/directives/parser_directives.md | 283 ++++++++ .../docs/directives/template_directives.md | 276 +++++++ .../docs/plugins/filter_plugins.md | 50 ++ .../plugins/verify_dependent_role_version.md | 24 + .../docs/tasks/cli.md | 125 ++++ .../docs/tests/test_guide.md | 55 ++ .../docs/user_guide/README.md | 48 ++ .../docs/user_guide/command_parser.md | 223 ++++++ .../docs/user_guide/textfsm_parser.md | 82 +++ .../filter_plugins/network_engine.py | 122 ++++ .../includes/init.yaml | 15 + .../library/command_parser.py | 54 ++ .../library/net_facts.py | 58 ++ .../library/textfsm_parser.py | 70 ++ .../lookup_plugins/__init__.py | 0 .../lookup_plugins/config_template.py | 48 ++ .../lookup_plugins/json_template.py | 68 ++ .../lookup_plugins/netcfg_diff.py | 119 ++++ .../lookup_plugins/network_template.py | 257 +++++++ .../meta/.galaxy_install_info | 1 + .../meta/main.yml | 37 + .../requirements.txt | 2 + .../tasks/cli.yaml | 10 + .../tasks/main.yml | 2 + .../test-requirements.txt | 3 + .../tests/ansible.cfg | 4 + .../command_parser/defaults/main.yaml | 4 + .../output/ios/show_interfaces.txt | 85 +++ .../output/ios/show_version.txt | 44 ++ .../parser_templates/ios/show_interfaces.yaml | 61 ++ .../ios/show_interfaces_expand.yaml | 61 ++ .../parser_templates/ios/show_version.yaml | 48 ++ .../ios/show_version_expand.yaml | 49 ++ .../command_parser/tasks/ios.yaml | 79 ++ .../command_parser/tasks/main.yaml | 7 + .../tests/command_parser/test.yml | 5 + .../tasks/config_template.yaml | 12 + .../config_template/tasks/main.yaml | 7 + .../config_template/templates/fail.j2 | 1 + .../config_template/templates/pass.j2 | 1 + .../tests/config_template/test.yml | 5 + .../tasks/interface_range.yaml | 35 + .../interface_range/tasks/main.yaml | 7 + .../tests/interface_range/test.yml | 5 + .../tasks/interface_split.yaml | 28 + .../interface_split/tasks/main.yaml | 7 + .../tests/interface_split/test.yml | 5 + .../tests/inventory | 2 + .../json_template/defaults/main.yaml | 2 + .../json_template/tasks/json_lookup.yaml | 14 + .../json_template/tasks/main.yaml | 7 + .../json_template/templates/config.json | 26 + .../tests/json_template/test.yml | 5 + .../netcfg_diff/defaults/main.yaml | 6 + .../netcfg_diff/files/ios/have.txt | 137 ++++ .../netcfg_diff/files/ios/want.txt | 138 ++++ .../netcfg_diff/netcfg_diff/tasks/ios.yaml | 64 ++ .../netcfg_diff/netcfg_diff/tasks/main.yaml | 7 + .../tests/netcfg_diff/test.yml | 5 + .../tests/test.yml | 13 + .../tests/textfsm_parser/test.yml | 5 + .../textfsm_parser/defaults/main.yaml | 3 + .../output/ios/show_interfaces.txt | 85 +++ .../output/ios/show_version.txt | 44 ++ .../parser_templates/ios/show_interfaces | 10 + .../parser_templates/ios/show_version | 11 + .../textfsm_parser/tasks/ios.yaml | 42 ++ .../textfsm_parser/tasks/main.yaml | 7 + .../tests/to_lines/test.yml | 5 + .../tests/to_lines/to_lines/tasks/main.yaml | 7 + .../to_lines/to_lines/tasks/to_lines.yaml | 9 + .../tests/validate_role_spec/test.yml | 5 + .../validate_role_spec/meta/failedtest.yaml | 3 + .../validate_role_spec/meta/test.yaml | 17 + .../validate_role_spec/tasks/main.yaml | 10 + .../tasks/validate_role_spec.yaml | 10 + .../tasks/validate_role_spec_failed.yaml | 11 + .../tests/vlan_compress/test.yml | 5 + .../vlan_compress/tasks/main.yaml | 7 + .../vlan_compress/tasks/vlan_compress.yaml | 36 + .../tests/vlan_expand/test.yml | 5 + .../vlan_expand/vlan_expand/tasks/main.yaml | 7 + .../vlan_expand/tasks/vlan_expand.yaml | 35 + roles/ansible-network.network-engine/tox.ini | 31 + .../vars/main.yml | 2 + roles/kickstart-rhv-template/README.md | 40 ++ .../kickstart-rhv-template/defaults/main.yml | 2 + .../kickstart-rhv-template/handlers/main.yml | 2 + roles/kickstart-rhv-template/meta/main.yml | 60 ++ roles/kickstart-rhv-template/tasks/main.yml | 14 + roles/kickstart-rhv-template/tests/inventory | 2 + roles/kickstart-rhv-template/tests/test.yml | 5 + roles/kickstart-rhv-template/vars/main.yml | 2 + 278 files changed, 12767 insertions(+) create mode 100644 netbox.yml create mode 100644 roles/ansible-network.cisco_ios/.gitignore create mode 100644 roles/ansible-network.cisco_ios/.yamllint create mode 100644 roles/ansible-network.cisco_ios/CHANGELOG.rst create mode 100644 roles/ansible-network.cisco_ios/LICENSE create mode 100644 roles/ansible-network.cisco_ios/README.md create mode 100644 roles/ansible-network.cisco_ios/action_plugins/extract_banners.py create mode 100644 roles/ansible-network.cisco_ios/action_plugins/ios_user_manager.py create mode 100644 roles/ansible-network.cisco_ios/action_plugins/parse_validate_acl.py create mode 100644 roles/ansible-network.cisco_ios/bindep.txt create mode 100644 roles/ansible-network.cisco_ios/defaults/cloud_vpn/providers/csr/initiator.yaml create mode 100644 roles/ansible-network.cisco_ios/defaults/main.yml create mode 100644 roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_routing_initiator.md create mode 100644 roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_vpn_initiator.md create mode 100644 roles/ansible-network.cisco_ios/docs/config_manager/get.md create mode 100644 roles/ansible-network.cisco_ios/docs/config_manager/load.md create mode 100644 roles/ansible-network.cisco_ios/docs/get_facts.md create mode 100644 roles/ansible-network.cisco_ios/filter_plugins/ios.py create mode 100644 roles/ansible-network.cisco_ios/handlers/main.yml create mode 100644 roles/ansible-network.cisco_ios/includes/args_adapter.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/checkpoint/create.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/checkpoint/remove.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/checkpoint/restore.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/configure/merge.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/configure/replace.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/configure/terminal.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/init.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/run_cli.yaml create mode 100644 roles/ansible-network.cisco_ios/includes/wrapper.yaml create mode 100644 roles/ansible-network.cisco_ios/library/ios_capabilities.py create mode 100644 roles/ansible-network.cisco_ios/library/ios_command.py create mode 100644 roles/ansible-network.cisco_ios/library/ios_user_manager.py create mode 100644 roles/ansible-network.cisco_ios/meta/.galaxy_install_info create mode 100644 roles/ansible-network.cisco_ios/meta/main.yml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_cdp_neighbors_detail.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces_transceiver.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_bgp_summary.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_vrf_detail.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_lldp_neighbors_detail.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/cli/show_version.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/config/show_ip_prefix_list.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/config/show_run_interface.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/config_manager/global.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/net_operations/show_ip_access_list.yaml create mode 100644 roles/ansible-network.cisco_ios/parser_templates/net_operations/show_logs_acl_logs.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/add_host_initiator.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/add_host_responder.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/configure_routing_initiator.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/configure_routing_responder.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/configure_vpn_initiator.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/configure_vpn_responder.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/noop.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/providers/csr/initiator/add_host.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/providers/csr/initiator/configure_routing.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/providers/csr/initiator/configure_vpn.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/providers/csr/initiator/show_login_info.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/show_login_info_initiator.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/show_login_info_responder.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/unconfigure_initiator.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/cloud_vpn/unconfigure_responder.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/config_manager/get.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/config_manager/load.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/config_manager/save.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/configure_user.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/get_facts.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/main.yml create mode 100644 roles/ansible-network.cisco_ios/tasks/net_operations/parse_validate_acl.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/net_operations/pre_config_sink_device.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/net_operations/sink_packet_capture_logs.yaml create mode 100644 roles/ansible-network.cisco_ios/tasks/noop.yaml create mode 100644 roles/ansible-network.cisco_ios/templates/cloud_vpn/providers/csr/initiator/aws_vpn/configure_routing_bgp.j2 create mode 100644 roles/ansible-network.cisco_ios/templates/cloud_vpn/providers/csr/initiator/aws_vpn/configure_routing_static.j2 create mode 100644 roles/ansible-network.cisco_ios/templates/cloud_vpn/providers/csr/initiator/aws_vpn/configure_vpn.j2 create mode 100644 roles/ansible-network.cisco_ios/templates/cloud_vpn/providers/csr/initiator/configure_routing_bgp.j2 create mode 100644 roles/ansible-network.cisco_ios/templates/cloud_vpn/providers/csr/initiator/configure_routing_static.j2 create mode 100644 roles/ansible-network.cisco_ios/templates/cloud_vpn/providers/csr/initiator/configure_vpn.j2 create mode 100644 roles/ansible-network.cisco_ios/templates/configure_user.j2 create mode 100644 roles/ansible-network.cisco_ios/test-requirements.txt create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/tasks/get.yml create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/tasks/load.yml create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/tasks/main.yml create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/templates/csr01_config_error.j2 create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/templates/csr01_config_valid.j2 create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/vars/default.yml create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/config_manager/vars/load.yml create mode 100644 roles/ansible-network.cisco_ios/tests/config_manager/test.yml create mode 100644 roles/ansible-network.cisco_ios/tests/inventory create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_interfaces/03.16.08.S.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_interfaces/main.yaml create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_bgp_summary/03.14.00.S.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_bgp_summary/12.2(33)SXH5.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_bgp_summary/15.1(2)T5.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_bgp_summary/bgp_not_active.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_bgp_summary/main.yaml create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_vrf_detail/03.14.00.S.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_vrf_detail/12.2(33)SXH5.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_ip_vrf_detail/main.yaml create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_version/15.1.4.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_version/15.5.1.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_version/16.6.4.txt create mode 100644 roles/ansible-network.cisco_ios/tests/parser_templates/cli/show_version/main.yaml create mode 100755 roles/ansible-network.cisco_ios/tests/test_config_manager.yaml create mode 100755 roles/ansible-network.cisco_ios/tests/test_parser_templates.yaml create mode 100644 roles/ansible-network.cisco_ios/tox.ini create mode 100644 roles/ansible-network.cisco_ios/vars/get_facts_command_map.yaml create mode 100644 roles/ansible-network.cisco_ios/vars/main.yml create mode 100644 roles/ansible-network.config_manager/.gitignore create mode 100644 roles/ansible-network.config_manager/.travis.yml create mode 100644 roles/ansible-network.config_manager/CHANGELOG.rst create mode 100644 roles/ansible-network.config_manager/LICENSE create mode 100644 roles/ansible-network.config_manager/README.md create mode 100644 roles/ansible-network.config_manager/changelogs/config.yaml create mode 100644 roles/ansible-network.config_manager/defaults/main.yml create mode 100644 roles/ansible-network.config_manager/docs/get.md create mode 100644 roles/ansible-network.config_manager/docs/load.md create mode 100644 roles/ansible-network.config_manager/docs/save.md create mode 100644 roles/ansible-network.config_manager/handlers/main.yml create mode 100644 roles/ansible-network.config_manager/includes/init.yaml create mode 100644 roles/ansible-network.config_manager/meta/.galaxy_install_info create mode 100644 roles/ansible-network.config_manager/meta/get_spec.yaml create mode 100644 roles/ansible-network.config_manager/meta/load_spec.yaml create mode 100644 roles/ansible-network.config_manager/meta/main.yml create mode 100644 roles/ansible-network.config_manager/meta/save_spec.yaml create mode 100644 roles/ansible-network.config_manager/tasks/edit.yaml create mode 100644 roles/ansible-network.config_manager/tasks/get.yaml create mode 100644 roles/ansible-network.config_manager/tasks/load.yaml create mode 100644 roles/ansible-network.config_manager/tasks/main.yml create mode 100644 roles/ansible-network.config_manager/tasks/noop.yaml create mode 100644 roles/ansible-network.config_manager/tasks/save.yaml create mode 100644 roles/ansible-network.config_manager/tests/inventory create mode 100644 roles/ansible-network.config_manager/tests/test.yml create mode 100644 roles/ansible-network.config_manager/vars/main.yml create mode 100644 roles/ansible-network.network-engine/.github/ISSUE_TEMPLATE.md create mode 100644 roles/ansible-network.network-engine/.gitignore create mode 100644 roles/ansible-network.network-engine/.yamllint create mode 100644 roles/ansible-network.network-engine/ANNOUNCE.md create mode 100644 roles/ansible-network.network-engine/CHANGELOG.rst create mode 100644 roles/ansible-network.network-engine/CONTRIBUTING.md create mode 100644 roles/ansible-network.network-engine/LICENSE create mode 100644 roles/ansible-network.network-engine/README.md create mode 100644 roles/ansible-network.network-engine/action_plugins/cli.py create mode 100644 roles/ansible-network.network-engine/action_plugins/command_parser.py create mode 100644 roles/ansible-network.network-engine/action_plugins/textfsm_parser.py create mode 100644 roles/ansible-network.network-engine/action_plugins/validate_role_spec.py create mode 100644 roles/ansible-network.network-engine/action_plugins/verify_dependent_role_version.py create mode 100644 roles/ansible-network.network-engine/bindep.txt create mode 100644 roles/ansible-network.network-engine/changelogs/config.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v0-initial-release.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v251-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v251-docs.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v251-terminology-changes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v252-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v252-filter-plugins.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v252-lookup-plugins.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v252-minorchanges.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v252-tasks.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v253-minorchanges.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v253-removed-features.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v254-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v254-minorchanges.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v260-initial-release.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v261-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v261-docs.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v262-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v262-filter-plugins.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v262-lookup-plugins.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v262-modules.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v263-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v263-minorchanges.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v264-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v264-docs.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v264-removed-features.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v265-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v266-minor-changes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v266-removed-features.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v270-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v270-initial-release.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v271-minorchanges.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v272-minorchanges.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v273-deprecated-features.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v273-minor-changes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v274-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/changelogs/fragments/v275-bugfixes.yaml create mode 100644 roles/ansible-network.network-engine/defaults/main.yml create mode 100644 roles/ansible-network.network-engine/docs/directives/parser_directives.md create mode 100644 roles/ansible-network.network-engine/docs/directives/template_directives.md create mode 100644 roles/ansible-network.network-engine/docs/plugins/filter_plugins.md create mode 100644 roles/ansible-network.network-engine/docs/plugins/verify_dependent_role_version.md create mode 100644 roles/ansible-network.network-engine/docs/tasks/cli.md create mode 100644 roles/ansible-network.network-engine/docs/tests/test_guide.md create mode 100644 roles/ansible-network.network-engine/docs/user_guide/README.md create mode 100644 roles/ansible-network.network-engine/docs/user_guide/command_parser.md create mode 100644 roles/ansible-network.network-engine/docs/user_guide/textfsm_parser.md create mode 100644 roles/ansible-network.network-engine/filter_plugins/network_engine.py create mode 100644 roles/ansible-network.network-engine/includes/init.yaml create mode 100644 roles/ansible-network.network-engine/library/command_parser.py create mode 100644 roles/ansible-network.network-engine/library/net_facts.py create mode 100644 roles/ansible-network.network-engine/library/textfsm_parser.py create mode 100644 roles/ansible-network.network-engine/lookup_plugins/__init__.py create mode 100644 roles/ansible-network.network-engine/lookup_plugins/config_template.py create mode 100644 roles/ansible-network.network-engine/lookup_plugins/json_template.py create mode 100644 roles/ansible-network.network-engine/lookup_plugins/netcfg_diff.py create mode 100644 roles/ansible-network.network-engine/lookup_plugins/network_template.py create mode 100644 roles/ansible-network.network-engine/meta/.galaxy_install_info create mode 100644 roles/ansible-network.network-engine/meta/main.yml create mode 100644 roles/ansible-network.network-engine/requirements.txt create mode 100644 roles/ansible-network.network-engine/tasks/cli.yaml create mode 100644 roles/ansible-network.network-engine/tasks/main.yml create mode 100644 roles/ansible-network.network-engine/test-requirements.txt create mode 100644 roles/ansible-network.network-engine/tests/ansible.cfg create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/defaults/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/output/ios/show_interfaces.txt create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/output/ios/show_version.txt create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/parser_templates/ios/show_interfaces.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/parser_templates/ios/show_interfaces_expand.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/parser_templates/ios/show_version.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/parser_templates/ios/show_version_expand.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/tasks/ios.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/command_parser/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/command_parser/test.yml create mode 100644 roles/ansible-network.network-engine/tests/config_template/config_template/tasks/config_template.yaml create mode 100644 roles/ansible-network.network-engine/tests/config_template/config_template/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/config_template/config_template/templates/fail.j2 create mode 100644 roles/ansible-network.network-engine/tests/config_template/config_template/templates/pass.j2 create mode 100644 roles/ansible-network.network-engine/tests/config_template/test.yml create mode 100644 roles/ansible-network.network-engine/tests/interface_range/interface_range/tasks/interface_range.yaml create mode 100644 roles/ansible-network.network-engine/tests/interface_range/interface_range/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/interface_range/test.yml create mode 100644 roles/ansible-network.network-engine/tests/interface_split/interface_split/tasks/interface_split.yaml create mode 100644 roles/ansible-network.network-engine/tests/interface_split/interface_split/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/interface_split/test.yml create mode 100644 roles/ansible-network.network-engine/tests/inventory create mode 100644 roles/ansible-network.network-engine/tests/json_template/json_template/defaults/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/json_template/json_template/tasks/json_lookup.yaml create mode 100644 roles/ansible-network.network-engine/tests/json_template/json_template/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/json_template/json_template/templates/config.json create mode 100644 roles/ansible-network.network-engine/tests/json_template/test.yml create mode 100644 roles/ansible-network.network-engine/tests/netcfg_diff/netcfg_diff/defaults/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/netcfg_diff/netcfg_diff/files/ios/have.txt create mode 100644 roles/ansible-network.network-engine/tests/netcfg_diff/netcfg_diff/files/ios/want.txt create mode 100644 roles/ansible-network.network-engine/tests/netcfg_diff/netcfg_diff/tasks/ios.yaml create mode 100644 roles/ansible-network.network-engine/tests/netcfg_diff/netcfg_diff/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/netcfg_diff/test.yml create mode 100644 roles/ansible-network.network-engine/tests/test.yml create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/test.yml create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/defaults/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/output/ios/show_interfaces.txt create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/output/ios/show_version.txt create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/parser_templates/ios/show_interfaces create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/parser_templates/ios/show_version create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/tasks/ios.yaml create mode 100644 roles/ansible-network.network-engine/tests/textfsm_parser/textfsm_parser/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/to_lines/test.yml create mode 100644 roles/ansible-network.network-engine/tests/to_lines/to_lines/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/to_lines/to_lines/tasks/to_lines.yaml create mode 100644 roles/ansible-network.network-engine/tests/validate_role_spec/test.yml create mode 100644 roles/ansible-network.network-engine/tests/validate_role_spec/validate_role_spec/meta/failedtest.yaml create mode 100644 roles/ansible-network.network-engine/tests/validate_role_spec/validate_role_spec/meta/test.yaml create mode 100644 roles/ansible-network.network-engine/tests/validate_role_spec/validate_role_spec/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/validate_role_spec/validate_role_spec/tasks/validate_role_spec.yaml create mode 100644 roles/ansible-network.network-engine/tests/validate_role_spec/validate_role_spec/tasks/validate_role_spec_failed.yaml create mode 100644 roles/ansible-network.network-engine/tests/vlan_compress/test.yml create mode 100644 roles/ansible-network.network-engine/tests/vlan_compress/vlan_compress/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/vlan_compress/vlan_compress/tasks/vlan_compress.yaml create mode 100644 roles/ansible-network.network-engine/tests/vlan_expand/test.yml create mode 100644 roles/ansible-network.network-engine/tests/vlan_expand/vlan_expand/tasks/main.yaml create mode 100644 roles/ansible-network.network-engine/tests/vlan_expand/vlan_expand/tasks/vlan_expand.yaml create mode 100644 roles/ansible-network.network-engine/tox.ini create mode 100644 roles/ansible-network.network-engine/vars/main.yml create mode 100644 roles/kickstart-rhv-template/README.md create mode 100644 roles/kickstart-rhv-template/defaults/main.yml create mode 100644 roles/kickstart-rhv-template/handlers/main.yml create mode 100644 roles/kickstart-rhv-template/meta/main.yml create mode 100644 roles/kickstart-rhv-template/tasks/main.yml create mode 100644 roles/kickstart-rhv-template/tests/inventory create mode 100644 roles/kickstart-rhv-template/tests/test.yml create mode 100644 roles/kickstart-rhv-template/vars/main.yml diff --git a/netbox.yml b/netbox.yml new file mode 100644 index 0000000..5b677ff --- /dev/null +++ b/netbox.yml @@ -0,0 +1,23 @@ +plugin: netbox +validate_certs: False +config_context: True +group_by: + - device_roles + + #query_filters: + # - role: core-switch + +#query_filters: +# - role: network-edge-router + +# Query filters are passed directly as an argument to the fetching queries. +# You can repeat tags in the query string. + + #query_filters: + # - role: server + # - tag: web + # - tag: production + + #compose: + # foo: last_updated + # bar: display_name diff --git a/roles/ansible-network.cisco_ios/.gitignore b/roles/ansible-network.cisco_ios/.gitignore new file mode 100644 index 0000000..d49245c --- /dev/null +++ b/roles/ansible-network.cisco_ios/.gitignore @@ -0,0 +1,113 @@ +# IDE +.vscode/ + +# Ansible +*.log +*.retry +*.swp +!*.gitkeep +ansible.cfg + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/roles/ansible-network.cisco_ios/.yamllint b/roles/ansible-network.cisco_ios/.yamllint new file mode 100644 index 0000000..a4d53d6 --- /dev/null +++ b/roles/ansible-network.cisco_ios/.yamllint @@ -0,0 +1,10 @@ +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable diff --git a/roles/ansible-network.cisco_ios/CHANGELOG.rst b/roles/ansible-network.cisco_ios/CHANGELOG.rst new file mode 100644 index 0000000..fea0ad0 --- /dev/null +++ b/roles/ansible-network.cisco_ios/CHANGELOG.rst @@ -0,0 +1,120 @@ +========================= +Ansible Network cisco_ios +========================= +.. _cisco_ios_v2.7.1: + +v2.7.1 +====== + +.. _cisco_ios_v2.7.1_Minor Changes: + +Minor Changes +------------- + +- Adds parser for reload reason. `ios-#87 `_. +- Fixed message ``missing required arg: config_manager_text``. `ios-#88 `_. +- Remove set defaults task files. `ios-#89 `_. +- Use default template if no specific peer provider folder is present. `ios-#90 `_. +- Add unconfigure task hooks. `ios-#92 `_. + +.. _cisco_ios_v2.7.0: + +v2.7.0 +====== + +.. _cisco_ios_v2.7.0_Major Changes: + +Major Changes +------------- + +- Initial release of 2.7.0 ``cisco_ios`` Ansible role that is supported with Ansible 2.7.0 +- Dependant role ``ansible-network.network-engine`` should be upgraded with version >= 2.7.2 + +.. _cisco_ios_v2.7.0_Bugfixes: + +Bugfixes +-------- + +- multiline banner processing (cli_config issue) (#69) +- Ensure that subset is a list. Align docs with fact map (#47) +- Created test for show_interfaces parser (#58) +- fix for 'interfaces' facts (#55) +- fix for handling config text with lines containing only whitespace chars (#64) + +.. _cisco_ios_v2.6.3: + +v2.6.3 +====== + +.. _cisco_ios_v2.6.3_New Features + +New Features +------------ + +- NEW provider tasks and parsers for net_operations role + +.. _cisco_ios_v2.6.3_Bugfixes: + +Bugfixes +-------- + +- configure_user task should use config_manager_file instead of config_manager_text +- uptime facts from cisco IOS has separate keys for year, week, days hours and time + +.. _cisco_ios_v2.6.2: + +v2.6.2 +====== + +.. _cisco_ios_v2.6.2_New Features + +New Features +------------ + +- NEW Added CPF and Fiber Optic DOM parser +- NEW Added dependency role plugin check + +.. _cisco_ios_v2.6.1: + +v2.6.1 +====== + +.. _cisco_ios_v2.6.1_New Action Plugins: + +New Action Plugins +------------------ + +- NEW ``ios_user_manager`` action plugin + +.. _cisco_ios_v2.6.1_New Tasks: + +New Tasks +--------- + +- NEW ``configure_user`` task + +.. _cisco_ios_v2.6.1_Bugfixes: + +Bugfixes +-------- + +- Refactor vrf and bgp output and improve reliability (#29) +- better support for working with config_manager tasks + +devel +===== + +New Functions +------------- + +- NEW `get_facts` retrive and parse facts from cisco ios devices +- NEW `config_manager/get` support for config_manager get function +- NEW `config_manager/load` support for config_manager load function +- NEW `config_manager/save` support for config_manager save function +- NEW `configure_user` support for configuring users on cisco ios devices + + +Major Changes +------------- + +- Initial release of the `cisco_ios` role. diff --git a/roles/ansible-network.cisco_ios/LICENSE b/roles/ansible-network.cisco_ios/LICENSE new file mode 100644 index 0000000..9cecc1d --- /dev/null +++ b/roles/ansible-network.cisco_ios/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/roles/ansible-network.cisco_ios/README.md b/roles/ansible-network.cisco_ios/README.md new file mode 100644 index 0000000..0a4bc4b --- /dev/null +++ b/roles/ansible-network.cisco_ios/README.md @@ -0,0 +1,37 @@ +# cisco_ios + +This Ansible Network role provides a set of platform dependent fuctions that +are designed to work with Cisco IOS network devices. The functions included +int his role inlcuding both configuration and fact collection. + +## Requirements + +* Ansible 2.6 or later +* Ansible Network Engine Role 2.6.0 or later + +## Functions + +This section provides a list of the availabe functions that are including +in this role. Any of the provided functions can be implemented in Ansible +playbooks to perform automation activities on Cisco IOS devices. + +Please see the documentation link for each function for details on how to use +the function in an Ansible playbook. + +* get_facts [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/get_facts.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/get_facts.md) + +### Config Manager +* config_manager/get [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/config_manager/get.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/config_manager/get.md) +* config_manager/load [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/config_manager/load.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/config_manager/load.md) + +### Cloud VPN +* cloud_vpn/configure_vpn_initiator [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/cloud_vpn/configure_vpn_initiator.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/cloud_vpn/configure_vpn_initiator.md) +* cloud_vpn/configure_routing_initiator [[source]](https://github.com/ansible-network/cisco_ios/blob/devel/tasks/cloud_vpn/configure_routing_initiator.yaml) [[docs]](https://github.com/ansible-network/cisco_ios/blob/devel/docs/cloud_vpn/configure_routing_initiator.md) + +## License + +GPLv3 + +## Author Information + +Ansible Network Community diff --git a/roles/ansible-network.cisco_ios/action_plugins/extract_banners.py b/roles/ansible-network.cisco_ios/action_plugins/extract_banners.py new file mode 100644 index 0000000..859da46 --- /dev/null +++ b/roles/ansible-network.cisco_ios/action_plugins/extract_banners.py @@ -0,0 +1,137 @@ +# (c) 2018, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'network'} + +DOCUMENTATION = """ +--- +module: extract_banners +author: Ansible Network Team +short_description: remove banners from config text +description: + - The config text specified in C(config) will be used to extract banners + from it. Banners need to be executed on device in special manner. It + returns configs with banner removed and a dictionary of banners +version_added: "2.7" +options: + config: + description: + - Config text from which banners need to be extracted. + required: yes + default: null +""" + +EXAMPLES = """ +- name: extract multiline banners + extract_banners: + config: "{{ ios_config_text }}" + +""" + +RETURN = """ +config: + description: returns the config with masked banners + returned: always + type: str +banners: + description: returns the extracted banners + returned: always + type: dict +""" +import re +from ansible.plugins.action import ActionBase +from ansible.module_utils._text import to_text +from ansible.errors import AnsibleError + +try: + from __main__ import display +except ImportError: + from ansible.utils.display import Display + display = Display() + + +class ActionModule(ActionBase): + + def run(self, tmp=None, task_vars=None): + ''' handler for extract_banners ''' + + if task_vars is None: + task_vars = dict() + + result = super(ActionModule, self).run(tmp, task_vars) + del tmp # tmp no longer has any effect + + try: + config = self._task.args['config'] + except KeyError as exc: + raise AnsibleError(to_text(exc)) + + # make config required argument + if not config: + raise AnsibleError('missing required argument `config`') + + banners, masked_config = self._extract_banners(config) + result['config'] = masked_config + result['banners'] = banners + return result + + def _extract_banners(self, config): + config_lines = config.split('\n') + found_banner_start = 0 + banner_meta = [] + for linenum, line in enumerate(config_lines): + if not found_banner_start: + banner_start = re.search(r'^banner\s+(\w+)\s+(.*)', line) + if banner_start: + banner_cmd = banner_start.group(1) + try: + banner_delimiter = banner_start.group(2) + banner_delimiter = banner_delimiter.strip() + banner_delimiter_esc = re.escape(banner_delimiter) + except Exception: + continue + banner_start_index = linenum + found_banner_start = 1 + continue + + if found_banner_start: + # Search for delimiter found in current banner start + regex = r'%s' % banner_delimiter_esc + banner_end = re.search(regex, line) + if banner_end: + found_banner_start = 0 + kwargs = { + 'banner_cmd': banner_cmd, + 'banner_delimiter': banner_delimiter, + 'banner_start_index': banner_start_index, + 'banner_end_index': linenum, + } + banner_meta.append(kwargs) + + # Build banners from extracted data + banner_lines = [] + for banner in banner_meta: + banner_lines.append('banner %s %s' % (banner['banner_cmd'], + banner['banner_delimiter'])) + banner_conf_lines = config_lines[banner['banner_start_index'] + 1: banner['banner_end_index']] + for index, conf_line in enumerate(banner_conf_lines): + banner_lines.append(conf_line) + banner_lines.append('%s' % banner['banner_delimiter']) + + # Delete banner lines from config + for banner in banner_meta: + banner_lines_range = range(banner['banner_start_index'], + banner['banner_end_index'] + 1) + for index in banner_lines_range: + config_lines[index] = '! banner removed' + + configs = '\n'.join(config_lines) + return (banner_lines, configs) diff --git a/roles/ansible-network.cisco_ios/action_plugins/ios_user_manager.py b/roles/ansible-network.cisco_ios/action_plugins/ios_user_manager.py new file mode 100644 index 0000000..e983d58 --- /dev/null +++ b/roles/ansible-network.cisco_ios/action_plugins/ios_user_manager.py @@ -0,0 +1,111 @@ +# (c) 2018, Ansible by Red Hat, inc +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'network'} +import re +import base64 +import hashlib + +from ansible.plugins.action import ActionBase + + +class UserManager: + + def __init__(self, new_users, user_config_data): + self.__new_users = new_users + self.__user_config_data = user_config_data + + @staticmethod + def calculate_fingerprint(sshkey): + if ' ' in sshkey: + keyparts = sshkey.split(' ') + keyparts[1] = hashlib.md5(base64.b64decode(keyparts[1])).hexdigest().upper() + return ' '.join(keyparts) + + else: + return 'ssh-rsa %s' % hashlib.md5(base64.b64decode(sshkey)).hexdigest().upper() + + def _parse_view(self, data): + match = re.search(r'view (\S+)', data, re.M) + if match: + return match.group(1) + + def _parse_sshkey(self, data): + match = re.search(r'key-hash (\S+ \S+(?: .+)?)$', data, re.M) + if match: + return match.group(1) + + def _parse_privilege(self, data): + match = re.search(r'privilege (\S+)', data, re.M) + if match: + return int(match.group(1)) + + def generate_existing_users(self): + match = re.findall(r'(?:^(?:u|\s{2}u))sername (\S+)', self.__user_config_data, re.M) + if not match: + return [] + + existing_users = [] + + for user in set(match): + regex = r'username %s .+$' % user + cfg = re.findall(regex, self.__user_config_data, re.M) + cfg = '\n'.join(cfg) + sshregex = r'username %s\n\s+key-hash .+$' % user + sshcfg = re.findall(sshregex, self.__user_config_data, re.M) + sshcfg = '\n'.join(sshcfg) + + obj = { + 'name': user, + 'sshkey': self._parse_sshkey(sshcfg), + 'privilege': self._parse_privilege(cfg), + 'view': self._parse_view(cfg) + } + + filtered = {k: v for k, v in obj.items() if v is not None} + obj.clear() + obj.update(filtered) + + existing_users.append(obj) + + return existing_users + + def filter_users(self): + want = self.__new_users + for user in want: + if 'sshkey' in user: + user['sshkey'] = self.calculate_fingerprint(user['sshkey']) + + have = self.generate_existing_users() + filtered_users = [x for x in want if x not in have] + + changed = True if len(filtered_users) > 0 else False + + return changed, filtered_users + + +class ActionModule(ActionBase): + + def run(self, tmp=None, task_vars=None): + if task_vars is None: + task_vars = dict() + + result = super(ActionModule, self).run(tmp, task_vars) + + try: + new_users = self._task.args['new_users'] + user_config_data = self._task.args['user_config'] + except KeyError as exc: + return {'failed': True, 'msg': 'missing required argument: %s' % exc} + + result['changed'], result['stdout'] = UserManager(new_users, user_config_data).filter_users() + + return result diff --git a/roles/ansible-network.cisco_ios/action_plugins/parse_validate_acl.py b/roles/ansible-network.cisco_ios/action_plugins/parse_validate_acl.py new file mode 100644 index 0000000..737c984 --- /dev/null +++ b/roles/ansible-network.cisco_ios/action_plugins/parse_validate_acl.py @@ -0,0 +1,262 @@ +# (c) 2018, Ansible Inc, +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import copy +import os +import time +import re +import hashlib +import netaddr +import json +import socket + +from ansible.module_utils._text import to_bytes, to_text +from ansible.module_utils.connection import Connection +from ansible.errors import AnsibleError +from ansible.plugins.action import ActionBase +from ansible.module_utils.six.moves.urllib.parse import urlsplit +from ansible.utils.path import unfrackpath + +try: + from __main__ import display +except ImportError: + from ansible.utils.display import Display + display = Display() + + +class ActionModule(ActionBase): + + def run(self, tmp=None, task_vars=None): + result = super(ActionModule, self).run(task_vars=task_vars) + + try: + show_acl_output_buffer = self._task.args.get('show_acl_output_buffer') + except KeyError as exc: + return {'failed': True, 'msg': 'missing required argument: %s' % exc} + + try: + parser = self._task.args.get('parser') + except KeyError as exc: + return {'failed': True, 'msg': 'missing required argument: %s' % exc} + + try: + generated_flow_file = self._task.args.get('generated_flow_file') + except KeyError as exc: + return {'failed': True, 'msg': 'missing required argument: %s' % exc} + + generated_flow_file = unfrackpath(generated_flow_file) + dest = generated_flow_file + + parser = unfrackpath(parser) + if not os.path.exists(parser): + return {'failed': True, 'msg': 'path: %s does not exist.' % parser} + parser_file = parser + + pd_json = self._parse_acl_with_textfsm( + parser_file, show_acl_output_buffer) + try: + changed = self._write_packet_dict(dest, pd_json) + except IOError as exc: + result['failed'] = True + result['msg'] = ('Exception received : %s' % exc) + + result['changed'] = changed + if changed: + result['destination'] = dest + else: + result['dest_unchanged'] = dest + + return result + + def _create_packet_dict(self, cmd_out): + import warnings + with warnings.catch_warnings(record=True): + warnings.simplefilter("always") + from trigger.acl import parse + import netaddr + import json + import uuid + + # pd is list of dictionary of packets + pd = [] + lines = cmd_out.split('\n') + for index, line in enumerate(lines): + line = to_bytes(line, errors='surrogate_or_strict') + pd_it = {} + try: + p = parse(line) + except Exception: + continue + + if p.terms: + match = p.terms[0].match + for key in match: + if key == 'source-address': + for m in match["source-address"]: + v = netaddr.IPNetwork(str(m)) + # Return the host in middle of subnet + size_subnet = v.size + host_index = int(size_subnet / 2) + pd_it["src"] = str(v[host_index]) + if key == 'destination-address': + for m in match["destination-address"]: + v = netaddr.IPNetwork(str(m)) + # Return the host in middle of subnet + size_subnet = v.size + host_index = int(size_subnet / 2) + pd_it["dst"] = str(v[host_index]) + if key == 'protocol': + for m in match['protocol']: + pd_it["proto"] = str(m) + if key == 'destination-port': + for m in match["destination-port"]: + pd_it['dst_port'] = str(m) + if key == 'source-port': + for m in match["source-port"]: + pd_it['src_port'] = str(m) + + action = p.terms[0].action + for act in action: + pd_it["action"] = act + + if pd_it is not None: + if "dst" not in pd_it: + pd_it["dst"] = "any" + if "src" not in pd_it: + pd_it["src"] = "any" + pd_it["service_line_index"] = str(index) + pd.append(pd_it) + + return json.dumps(pd, indent=4) + + def _write_packet_dict(self, dest, contents): + # Check for Idempotency + if os.path.exists(dest): + try: + with open(dest, 'r') as f: + old_content = f.read() + except IOError as ioexc: + raise IOError(ioexc) + sha1 = hashlib.sha1() + old_content_b = to_bytes(old_content, errors='surrogate_or_strict') + sha1.update(old_content_b) + checksum_old = sha1.digest() + + sha1 = hashlib.sha1() + new_content_b = to_bytes(contents, errors='surrogate_or_strict') + sha1.update(new_content_b) + checksum_new = sha1.digest() + if checksum_old == checksum_new: + return (False) + + try: + with open(dest, 'w') as f: + f.write(contents) + except IOError as ioexc: + raise IOError(ioexc) + + return (True) + + def _parse_acl_with_textfsm(self, parser_file, output): + import textfsm + tmp = open(parser_file) + re_table = textfsm.TextFSM(tmp) + results = re_table.ParseText(output) + fsm_results = [] + for item in results: + facts = {} + facts.update(dict(zip(re_table.header, item))) + fsm_results.append(facts) + + pd = [] + parsed_acl = [] + # Convert dictionary of terms into flows dictionary + for term in fsm_results: + pd_it = {} + original_terms = {} + for k, v in term.items(): + if k == 'LINE_NUM' and v == '': + # Empty line with just name + continue + elif k == 'LINE_NUM' and v != '': + pd_it["service_line_index"] = v + original_terms["service_line_index"] = v + if k == 'PROTOCOL' and v != '': + pd_it["proto"] = v + original_terms['proto'] = v + if k == 'ACTION' and v != '': + pd_it["action"] = v + original_terms['action'] = v + if k == 'SRC_NETWORK' and v != '': + if 'SRC_WILDCARD' in term: + src_mask = term['SRC_WILDCARD'] + src_invert_mask = sum([bin(255 - int(x)).count("1") for x in + src_mask.split(".")]) + else: + src_invert_mask = '32' + cidr = "%s/%s" % (v, src_invert_mask) + src_ip = netaddr.IPNetwork(cidr) + size_subnet = src_ip.size + host_index = int(size_subnet / 2) + pd_it['src'] = str(src_ip[host_index]) + original_terms['src'] = src_ip + if k == 'SRC_ANY' and v != '': + pd_it['src'] = "any" + original_terms['src'] = netaddr.IPNetwork('0.0.0.0/0') + if k == 'SRC_HOST' and v != '': + pd_it['src'] = v + original_terms['src'] = v + if k == 'SRC_PORT' and v != '': + if not v[0].isdigit(): + v = str(socket.getservbyname(v)) + pd_it['src_port'] = v + original_terms['src_port'] = v + if k == 'DST_NETWORK' and v != '': + if 'DST_WILDCARD' in term: + dst_mask = term['DST_WILDCARD'] + dst_invert_mask = sum([bin(255 - int(x)).count("1") for x in + dst_mask.split(".")]) + else: + dst_invert_mask = '32' + d_cidr = "%s/%s" % (v, dst_invert_mask) + dst_ip = netaddr.IPNetwork(d_cidr) + d_size_subnet = dst_ip.size + d_host_index = int(d_size_subnet / 2) + pd_it['dst'] = str(dst_ip[d_host_index]) + original_terms['dst'] = dst_ip + if k == 'DST_ANY' and v != '': + pd_it['dst'] = "any" + original_terms['dst'] = netaddr.IPNetwork('0.0.0.0/0') + if k == 'DST_HOST' and v != '': + pd_it['dst'] = v + original_terms['dst'] = v + if k == 'DST_PORT' and v != '': + if not v[0].isdigit(): + v = str(socket.getservbyname(v)) + pd_it['dst_port'] = v + original_terms['dst_port'] = v + + if pd_it: + pd.append(pd_it) + if original_terms: + parsed_acl.append(original_terms) + + # Store parsed acl on this object for later processing + self._parsed_acl = parsed_acl + return json.dumps(pd, indent=4) diff --git a/roles/ansible-network.cisco_ios/bindep.txt b/roles/ansible-network.cisco_ios/bindep.txt new file mode 100644 index 0000000..ccee5a8 --- /dev/null +++ b/roles/ansible-network.cisco_ios/bindep.txt @@ -0,0 +1,7 @@ +# This is a cross-platform list tracking distribution packages needed by tests; +# see http://docs.openstack.org/infra/bindep/ for additional information. + +gcc-c++ [test platform:rpm] +python3-devel [test platform:rpm] +python3 [test platform:rpm] +python36 [test !platform:fedora-28] diff --git a/roles/ansible-network.cisco_ios/defaults/cloud_vpn/providers/csr/initiator.yaml b/roles/ansible-network.cisco_ios/defaults/cloud_vpn/providers/csr/initiator.yaml new file mode 100644 index 0000000..68fff6d --- /dev/null +++ b/roles/ansible-network.cisco_ios/defaults/cloud_vpn/providers/csr/initiator.yaml @@ -0,0 +1,5 @@ +--- + +cloud_vpn_initiator_user: ec2-user +cloud_vpn_initiator_ansible_connection: network_cli +cloud_vpn_initiator_outside_interface: GigabitEthernet1 diff --git a/roles/ansible-network.cisco_ios/defaults/main.yml b/roles/ansible-network.cisco_ios/defaults/main.yml new file mode 100644 index 0000000..87f1c4e --- /dev/null +++ b/roles/ansible-network.cisco_ios/defaults/main.yml @@ -0,0 +1,15 @@ +--- +# defaults file for ansible-network.cisco_ios +# +ios_config_rollback_enabled: true +ios_config_use_terminal: true +ios_config_remove_temp_files: "{{ remove_temp_files | default(True) }}" +ios_config_replace: "{{ config_manager_replace | default(False) }}" + +ios_config_source: + running: show running-config + startup: show startup-config + +ios_get_facts_command_map: "{{ role_path }}/vars/get_facts_command_map.yaml" +ios_get_facts_subset: "{{ subset | default(['default']) }}" +ios_dependent_role_check: true diff --git a/roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_routing_initiator.md b/roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_routing_initiator.md new file mode 100644 index 0000000..ed87a6c --- /dev/null +++ b/roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_routing_initiator.md @@ -0,0 +1,24 @@ +# Configure VPN routing as initiator +The `cloud_vpn/configure_routing_initiator` function will configure the routing where +a VPN as initiator has been configured previously on Cisco IOS devices. +It is performed by calling the `cloud_vpn/configure_routing_initiator` task from the role. +The task will process variables needed for routing configuration and apply it to the device. + +Below is an example to configure routing on a CSR device configured as initiator, +where the responder is AWS VPN. + +``` +- hosts: cisco_ios + + tasks: + - name: Configure initiator routing + include_role: + name: ansible-network.cisco_ios + tasks_from: cloud_vpn/configure_routing_initiator + vars: + cloud_vpn_responder_provider: aws_vpn + cloud_vpn_responder_cidr: 192.168.0.0/24 +``` + +## Notes +None diff --git a/roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_vpn_initiator.md b/roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_vpn_initiator.md new file mode 100644 index 0000000..7d939ae --- /dev/null +++ b/roles/ansible-network.cisco_ios/docs/cloud_vpn/configure_vpn_initiator.md @@ -0,0 +1,33 @@ +# Configure VPN as initiator +The `cloud_vpn/configure_vpn_initiator` function will configure IPSEC VPN as initiator +on Cisco IOS devices. +It is performed by calling the `cloud_vpn/configure_vpn_initiator` task from the role. +The task will process variables needed for VPN configuration and apply it to the device. + +Below is an example to configure an IPSEC VPN as initiator on CSR device, where +the responder is AWS VPN: + +``` +- hosts: cisco_ios + + tasks: + - name: Configure IPSEC VPN as initiator + include_role: + name: ansible-network.cisco_ios + tasks_from: cloud_vpn/configure_vpn_initiator + vars: + cloud_vpn_name: myvpn + cloud_vpn_psk: mypsksecret + cloud_vpn_initiator_provider: csr + cloud_vpn_initiator_outside_interface: GigabitEthernet1 + cloud_vpn_initiator_tunnel_ip: 169.254.56.25 + cloud_vpn_initiator_tunnel_failover_ip: 169.254.56.29 + cloud_vpn_responder_provider: aws_vpn + cloud_vpn_responder_public_ip: 18.191.132.220 + cloud_vpn_responder_failover_ip: 18.191.132.221 + cloud_vpn_responder_tunnel_ip: 169.254.56.26 + cloud_vpn_responder_tunnel_failover_ip: 169.254.56.30 +``` + +## Notes +None diff --git a/roles/ansible-network.cisco_ios/docs/config_manager/get.md b/roles/ansible-network.cisco_ios/docs/config_manager/get.md new file mode 100644 index 0000000..300cbaa --- /dev/null +++ b/roles/ansible-network.cisco_ios/docs/config_manager/get.md @@ -0,0 +1,78 @@ +# Get configuration from device +The `config_manager/get` function will return the either the current active or current +saved configuration from an Cisco IOS devices. This function is only +supported over `network_cli` connections. + +The `config_manager/get` function will also parse the device active configuration into +a set of host facts during its execution. All of the parsed facts are stored +in the ``cisco_ios.config`` top level facts key. + +## How to get the device configuration +Retrieving the configuration from the device involves just calling the +`config_manager/get` function from the role. By default, the `config_manager/get` role will +return the device active (running) configuraiton. The text configuration will +be returned as a fact for the host. The configuration text is stored in the +`configuration` fact. + +Below is an example of calling the `config_manager/get` function from the playbook. + +``` +- hosts: cisco_ios + + roles: + - name ansible-network.cisco_ios + function: config_manager/get +``` + +The above playbook will return the current running config from each host listed +in the `cisco_ios` group in inventory. + +### Get the current startup config +By default the `config_manager/get` function will return the device running +configuration. If you want to retrieve the device startup configuration, set +the value of `source` to `startup`. + +``` +- hosts: cisco_ios + + roles: + - name ansible-network.cisco_ios + function: config_manager/get + source: startup +``` + +### Implement using tasks +The `config_manager/get` function can also be implemented in the `tasks` during the +playbook run using either the `include_role` or `import_role` modules as shown +below. + +``` +- hosts: cisco_ios + + tasks: + - name: collect facts from cisco ios devices + include_role: + name: ansible-network.cisco_ios + tasks_from: config_manager/get +``` + +## How to add additional parsers + +The configuration facts are returned by this function are parsed using the +parsers in the `parser_templates/config` folder. To add a new parser, simply +create a PR and add the new parser to the folder. Once merged, the +`config_manager/get` function will automatically use the new parser. + +## Arguments + +### source + +Defines the configuration source to return from the device. This argument +accepts one of `running` or `startup`. When the value is set to `running` +(default), the current active configuration is returned. When the value is set +to `sartup`, the device saved configuration is returned. + +The default value is `running` + +## Notes +None diff --git a/roles/ansible-network.cisco_ios/docs/config_manager/load.md b/roles/ansible-network.cisco_ios/docs/config_manager/load.md new file mode 100644 index 0000000..5215cdc --- /dev/null +++ b/roles/ansible-network.cisco_ios/docs/config_manager/load.md @@ -0,0 +1,86 @@ +# Load configuration onto device +The `config_manager/load` function will take a Cisco IOS configuration file and load it +onto the device. This function supports either merging the configuration with +the current active configuration or replacing the current active configuration +with the provided configuration file. + +The `config_manager/load` function will return the full configuration diff in the +`ios_diff` fact. + +NOTE: When performing a configuration replace function be sure to specify the +entire configuration to be loaded otherwise you could end up not being able to +reconnect to your IOS device after the configuration has been loaded. + +## How to load and merge a configuration +Loading and merging a configuration file is the default operation for the +`config_manager/load` function. It will take the contents of a Cisco IOS configuration +file and merge it with the current device active configurations. + +Below is an example of calling the `config_manager/load` function from the playbook. + +``` +- hosts: cisco_ios + + roles: + - name ansible_network.cisco_ios + function: config_manager/load + config_manager_text: "{{ lookup('file', 'ios.cfg') }}" +``` + +The above playbook will load the specified configuration file onto each device +in the `cisco_ios` host group. + +## How to replace the current active configuration +The `config_manager/load` function also supports replacing the current active +configuration with the configuration file located on the Ansible controller. +In order to replace the device's active configuration, set the value of the +`config_manager_replace` setting to `True`. + +``` +- hosts: cisco_ios + + roles: + - name ansible_network.cisco_ios + function: config_manager/load + config_manager_text: "{{ lookup('file', 'ios.cfg') }}" + config_manager_replace: true +``` + + +## Arguments + +### config_manager_text + +This value accepts the text form of the configuration to be loaded on to the remote device. +The configuration file should be the native set of commands used to configure the remote device. + +The default value is `null` + +### config_manager_replace + +Specifies whether or not the source configuration should replace the current +active configuration on the target IOS device. When this value is set to +False, the source configuration is merged with the active configuration. When +this value is set to True, the source configuration will replace the current +active configuration + +The default value is `False` + +### ios_config_remove_temp_files + +Configures the function to remove or not remove the temp files created when +preparing to load the configuration file. There are two locations for temp +files, one on the Ansible controller and one on the device. This argument +accepts a boolean value. + +The default value is `True` + +### ios_config_rollback_enabled + +Configures whether or not automatic rollback is enabled during the execution of +the function. When enabled, if an error is enountered, then the configuration +is automatically returned to the original running-config. If disabled, then +the rollback operation is not performed automatically. + +The default value is `True` + diff --git a/roles/ansible-network.cisco_ios/docs/get_facts.md b/roles/ansible-network.cisco_ios/docs/get_facts.md new file mode 100644 index 0000000..02c63f6 --- /dev/null +++ b/roles/ansible-network.cisco_ios/docs/get_facts.md @@ -0,0 +1,166 @@ +# Get facts from device + +The `get_facts` function can be used to collect facts from an Cisco IOS +devices. This function is only supported over `network_cli` connection +type and requires the `ansible_network_os` value set to `ios`. + +## How to get facts from the device + +To collect facts from the device, simply include this function in the playbook +using either the `roles` directive or the `tasks` directive. If no other +options are provided, then all of the available facts will be collected for the +device. + +Below is an example of how to use the `roles` directive to collect all facts +from the IOS device. + +``` +- hosts: cisco_ios + + roles: + - name ansible-network.cisco_ios + function: get_facts +``` + +The above playbook will return the facts for the host under the `cisco_ios` +top level key. + +### Filter the subset of facts returned + +By default all available facts will be returned by the `get_facts` function. +If you only want to return a subset of the facts, you can specify the `subset` +variable as a list of keys to return. + +For instance, the below will return only `interfaces` and `system` facts. + +``` +- hosts: cisco_ios + + roles: + - name ansible-network.cisco_ios + function: get_facts + subset: + - system +``` + +### Implement using tasks + +The `get_facts` function can also be implemented using the `tasks` directive +instead of the `roles` directive. By using the `tasks` directive, you can +control when the fact collection is run. + +Below is an example of how to use the `get_facts` function with `tasks`. + +``` +- hosts: cisco_ios + + tasks: + - name: collect facts from cisco ios devices + import_role: + name: ansible-network.cisco_ios + tasks_from: get_facts + vars: + subset: + - system + - interfaces +``` + +## Adding new parsers + +Over time new parsers can be added (or updated) to the role to add additional +or enhanced functionality. To add or update parsers perform the following +steps: + +* Add (or update) command parser located ino `parse_templates/cli` + +* Update the `vars/get_facts_command_map.yaml` file to map the CLI command +to the parser + +The `get_facts_command_map.yaml` file provides a mapping between CLI command +and parser used to transform the output into Ansible facts. + +### Understanding the mapping file + +The command map file provides the mapping between show command and parser file. +The format of the file is a list of objects. Each object supports a set of +keys that can be configured to provide granular control over how each command +is implemented. + +Command map entries support the following keys: + +#### command + +The `command` key is required and specifies the actual CLI command to execute +on the target device. The output from the command is then passed to the parser +for further processing. + +#### parser + +The `parser` key provides the name of the parser used to accept the output from +the command. The parser value shoule be the command parser filename either +relative to `parser_templates/cli` or absolute path. This value is required. + +#### engine + +This key accepts one of two values, either `command_parser` or `textfsm_parser`. +This value instructs the the parsing function as to which parsing engine to +use to parse the output from the CLI command. + +This key is not required and, if not provided, the engine will assumed to be +`command_parser` + +#### groups + +Commands can be contained in one (or more) groups to make it easy for playbook +designers to filter specific facts to retreive from the network device. The +`groups` key must be a list and contain the groups the this command should be +associated with. + +#### pre_hook + +The `pre_hook` key provides the path to the set of tasks to include prior +to running the command on the CLI. This is useful if there is a need to check +if a command is available or supported on a particular version. + +#### post_hook + +The `post_hook` key provides the path to the set of tasks to include after the +command has been run on the target device and its results have been parsed by +the parser. + +## Arguments + +### ios_get_facts_subset + +Defines the subset of facts to collection when the `get_facts` function is +called. This value must be a list value and contain only the sub keys for the +facts you wish to return. + +The default value is `default` + +#### Aliases + +* subset + +#### Current supported values for subset are + +* default +* all +* interfaces +* bgp +* lldp + +### ios_get_facts_command_map + +Defines the command / parser mapping file to use when the call to `get_facts` +is made by the playbook. Normally this value does not need to be modified but +can be used to pass a custom command map to the function. + +The default value is `vars/get_facts_command_map.yaml` + + +## Notes + +None + + diff --git a/roles/ansible-network.cisco_ios/filter_plugins/ios.py b/roles/ansible-network.cisco_ios/filter_plugins/ios.py new file mode 100644 index 0000000..6fda4db --- /dev/null +++ b/roles/ansible-network.cisco_ios/filter_plugins/ios.py @@ -0,0 +1,35 @@ +# +# (c) 2018 Red Hat, Inc. +# +# Copyright (c) 2017 Ansible Project +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +# +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import re + + +INTERFACE_NAMES = { + 'Gi': 'GigabitEthernet', +} + + +def expand_interface_name(name): + match = re.match('([a-zA-Z]*)', name) + if match and match.group(1) in INTERFACE_NAMES: + matched = match.group(1) + name = name.replace(matched, INTERFACE_NAMES[matched]) + return name + + +class FilterModule(object): + """Filters for working with output from network devices""" + + filter_map = { + 'expand_interface_name': expand_interface_name + } + + def filters(self): + return self.filter_map diff --git a/roles/ansible-network.cisco_ios/handlers/main.yml b/roles/ansible-network.cisco_ios/handlers/main.yml new file mode 100644 index 0000000..a6060d4 --- /dev/null +++ b/roles/ansible-network.cisco_ios/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for ansible-network.cisco_ios diff --git a/roles/ansible-network.cisco_ios/includes/args_adapter.yaml b/roles/ansible-network.cisco_ios/includes/args_adapter.yaml new file mode 100644 index 0000000..615f0be --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/args_adapter.yaml @@ -0,0 +1,13 @@ +--- +# Playbook to ingest config manager args into ios provider specific args +# + +- name: convert config_manager_text + set_fact: + ios_config_text: "{{ config_manager_text }}" + when: config_manager_text is defined + +- name: convert config_manager_file + set_fact: + ios_config_file: "{{ config_manager_file }}" + when: config_manager_file is defined diff --git a/roles/ansible-network.cisco_ios/includes/checkpoint/create.yaml b/roles/ansible-network.cisco_ios/includes/checkpoint/create.yaml new file mode 100644 index 0000000..b85f98d --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/checkpoint/create.yaml @@ -0,0 +1,26 @@ +--- +- name: validate ios_checkpoint_filename is defined + fail: + msg: "missing required var: ios_checkpoint_filename" + when: ios_checkpoint_filename is undefined + +- name: get current files on disk + cli: + command: dir + register: ios_dir_listing + +- name: remove old checkpoint file (if necessary) + cli: + command: "delete /force flash:/{{ ios_checkpoint_filename }}" + when: ios_checkpoint_filename in ios_dir_listing.stdout + +# copy the current running-config to the local flash disk on the target device. +# This will be used both for restoring the current config if a failure happens +# as well as performing a configuration diff once the new config has been +# loaded. +- name: create a checkpoint of the current running-config + ios_command: + commands: + - command: "copy running-config flash:{{ ios_checkpoint_filename }}" + prompt: ["\\? "] + answer: "{{ ios_checkpoint_filename }}" diff --git a/roles/ansible-network.cisco_ios/includes/checkpoint/remove.yaml b/roles/ansible-network.cisco_ios/includes/checkpoint/remove.yaml new file mode 100644 index 0000000..d4bb64f --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/checkpoint/remove.yaml @@ -0,0 +1,15 @@ +--- +- name: validate ios_checkpoint_filename is defined + fail: + msg: "missing required var: ios_checkpoint_filename" + when: ios_checkpoint_filename is undefined + +- name: get current files on disk + cli: + command: dir + register: ios_dir_listing + +- name: remove checkpoint file from remote device + cli: + command: "delete /force flash:/{{ ios_checkpoint_filename }}" + when: ios_checkpoint_filename in ios_dir_listing.stdout diff --git a/roles/ansible-network.cisco_ios/includes/checkpoint/restore.yaml b/roles/ansible-network.cisco_ios/includes/checkpoint/restore.yaml new file mode 100644 index 0000000..4617212 --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/checkpoint/restore.yaml @@ -0,0 +1,32 @@ +--- +- name: validate ios_checkpoint_filename is defined + fail: + msg: "missing required var: ios_checkpoint_filename" + when: ios_checkpoint_filename is undefined + +- name: get current files on disk + cli: + command: dir + register: ios_dir_listing + +- name: verify checkpoint file exists + fail: + msg: "missing checkpoint file {{ ios_checkpoing_filename }}" + when: ios_checkpoint_filename not in ios_dir_listing.stdout + +- name: checkpoint configuration restore pre hook + include_tasks: "{{ ios_checkpoint_restore_pre_hook }}" + when: ios_checkpoint_restore_pre_hook is defined + +- name: restore checkpoint configuration + cli: + command: "config replace flash:/{{ ios_checkpoint_filename }} force" + register: ios_rollback_results + +- name: checkpoint configuration restore post hook + include_tasks: "{{ ios_checkpoint_restore_post_hook }}" + when: ios_checkpoint_restore_post_hook is defined + +- name: remove checkpoint file from remote device + cli: + command: "delete /force flash:/{{ ios_checkpoint_filename }}" diff --git a/roles/ansible-network.cisco_ios/includes/configure/merge.yaml b/roles/ansible-network.cisco_ios/includes/configure/merge.yaml new file mode 100644 index 0000000..c45b983 --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/configure/merge.yaml @@ -0,0 +1,59 @@ +--- +- name: validate ios_config_text is defined + fail: + msg: "missing required arg: ios_config_text" + when: ios_config_text is undefined + +- name: set the ios_config_temp_file name + set_fact: + ios_config_temp_file: "tmp_ansible" + +- name: create temp working dir + tempfile: + state: directory + register: ios_config_temp_dir + +- name: write the config text to disk + copy: + content: "{{ ios_config_text }}" + dest: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}" + +- name: get current list of files on remote device + cli: + command: dir + register: ios_dir_listing + +- name: remove temporary files from target device + cli: + command: "delete /force flash:/{{ ios_config_temp_file }}" + when: ios_config_temp_file in ios_dir_listing.stdout + +- name: enable the ios scp server + cli: + command: "{{ line }}" + loop: + - configure terminal + - ip scp server enable + - end + loop_control: + loop_var: line + +- name: copy configuration to device + net_put: + src: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}" + dest: "flash:/{{ ios_config_temp_file }}" + changed_when: false + +- name: merge with current active configuration + cli: + command: "{{ line }}" + loop: + - "copy flash:/{{ ios_config_temp_file }} force" + - "delete /force flash:/{{ ios_config_temp_file }}" + loop_control: + loop_var: line + +- name: remove local temp working dir + file: + path: "{{ ios_config_temp_dir.path }}" + state: absent diff --git a/roles/ansible-network.cisco_ios/includes/configure/replace.yaml b/roles/ansible-network.cisco_ios/includes/configure/replace.yaml new file mode 100644 index 0000000..d75f1ed --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/configure/replace.yaml @@ -0,0 +1,59 @@ +--- +- name: validate ios_config_text is defined + fail: + msg: "missing required arg: ios_config_text" + when: ios_config_text is undefined + +- name: set the ios_config_temp_file name + set_fact: + ios_config_temp_file: "tmp_ansible" + +- name: create temp working dir + tempfile: + state: directory + register: ios_config_temp_dir + +- name: write the config text to disk + copy: + content: "{{ ios_config_text }}" + dest: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}" + +- name: get current list of files on remote device + cli: + command: dir + register: ios_dir_listing + +- name: remove temporary files from target device + cli: + command: "delete /force flash:/{{ ios_config_temp_file }}" + when: ios_config_temp_file in ios_dir_listing.stdout and ios_config_remove_temp_files + +- name: enable the ios scp server + cli: + command: "{{ line }}" + loop: + - configure terminal + - ip scp server enable + - end + loop_control: + loop_var: line + +- name: copy configuration to device + net_put: + src: "{{ ios_config_temp_dir.path }}/{{ ios_config_temp_file }}" + dest: "flash:/{{ ios_config_temp_file }}" + changed_when: false + +- name: replace current active configuration + cli: + command: "{{ line }}" + loop: + - "config replace flash:/{{ ios_config_temp_file }} force" + - "delete /force flash:/{{ ios_config_temp_file }}" + loop_control: + loop_var: line + +- name: remove local temp working dir + file: + path: "{{ ios_config_temp_dir.path }}" + state: absent diff --git a/roles/ansible-network.cisco_ios/includes/configure/terminal.yaml b/roles/ansible-network.cisco_ios/includes/configure/terminal.yaml new file mode 100644 index 0000000..56cdebd --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/configure/terminal.yaml @@ -0,0 +1,41 @@ +--- +# this block is responsible for loading the configuration on to the target +# device line by line from config model. +- name: load configuration onto target device + block: + - name: load configuration lines into target device + block: + - name: extract banners from configs if present + extract_banners: + config: "{{ ios_config_text }}" + register: result + + - name: load configuration lines into target device except banner + cli_config: + config: "{{ result['config'] }}" + register: ios_config_output + + - name: enter configuration mode + cli: + command: "configure terminal" + + - name: load banner lines into target device + cli_command: + command: "{{ item }}" + sendonly: true + with_items: "{{ result['banners'] }}" + register: banner_config_output + + - name: exit configuration mode + cli: + command: end + + rescue: + - name: exit configuration mode + cli: + command: end + + - name: set host failed + fail: + msg: "error loading configuration lines" + when: not ansible_check_mode diff --git a/roles/ansible-network.cisco_ios/includes/init.yaml b/roles/ansible-network.cisco_ios/includes/init.yaml new file mode 100644 index 0000000..4e311b2 --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/init.yaml @@ -0,0 +1,34 @@ +--- +- name: set role basic facts + set_fact: + ansible_network_ios_path: "{{ role_path }}" + ansible_network_ios_version: "v2.7.0" + +- name: display the role version to stdout + debug: + msg: "ansible_network.cisco_ios version is {{ ansible_network_ios_version }}" + +- name: validate ansible_network_os == 'ios' + fail: + msg: "expected ansible_network_os to be `ios`, got `{{ ansible_network_os }}`" + when: ansible_network_os != 'ios' + +- name: validate ansible_connection == 'network_cli' + fail: + msg: "expected ansible_network to be `network_cli`, got `{{ ansible_connection }}`" + when: ansible_connection != 'network_cli' + +- name: Validate we have required installed version of dependent roles + verify_dependent_role_version: + role_path: "{{ role_path }}" + depends_map: + - name: 'ansible-network.network-engine' + version: "{{ ios_network_engine_req_ver_override }}" + when: ios_dependent_role_check is defined and ios_dependent_role_check + and ios_network_engine_req_ver_override is defined + +- name: Validate we have required installed version of dependent roles from meta + verify_dependent_role_version: + role_path: "{{ role_path }}" + when: ios_dependent_role_check is defined and ios_dependent_role_check + and ios_network_engine_req_ver_override is not defined diff --git a/roles/ansible-network.cisco_ios/includes/run_cli.yaml b/roles/ansible-network.cisco_ios/includes/run_cli.yaml new file mode 100644 index 0000000..fc7f5db --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/run_cli.yaml @@ -0,0 +1,25 @@ +--- +- name: run cli command pre hook + include_tasks: "{{ ios_run_cli_command_pre_hook }}" + when: ios_run_cli_command_pre_hook is defined and ios_run_cli_command_pre_hook + +- name: run command and parse output + cli: + command: "{{ ios_command }}" + parser: "{{ parser }}" + engine: "{{ ios_parser_engine | default(None) }}" + name: "{{ ios_name | default(None) }} " + with_first_found: + - files: + - "{{ ios_parser }}" + paths: + - "{{ playbook_dir }}/parser_templates/ios" + - "~/.ansible/ansible_network/parser_templates/ios" + - "/etc/ansible/ansible_network/parser_templates/ios" + - "{{ role_path }}/parser_templates" + loop_control: + loop_var: parser + +- name: run cli command post hook + include_tasks: "{{ ios_run_cli_command_post_hook }}" + when: ios_run_cli_command_post_hook is defined and ios_run_cli_command_post_hook diff --git a/roles/ansible-network.cisco_ios/includes/wrapper.yaml b/roles/ansible-network.cisco_ios/includes/wrapper.yaml new file mode 100644 index 0000000..3bd6e85 --- /dev/null +++ b/roles/ansible-network.cisco_ios/includes/wrapper.yaml @@ -0,0 +1,102 @@ +--- +- name: initialize function + include_tasks: includes/init.yaml + +- name: validate ios_config_includes is defined + fail: + msg: "missing required arg: ios_config_includes" + when: ios_config_includes is undefined + +- name: set ios checkpoint filename + set_fact: + ios_checkpoint_filename: "chk_ansible" + +# initiate creating a checkpoint of the existing running-config +- name: create checkpoint of current configuration + include_tasks: "{{ role_path }}/includes/checkpoint/create.yaml" + +- name: configure the target device + block: + # iterate over the set of includes to configure the device + - name: iterate over configuration tasks + include_tasks: "{{ task }}" + loop: "{{ ios_config_includes }}" + loop_control: + loop_var: task + + rescue: + # since the host has failed during the configuration load, the role by + # default will initiate a restore sequence. the restore sequence will + # load the previous running-config with the replace option enabled. + - name: display message + debug: + msg: "error configuring device, starting rollback" + when: ios_config_rollback_enabled + + - name: initiate configuration rollback + include_tasks: "{{ role_path }}/includes/checkpoint/restore.yaml" + + - name: display message + debug: + msg: "successfully completed configuration rollback" + when: ios_config_rollback_enabled + + - name: fail host due to config load error + fail: + msg: "error loading configuration onto target device" + +- name: set the ios_active_config fact + set_fact: + ios_active_config: "cfg_ansible" + +# check if any reminents are left over from a previous run and remove them +# prior to starting the configuration tasks. +- name: check if stale temporarary files exist on target device + cli: + command: dir + register: ios_dir_listing + +- name: remove temporary files from target device + cli: + command: "delete /force flash:/{{ ios_active_config }}" + when: ios_active_config in ios_dir_listing.stdout + +# copy the updated running-config to the local flash device to be used to +# generate a configuration diff between the before and after +# running-configurations. +- name: copy running-config to active config + ios_command: + commands: + - command: "copy running-config flash:{{ ios_active_config }}" + prompt: ["\\? "] + answer: "{{ ios_active_config }}" + +# generate the configuration diff and display the diff to stdout. only set +# changed if there are lines in the diff that have changed +- name: generate ios diff + cli: + command: "show archive config differences flash:{{ ios_checkpoint_filename }} flash:{{ ios_active_config }}" + register: ios_config_diff + changed_when: "'No changes were found' not in ios_config_diff.stdout" + +- name: display config diff + debug: + msg: "{{ ios_config_diff.stdout.splitlines() }}" + when: not ansible_check_mode + +# refresh the list of files currently on the target network device flash +# drive and remote all temp files +- name: update local directory listing + cli: + command: dir + register: ios_dir_listing + +- name: remove remote temp files from flash + cli: + command: "delete /force flash:/{{ filename }}" + loop: + - "{{ ios_active_config }}" + - "{{ ios_checkpoint_filename }}" + loop_control: + loop_var: filename + when: filename in ios_dir_listing.stdout diff --git a/roles/ansible-network.cisco_ios/library/ios_capabilities.py b/roles/ansible-network.cisco_ios/library/ios_capabilities.py new file mode 100644 index 0000000..309aef8 --- /dev/null +++ b/roles/ansible-network.cisco_ios/library/ios_capabilities.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'network'} + + +DOCUMENTATION = """ +--- +module: ios_capabilities +version_added: "2.7" +short_description: Collect device capabilities from Cisco IOS +description: + - Collect basic fact capabilities from Cisco NX-OS devices and return + the capabilities as Ansible facts. +author: + - Ansible Netowrk Community (ansible-network) +options: {} +""" + +EXAMPLES = """ +- facts: +""" + +RETURN = """ +""" +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.connection import Connection + + +def main(): + """ main entry point for Ansible module + """ + argument_spec = {} + + module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) + + connection = Connection(module._socket_path) + facts = connection.get_capabilities() + facts = module.from_json(facts) + result = { + 'changed': False, + 'ansible_facts': {'cisco_ios': {'capabilities': facts['device_info']}} + } + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/roles/ansible-network.cisco_ios/library/ios_command.py b/roles/ansible-network.cisco_ios/library/ios_command.py new file mode 100644 index 0000000..f136959 --- /dev/null +++ b/roles/ansible-network.cisco_ios/library/ios_command.py @@ -0,0 +1,241 @@ +#!/usr/bin/python +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'network'} + + +DOCUMENTATION = """ +--- +module: ios_command +version_added: "2.1" +author: "Peter Sprygada (@privateip)" +short_description: Run commands on remote devices running Cisco IOS +description: + - Sends arbitrary commands to an ios node and returns the results + read from the device. This module includes an + argument that will cause the module to wait for a specific condition + before returning or timing out if the condition is not met. + - This module does not support running commands in configuration mode. + Please use M(ios_config) to configure IOS devices. +extends_documentation_fragment: ios +notes: + - Tested against IOS 15.6 +options: + commands: + description: + - List of commands to send to the remote ios device over the + configured provider. The resulting output from the command + is returned. If the I(wait_for) argument is provided, the + module is not returned until the condition is satisfied or + the number of retries has expired. If a command sent to the + device requires answering a prompt, it is possible to pass + a dict containing I(command), I(answer) and I(prompt). + Common answers are 'y' or "\\r" (carriage return, must be + double quotes). See examples. + required: true + wait_for: + description: + - List of conditions to evaluate against the output of the + command. The task will wait for each condition to be true + before moving forward. If the conditional is not true + within the configured number of retries, the task fails. + See examples. + aliases: ['waitfor'] + version_added: "2.2" + match: + description: + - The I(match) argument is used in conjunction with the + I(wait_for) argument to specify the match policy. Valid + values are C(all) or C(any). If the value is set to C(all) + then all conditionals in the wait_for must be satisfied. If + the value is set to C(any) then only one of the values must be + satisfied. + default: all + choices: ['any', 'all'] + version_added: "2.2" + retries: + description: + - Specifies the number of retries a command should by tried + before it is considered failed. The command is run on the + target device every retry and evaluated against the + I(wait_for) conditions. + default: 10 + interval: + description: + - Configures the interval in seconds to wait between retries + of the command. If the command does not pass the specified + conditions, the interval indicates how long to wait before + trying the command again. + default: 1 +""" + +EXAMPLES = r""" +tasks: + - name: run show version on remote devices + ios_command: + commands: show version + + - name: run show version and check to see if output contains IOS + ios_command: + commands: show version + wait_for: result[0] contains IOS + + - name: run multiple commands on remote nodes + ios_command: + commands: + - show version + - show interfaces + + - name: run multiple commands and evaluate the output + ios_command: + commands: + - show version + - show interfaces + wait_for: + - result[0] contains IOS + - result[1] contains Loopback0 + - name: run commands that require answering a prompt + ios_command: + commands: + - command: 'clear counters GigabitEthernet0/1' + prompt: 'Clear "show interface" counters on this interface \[confirm\]' + answer: 'y' + - command: 'clear counters GigabitEthernet0/2' + prompt: '[confirm]' + answer: "\r" +""" + +RETURN = """ +stdout: + description: The set of responses from the commands + returned: always apart from low level errors (such as action plugin) + type: list + sample: ['...', '...'] +stdout_lines: + description: The value of stdout split into a list + returned: always apart from low level errors (such as action plugin) + type: list + sample: [['...', '...'], ['...'], ['...']] +failed_conditions: + description: The list of conditionals that have failed + returned: failed + type: list + sample: ['...', '...'] +""" +import re +import time + +from ansible.module_utils.network.ios.ios import run_commands +from ansible.module_utils.network.ios.ios import ios_argument_spec, check_args +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.network.common.utils import ComplexList +from ansible.module_utils.network.common.parsing import Conditional +from ansible.module_utils.six import string_types + + +def to_lines(stdout): + for item in stdout: + if isinstance(item, string_types): + item = str(item).split('\n') + yield item + + +def parse_commands(module, warnings): + command = ComplexList(dict( + command=dict(key=True), + prompt=dict(), + answer=dict() + ), module) + commands = command(module.params['commands']) + for item in list(commands): + configure_type = re.match(r'conf(?:\w*)(?:\s+(\w+))?', item['command']) + if module.check_mode: + if configure_type and configure_type.group(1) not in ('confirm', 'replace', 'revert', 'network'): + module.fail_json( + msg='ios_command does not support running config mode ' + 'commands. Please use ios_config instead' + ) + return commands + + +def main(): + """main entry point for module execution + """ + argument_spec = dict( + commands=dict(type='list', required=True), + + wait_for=dict(type='list', aliases=['waitfor']), + match=dict(default='all', choices=['all', 'any']), + + retries=dict(default=10, type='int'), + interval=dict(default=1, type='int') + ) + + argument_spec.update(ios_argument_spec) + + module = AnsibleModule(argument_spec=argument_spec, + supports_check_mode=True) + + result = {'changed': False} + + warnings = list() + check_args(module, warnings) + commands = parse_commands(module, warnings) + result['warnings'] = warnings + + wait_for = module.params['wait_for'] or list() + conditionals = [Conditional(c) for c in wait_for] + + retries = module.params['retries'] + interval = module.params['interval'] + match = module.params['match'] + + while retries > 0: + responses = run_commands(module, commands) + + for item in list(conditionals): + if item(responses): + if match == 'any': + conditionals = list() + break + conditionals.remove(item) + + if not conditionals: + break + + time.sleep(interval) + retries -= 1 + + if conditionals: + failed_conditions = [item.raw for item in conditionals] + msg = 'One or more conditional statements have not been satisfied' + module.fail_json(msg=msg, failed_conditions=failed_conditions) + + result.update({ + 'changed': False, + 'stdout': responses, + 'stdout_lines': list(to_lines(responses)) + }) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/roles/ansible-network.cisco_ios/library/ios_user_manager.py b/roles/ansible-network.cisco_ios/library/ios_user_manager.py new file mode 100644 index 0000000..4903884 --- /dev/null +++ b/roles/ansible-network.cisco_ios/library/ios_user_manager.py @@ -0,0 +1,48 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright 2018 Red Hat +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'network'} + + +DOCUMENTATION = ''' +--- +module: ios_user_manager +short_description: Manage an aggregate of users in IOS device(s) +description: + - Allows the `cisco_ios` provider role to manage aggregate of users + by providing idempotency and other utility functions while running + the `configure_user` task +version_added: "2.7" +options: + new_users: + description: + - Aggregate of local users to be configured on IOS device(s) + required: true + user_config: + description: + - User config lines extracted from the devices' running-configuration + required: true +author: + - Nilashish Chakraborty (@NilashishC) +''' +RETURN = """ +stdout: + description: Filtered set of users that should be configured on the device + returned: always apart from low-level errors (such as action plugin) + type: list + sample: [{"name": "ansible", "privilege": 15}, {"name": "test_user", "privilege": 15, "view": "sh_int"}] +""" +EXAMPLES = ''' +- ios_user_manager: + new_users: "{{ users }}" + user_config: "{{ existing_user_config.stdout }}" +''' diff --git a/roles/ansible-network.cisco_ios/meta/.galaxy_install_info b/roles/ansible-network.cisco_ios/meta/.galaxy_install_info new file mode 100644 index 0000000..1512187 --- /dev/null +++ b/roles/ansible-network.cisco_ios/meta/.galaxy_install_info @@ -0,0 +1 @@ +{install_date: 'Thu May 2 18:46:21 2019', version: v2.7.1} diff --git a/roles/ansible-network.cisco_ios/meta/main.yml b/roles/ansible-network.cisco_ios/meta/main.yml new file mode 100644 index 0000000..c88db58 --- /dev/null +++ b/roles/ansible-network.cisco_ios/meta/main.yml @@ -0,0 +1,41 @@ +--- +galaxy_info: + author: Ansible Network Community (ansible-network) + description: | + This role provides an implementation for automating the configuration of + Cisco IOS/IOS-XE devices. It provides implementations of Ansible Network + configuration abstractions. + company: Ansible + + license: GPLv3 + + min_ansible_version: 2.7 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # Optionally specify the branch Galaxy will use when accessing the GitHub + # repo for this role. During role install, if no tags are available, + # Galaxy will use this branch. During import Galaxy will access files on + # this branch. If Travis integration is configured, only notifications for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + # github_branch: + + # + # platforms is a list of platforms, and each platform has a name and a list of versions. + # + platforms: + - name: ios + version: + - any + + galaxy_tags: + - network + - cisco + - ios + - iosxe + +dependencies: + - src: ansible-network.network-engine + version: v2.7.3 diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_cdp_neighbors_detail.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_cdp_neighbors_detail.yaml new file mode 100644 index 0000000..60f8c0a --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_cdp_neighbors_detail.yaml @@ -0,0 +1,51 @@ +--- +- name: parser meta data + parser_metadata: + version: 1.0 + command: show cdp neighbors detail + network_os: ios + +- name: match sections + pattern_match: + regex: "^-----.*" + match_all: true + match_greedy: true + register: context + +- name: parse cdp neighbors + pattern_group: + - name: parse local port + pattern_match: + regex: '^Interface: ([^,]*)' + content: "{{ item }}" + register: local_port + + - name: parse remote prort + pattern_match: + regex: 'Port ID \(outgoing port\): (.*)$' + content: "{{ item }}" + register: remote_port + + - name: parse remote host + pattern_match: + regex: 'Device ID: (.*)$' + content: "{{ item }}" + register: remote_host + + loop: "{{ context }}" + register: matches + +- name: build cdp neighbor facts + loop: "{{ matches }}" + register: cdp + export: true + export_as: dict + extend: "{{ toplevel | default('cisco_ios') }}" + json_template: + template: + - key: "{{ item.local_port.matches.0 | expand_interface_name }}" + object: + - key: neighbor + value: "{{ item.remote_host.matches.0 }}" + - key: neighbor_port + value: "{{ item.remote_port.matches.0 }}" diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces.yaml new file mode 100644 index 0000000..80551bc --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces.yaml @@ -0,0 +1,119 @@ +--- +- name: parser meta data + parser_metadata: + version: 1.0 + command: show interfaces + network_os: ios + +- name: match sections + pattern_match: + regex: "^\\S+ is (up|down|administratively down)," + match_all: true + match_greedy: true + register: context + +- name: match interface values + pattern_group: + - name: match name + pattern_match: + regex: "^(\\S+)" + content: "{{ item }}" + register: name + + - name: match hardware + pattern_match: + regex: "Hardware is (.*(?=,)|.*)" + content: "{{ item }}" + register: type + + - name: match mtu + pattern_match: + regex: "MTU (\\d+)" + content: "{{ item }}" + register: mtu + + - name: match interface description + pattern_match: + regex: "Description: (.+)" + content: "{{ item }}" + register: description + + - name: match administrative state + pattern_match: + regex: "(administratively down)" + content: "{{ item }}" + register: enabled + + - name: match line protocol + pattern_match: + regex: "line protocol is (\\S+)" + content: "{{ item }}" + register: operstatus + + - name: match in packets + pattern_match: + regex: "(\\d+) packets input, (\\d+)" + content: "{{ item }}" + register: in_pkts_octets + + - name: match input broadcast + pattern_match: + regex: "Received (\\d+) broadcasts \\(\\d+" + content: "{{ item }}" + register: in_bcast_mcast + + - name: match out packets + pattern_match: + regex: "(\\d+) packets output, (\\d+) bytes" + content: "{{ item }}" + register: out_pkts_octets + + - name: match out errors + pattern_match: + regex: "(\\d+) output errors" + content: "{{ item }}" + register: out_errors + + loop: "{{ context }}" + register: values + +- name: template interface values + loop: "{{ values }}" + register: interfaces + export: true + export_as: dict + extend: cisco_ios + json_template: + template: + - key: "{{ item.name.matches.0 }}" + object: + - key: name + value: "{{ item.name.matches.0 }}" + - key: type + value: "{{ item.type.matches.0 }}" + - key: mtu + value: "{{ item.mtu.matches.0 }}" + - key: description + value: "{{ item.description.matches.0 }}" + - key: enabled + value: "{{ item.enabled.matches.0 is undefined }}" + - key: admin-status + value: "{{ item.enabled.matches.0 is undefined | ternary ('enabled', 'disabled') }}" + - key: oper-status + value: "{{ item.operstatus.matches.0 }}" + - key: counters + object: + - key: in-octets + value: "{{ item.in_pkts_octets.matches.0 }}" + - key: in-unicast-pkts + value: "{{ item.in_pkts_octets.matches.1 }}" + - key: in-broadcast-pkts + value: "{{ item.in_bcast_mcast.matches.0 }}" + - key: in-multicast-pkts + value: "{{ item.in_bcast_mcast.matches.1 }}" + - key: out-octets + value: "{{ item.out_pkts_octets.matches.0 }}" + - key: out-unicast-pkts + value: "{{ item.out_pkts_octets.matches.1 }}" + - key: out-errors + value: "{{ item.out_errors.matches.0 }}" diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces_transceiver.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces_transceiver.yaml new file mode 100644 index 0000000..0a0aef6 --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_interfaces_transceiver.yaml @@ -0,0 +1,75 @@ +--- +- name: parser meta data + parser_metadata: + version: 1.0 + command: show interfaces transceiver + network_os: ios + +- name: match sections + pattern_match: + regex: '(^\S{2}\d+/\d/\d+).*' + match_all: true + match_greedy: true + register: context + +- name: match interface transceiver + pattern_group: + - name: match transceiver + pattern_match: + regex: '(^\S{2}\d+/\d/\d+)' + content: "{{ item }}" + register: transceiver + + - name: match temperature + pattern_match: + regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$' + content: "{{ item }}" + register: temperature + + - name: match voltage + pattern_match: + regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$' + content: "{{ item }}" + register: voltage + + - name: match TxPower + pattern_match: + regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$' + content: "{{ item }}" + register: txpower + + - name: match RxPower + pattern_match: + regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$' + content: "{{ item }}" + register: rxpower + + - name: match Alarm + pattern_match: + regex: '(^\S{2}\d+/\d/\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)\s*(\d+\.\d+)*\s*(-?\d+\.\d+)\s*(-?\d+\.\d+)*\s*([-\+]*)$' + content: "{{ item }}" + register: alarm + + loop: "{{ context }}" + register: values + +- name: template interface values + loop: "{{ values }}" + register: transceiver + export: true + export_as: dict + extend: cisco_ios + json_template: + template: + - key: "{{ item.transceiver.matches.0 | expand_interface_name}}" + object: + - key: temperature + value: "{{ item.temperature.matches.1 }}" + - key: voltage + value: "{{ item.voltage.matches.2 }}" + - key: tx + value: "{{ item.txpower.matches.4 }}" + - key: rx + value: "{{ item.rxpower.matches.5 }}" + - key: alarm + value: "{{ item.rxpower.matches.6 }}" diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_bgp_summary.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_bgp_summary.yaml new file mode 100644 index 0000000..2bd24df --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_bgp_summary.yaml @@ -0,0 +1,77 @@ +--- + +- name: show_ip_bgp_summary + parser_metadata: + version: 1.0 + command: show ip bgp summary + network_os: ios + +- name: match not active + register: not_active + pattern_match: + regex: "BGP not active" + match_all: true + +- name: set_vars bgp state active + set_vars: + process_state: "active" + +- name: set_vars bgp state not active + set_vars: + process_state: "not active" + when: "not_active.0.matches == 'BGP not active'" + +- name: match sections + register: context + pattern_match: + regex: "Neighbor.+" + match_all: true + match_greedy: true + when: process_state == 'active' + +- name: match lines + register: lines + pattern_match: + regex: "^[0-9a-f.]+" + content: "{{ context.0 }}" + match_all: true + match_greedy: true + when: process_state == 'active' + +- name: match neighbors + register: matched_neighbors + loop: "{{ lines }}" + pattern_match: + regex: "(?P[0-9a-f.]+)\\s+(?P\\d+)\\s+(?P\\d+)\\s+(?P\\d+)\\s+(?P\\d+)\\s+(?P\\d+)\\s+(?P\\d+)\\s+(?P\\d+)\\s+(?P\\S+)\\s+(?P\\S+)" + content: "{{ item }}" + when: process_state == 'active' + +- name: template bgp values + extend: cisco_ios.vrf.DEFAULT.protocols + register: bgp + export: true + export_as: dict + json_template: + template: + - key: "process_state" + value: "{{ process_state }}" + +- name: template bgp neighbor entries + extend: cisco_ios.vrf.DEFAULT.protocols.bgp + register: neighbors + export: true + export_as: dict + loop: "{{ matched_neighbors }}" + when: process_state == 'active' + json_template: + template: + - key: "{{ item.ip }}" + object: + - key: state_pfxrcd + value: "{{ item.state }}" + - key: asn + value: "{{ item.asn }}" + - key: timer + value: "{{ item.timer }}" + - key: ip_version + value: "{{ item.version }}" diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_vrf_detail.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_vrf_detail.yaml new file mode 100644 index 0000000..5b848c9 --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_ip_vrf_detail.yaml @@ -0,0 +1,138 @@ +--- + +- name: show_ip_vrf_detail + parser_metadata: + version: 1.0 + command: show ip vrf detail + network_os: ios + +- name: match vrf sections + register: vrf_section + pattern_match: + regex: "^VRF \\S+(?: \\(VRF Id = \\d+\\)|); default RD" + match_all: true + match_greedy: true + +- name: match vrf section values + loop: "{{ vrf_section }}" + register: vrf_section_values + pattern_group: + + - name: match name + pattern_match: + regex: "^VRF (\\S+)(?: \\(VRF Id = \\d+\\)|); default RD" + content: "{{ item }}" + register: name + + - name: match description + pattern_match: + regex: "^ Description: (.*)" + content: "{{ item }}" + register: description + + - name: match route distinguisher + pattern_match: + regex: ".*; default RD (\\d+:\\d+|)" + content: "{{ item }}" + register: rd + + - name: match interface section + pattern_match: + regex: "^ Interfaces:([\\s\\S]*)(?:Address family|VRF Table ID)" + content: "{{ item }}" + match_all: true + match_greedy: false + register: interface_section + + - name: match export route target section + pattern_match: + regex: "(?:No|)Export VPN route-target communities([\\s\\S]*) (?:No |)Import VPN" + content: "{{ item }}" + match_all: true + match_greedy: false + register: export_rt_section + + - name: match import route target section + pattern_match: + regex: "Import VPN route-target communities([\\s\\S]*) (?:No |)import" + content: "{{ item }}" + match_all: true + match_greedy: false + register: import_rt_section + +- name: match vrf nested section values + loop: "{{ vrf_section_values }}" + register: vrf_nested_section_values + loop_control: + loop_var: vrf_item + pattern_group: + + - name: match vrf name + pattern_match: + regex: "(.*)" + content: "{{ vrf_item.name.matches.0 }}" + register: name + + - name: match description + pattern_match: + regex: "(.*)" + content: "{{ vrf_item.description.matches.0 }}" + register: description + + - name: match route distinguisher + pattern_match: + regex: "(.*)" + content: "{{ vrf_item.rd.matches.0 }}" + register: rd + + - name: match interfaces + pattern_match: + regex: "\\s+(\\S+)\\s" + content: "{{ vrf_item.interface_section.0.matches }}" + match_all: true + register: interface + + - name: match export route targets + pattern_match: + regex: "\\s+RT:(\\d+:\\d+)" + content: "{{ vrf_item.export_rt_section.0.matches }}" + match_all: true + register: export_rt + + - name: match import route targets + pattern_match: + regex: "\\s+RT:(\\d+:\\d+)" + content: "{{ vrf_item.import_rt_section.0.matches }}" + match_all: true + register: import_rt + +- name: template export json object + export: true + loop: "{{ vrf_nested_section_values }}" + loop_control: + loop_var: vrf_nested_item + register: vrf + extend: cisco_ios + export_as: dict + json_template: + template: + - key: "{{ vrf_nested_item.name.matches.0 }}" + object: + - key: name + value: "{{ vrf_nested_item.name.matches.0 }}" + - key: description + value: "{{ vrf_nested_item.description.matches.0 }}" + - key: rd + value: "{{ vrf_nested_item.rd.matches.0 }}" + - key: export_rt + elements: "{{ export_rt_item.matches }}" + repeat_for: "{{ vrf_nested_item.export_rt }}" + repeat_var: export_rt_item + - key: import_rt + elements: "{{ import_rt_item.matches }}" + repeat_for: "{{ vrf_nested_item.import_rt }}" + repeat_var: import_rt_item + - key: interface + elements: "{{ interface_item.matches }}" + repeat_for: "{{ vrf_nested_item.interface }}" + repeat_var: interface_item diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_lldp_neighbors_detail.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_lldp_neighbors_detail.yaml new file mode 100644 index 0000000..9ec3e32 --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_lldp_neighbors_detail.yaml @@ -0,0 +1,52 @@ +--- +- name: parser meta data + parser_metadata: + version: 1.0 + command: show lldp neighbors detail + network_os: ios + +- name: match sections + pattern_match: + regex: "^-----.*" + match_all: true + match_greedy: true + register: context + +- name: parse lldp neighbors + pattern_group: + - name: parse local port + pattern_match: + regex: "Local Intf: (.+)" + content: "{{ item }}" + register: local_port + + - name: parse remote prort + pattern_match: + regex: "Port id: (.+)" + content: "{{ item }}" + register: remote_port + + - name: parse remote host + pattern_match: + regex: "System Name: (.+)" + content: "{{ item }}" + register: remote_host + + loop: "{{ context }}" + register: matches + +- name: build lldp neighbor facts + register: lldp + export: true + extend: "{{ toplevel | default('cisco_ios') }}" + json_template: + template: + - key: neighbors + elements: + - key: port + value: "{{ item.local_port.matches.0 | expand_interface_name }}" + - key: neighbor + value: "{{ item.remote_host.matches.0 }}" + - key: neighbor_port + value: "{{ item.remote_port.matches.0 }}" + repeat_for: "{{ matches }}" diff --git a/roles/ansible-network.cisco_ios/parser_templates/cli/show_version.yaml b/roles/ansible-network.cisco_ios/parser_templates/cli/show_version.yaml new file mode 100644 index 0000000..9aa42f4 --- /dev/null +++ b/roles/ansible-network.cisco_ios/parser_templates/cli/show_version.yaml @@ -0,0 +1,109 @@ +--- +- name: parser meta data + parser_metadata: + version: 1.0 + command: show version + network_os: ios + +- name: match softare version + pattern_match: + regex: "Cisco IOS Software.*, Version (\\S+)," + register: version + +- name: match model + pattern_match: + regex: "[Cc]isco (.+) \\(" + register: model + +- name: match hostname + pattern_match: + regex: "^(\\S+) uptime is" + register: hostname + +- name: match image + pattern_match: + regex: "^System image file is (\\S+)" + register: image + +- name: match restart conditions + pattern_match: + regex: "^System restarted at (?P