From 4b2495a54ce699e17b6d5b5f4495c818247bc770 Mon Sep 17 00:00:00 2001 From: Anil Kumar Muraleedharan Date: Thu, 30 Aug 2018 01:32:06 +0530 Subject: [PATCH] Lenovo integration test roles 1 (#44559) * Integration test suit for cnos_facts, cnos_config, cnos_command, enos_facts, enos_config and enos_command. * Update all_facts.yaml * Update invalid_subset.yaml * Update not_hardware.yaml * Adding cnos_backup, cnos_bgp, cnos_conditional_command, cnos_condtional_template, cnos_ethernet, cnos_portchannel, cnos_rollback. * Update README.md * Adding the sample roles for cnos_save, cnos_show_run, cnos_template, cnos_vlag and cnos_vlan --- .../integration/targets/cnos_backup/README.md | 115 ++++++++++++++++ test/integration/targets/cnos_backup/aliases | 2 + .../cnos_backup/cnos_backup_sample_hosts | 17 +++ .../targets/cnos_backup/tasks/main.yml | 25 ++++ .../targets/cnos_backup/vars/main.yml | 12 ++ test/integration/targets/cnos_bgp/README.md | 119 +++++++++++++++++ test/integration/targets/cnos_bgp/aliases | 2 + .../targets/cnos_bgp/cnos_bgp_sample_hosts | 14 ++ .../targets/cnos_bgp/tasks/main.yml | 78 +++++++++++ .../targets/cnos_bgp/vars/main.yml | 37 ++++++ .../targets/cnos_command/README.md | 115 ++++++++++++++++ test/integration/targets/cnos_command/aliases | 2 + .../cnos_command/cnos_command_sample_hosts | 14 ++ .../targets/cnos_command/defaults/main.yaml | 3 + .../targets/cnos_command/tasks/cli.yaml | 15 +++ .../targets/cnos_command/tasks/main.yaml | 2 + .../cnos_command/tests/cli/bad_operator.yaml | 20 +++ .../cnos_command/tests/cli/contains.yaml | 20 +++ .../cnos_command/tests/cli/invalid.yaml | 29 +++++ .../cnos_command/tests/cli/output.yaml | 29 +++++ .../cnos_command/tests/cli/timeout.yaml | 19 +++ .../targets/cnos_command/vars/main.yaml | 10 ++ .../cnos_conditional_command/README.md | 120 +++++++++++++++++ .../targets/cnos_conditional_command/aliases | 2 + .../cnos_conditional_command_sample_hosts | 14 ++ .../cnos_conditional_command/tasks/main.yml | 7 + .../cnos_conditional_command/vars/main.yml | 3 + .../cnos_conditional_template/README.md | 120 +++++++++++++++++ .../targets/cnos_conditional_template/aliases | 2 + .../cnos_conditional_template_sample_hosts | 14 ++ .../cnos_conditional_template/tasks/main.yml | 11 ++ .../templates/demo_template.j2 | 16 +++ .../cnos_conditional_template/vars/main.yml | 3 + .../integration/targets/cnos_config/README.md | 123 ++++++++++++++++++ test/integration/targets/cnos_config/aliases | 2 + .../cnos_config/cnos_config_sample_hosts | 14 ++ .../targets/cnos_config/defaults/main.yaml | 3 + .../targets/cnos_config/tasks/cli.yaml | 15 +++ .../targets/cnos_config/tasks/main.yaml | 2 + .../cnos_config/templates/basic/config.j2 | 4 + .../cnos_config/templates/basic/config1.j2 | 4 + .../cnos_config/templates/defaults/config.j2 | 2 + .../targets/cnos_config/tests/cli/backup.yaml | 52 ++++++++ .../targets/cnos_config/tests/cli/basic.yaml | 39 ++++++ .../cnos_config/tests/cli/defaults.yaml | 50 +++++++ .../targets/cnos_config/vars/main.yml | 9 ++ .../targets/cnos_ethernet/README.md | 120 +++++++++++++++++ .../integration/targets/cnos_ethernet/aliases | 2 + .../cnos_ethernet/cnos_ethernet_sample_hosts | 14 ++ .../targets/cnos_ethernet/tasks/main.yml | 98 ++++++++++++++ .../targets/cnos_ethernet/vars/main.yml | 49 +++++++ test/integration/targets/cnos_facts/README.md | 112 ++++++++++++++++ test/integration/targets/cnos_facts/aliases | 2 + .../cnos_facts/cnos_facts_sample_hosts | 14 ++ .../targets/cnos_facts/defaults/main.yaml | 3 + .../targets/cnos_facts/tasks/cli.yaml | 15 +++ .../targets/cnos_facts/tasks/main.yml | 2 + .../cnos_facts/tests/cli/all_facts.yaml | 27 ++++ .../cnos_facts/tests/cli/default_facts.yaml | 30 +++++ .../cnos_facts/tests/cli/invalid_subset.yaml | 39 ++++++ .../cnos_facts/tests/cli/not_hardware.yaml | 28 ++++ .../targets/cnos_facts/vars/main.yml | 9 ++ .../targets/cnos_portchannel/README.md | 117 +++++++++++++++++ .../targets/cnos_portchannel/aliases | 2 + .../cnos_portchannel_sample_hosts | 14 ++ .../targets/cnos_portchannel/tasks/main.yml | 98 ++++++++++++++ .../targets/cnos_portchannel/vars/main.yml | 49 +++++++ .../targets/cnos_rollback/README.md | 119 +++++++++++++++++ .../integration/targets/cnos_rollback/aliases | 2 + .../cnos_rollback/cnos_rollback_sample_hosts | 17 +++ .../targets/cnos_rollback/tasks/main.yml | 25 ++++ .../targets/cnos_rollback/vars/main.yml | 12 ++ test/integration/targets/cnos_save/README.md | 96 ++++++++++++++ test/integration/targets/cnos_save/aliases | 2 + .../targets/cnos_save/cnos_save_sample_hosts | 14 ++ .../targets/cnos_save/tasks/main.yml | 18 +++ .../targets/cnos_save/vars/main.yml | 9 ++ .../targets/cnos_showrun/README.md | 96 ++++++++++++++ test/integration/targets/cnos_showrun/aliases | 2 + .../cnos_showrun/cnos_showrun_sample_hosts | 14 ++ .../targets/cnos_showrun/tasks/main.yml | 6 + .../targets/cnos_showrun/vars/main.yml | 3 + .../targets/cnos_template/README.md | 112 ++++++++++++++++ .../integration/targets/cnos_template/aliases | 2 + .../cnos_template/cnos_template_sample_hosts | 14 ++ .../targets/cnos_template/tasks/main.yml | 13 ++ .../cnos_template/templates/demo_template.j2 | 16 +++ .../targets/cnos_template/vars/main.yml | 3 + test/integration/targets/cnos_vlag/README.md | 115 ++++++++++++++++ test/integration/targets/cnos_vlag/aliases | 2 + .../targets/cnos_vlag/cnos_vlag_sample_hosts | 14 ++ .../targets/cnos_vlag/tasks/main.yml | 51 ++++++++ .../targets/cnos_vlag/vars/main.yml | 33 +++++ test/integration/targets/cnos_vlan/README.md | 116 +++++++++++++++++ test/integration/targets/cnos_vlan/aliases | 2 + .../targets/cnos_vlan/cnos_vlan_sample_hosts | 14 ++ .../targets/cnos_vlan/tasks/main.yml | 35 +++++ .../targets/cnos_vlan/vars/main.yml | 19 +++ .../targets/enos_command/README.md | 115 ++++++++++++++++ test/integration/targets/enos_command/aliases | 2 + .../targets/enos_command/defaults/main.yaml | 3 + .../targets/enos_command/tasks/cli.yaml | 15 +++ .../targets/enos_command/tasks/main.yaml | 2 + .../enos_command/tests/cli/bad_operator.yaml | 20 +++ .../enos_command/tests/cli/contains.yaml | 20 +++ .../enos_command/tests/cli/invalid.yaml | 29 +++++ .../enos_command/tests/cli/output.yaml | 29 +++++ .../enos_command/tests/cli/timeout.yaml | 19 +++ .../targets/enos_command/vars/main.yaml | 13 ++ .../integration/targets/enos_config/README.md | 123 ++++++++++++++++++ test/integration/targets/enos_config/aliases | 2 + .../targets/enos_config/defaults/main.yaml | 3 + .../targets/enos_config/tasks/cli.yaml | 15 +++ .../targets/enos_config/tasks/main.yaml | 2 + .../enos_config/templates/basic/config.j2 | 4 + .../enos_config/templates/defaults/config.j2 | 2 + .../targets/enos_config/tests/cli/backup.yaml | 52 ++++++++ .../targets/enos_config/tests/cli/basic.yaml | 39 ++++++ .../enos_config/tests/cli/defaults.yaml | 50 +++++++ .../targets/enos_config/tests/cli/force.yaml | 41 ++++++ .../targets/enos_config/vars/main.yml | 9 ++ test/integration/targets/enos_facts/README.md | 111 ++++++++++++++++ test/integration/targets/enos_facts/aliases | 2 + .../targets/enos_facts/defaults/main.yaml | 3 + .../targets/enos_facts/tasks/cli.yaml | 15 +++ .../targets/enos_facts/tasks/main.yml | 2 + .../enos_facts/tests/cli/all_facts.yaml | 27 ++++ .../enos_facts/tests/cli/default_facts.yaml | 29 +++++ .../enos_facts/tests/cli/invalid_subset.yaml | 43 ++++++ .../enos_facts/tests/cli/not_hardware.yaml | 28 ++++ .../targets/enos_facts/vars/main.yml | 9 ++ 131 files changed, 4048 insertions(+) create mode 100644 test/integration/targets/cnos_backup/README.md create mode 100644 test/integration/targets/cnos_backup/aliases create mode 100644 test/integration/targets/cnos_backup/cnos_backup_sample_hosts create mode 100644 test/integration/targets/cnos_backup/tasks/main.yml create mode 100644 test/integration/targets/cnos_backup/vars/main.yml create mode 100644 test/integration/targets/cnos_bgp/README.md create mode 100644 test/integration/targets/cnos_bgp/aliases create mode 100644 test/integration/targets/cnos_bgp/cnos_bgp_sample_hosts create mode 100644 test/integration/targets/cnos_bgp/tasks/main.yml create mode 100644 test/integration/targets/cnos_bgp/vars/main.yml create mode 100644 test/integration/targets/cnos_command/README.md create mode 100644 test/integration/targets/cnos_command/aliases create mode 100644 test/integration/targets/cnos_command/cnos_command_sample_hosts create mode 100644 test/integration/targets/cnos_command/defaults/main.yaml create mode 100644 test/integration/targets/cnos_command/tasks/cli.yaml create mode 100644 test/integration/targets/cnos_command/tasks/main.yaml create mode 100644 test/integration/targets/cnos_command/tests/cli/bad_operator.yaml create mode 100644 test/integration/targets/cnos_command/tests/cli/contains.yaml create mode 100644 test/integration/targets/cnos_command/tests/cli/invalid.yaml create mode 100644 test/integration/targets/cnos_command/tests/cli/output.yaml create mode 100644 test/integration/targets/cnos_command/tests/cli/timeout.yaml create mode 100644 test/integration/targets/cnos_command/vars/main.yaml create mode 100644 test/integration/targets/cnos_conditional_command/README.md create mode 100644 test/integration/targets/cnos_conditional_command/aliases create mode 100644 test/integration/targets/cnos_conditional_command/cnos_conditional_command_sample_hosts create mode 100644 test/integration/targets/cnos_conditional_command/tasks/main.yml create mode 100644 test/integration/targets/cnos_conditional_command/vars/main.yml create mode 100644 test/integration/targets/cnos_conditional_template/README.md create mode 100644 test/integration/targets/cnos_conditional_template/aliases create mode 100644 test/integration/targets/cnos_conditional_template/cnos_conditional_template_sample_hosts create mode 100644 test/integration/targets/cnos_conditional_template/tasks/main.yml create mode 100644 test/integration/targets/cnos_conditional_template/templates/demo_template.j2 create mode 100644 test/integration/targets/cnos_conditional_template/vars/main.yml create mode 100644 test/integration/targets/cnos_config/README.md create mode 100644 test/integration/targets/cnos_config/aliases create mode 100644 test/integration/targets/cnos_config/cnos_config_sample_hosts create mode 100644 test/integration/targets/cnos_config/defaults/main.yaml create mode 100644 test/integration/targets/cnos_config/tasks/cli.yaml create mode 100644 test/integration/targets/cnos_config/tasks/main.yaml create mode 100644 test/integration/targets/cnos_config/templates/basic/config.j2 create mode 100644 test/integration/targets/cnos_config/templates/basic/config1.j2 create mode 100644 test/integration/targets/cnos_config/templates/defaults/config.j2 create mode 100644 test/integration/targets/cnos_config/tests/cli/backup.yaml create mode 100644 test/integration/targets/cnos_config/tests/cli/basic.yaml create mode 100644 test/integration/targets/cnos_config/tests/cli/defaults.yaml create mode 100644 test/integration/targets/cnos_config/vars/main.yml create mode 100644 test/integration/targets/cnos_ethernet/README.md create mode 100644 test/integration/targets/cnos_ethernet/aliases create mode 100644 test/integration/targets/cnos_ethernet/cnos_ethernet_sample_hosts create mode 100644 test/integration/targets/cnos_ethernet/tasks/main.yml create mode 100644 test/integration/targets/cnos_ethernet/vars/main.yml create mode 100644 test/integration/targets/cnos_facts/README.md create mode 100644 test/integration/targets/cnos_facts/aliases create mode 100644 test/integration/targets/cnos_facts/cnos_facts_sample_hosts create mode 100644 test/integration/targets/cnos_facts/defaults/main.yaml create mode 100644 test/integration/targets/cnos_facts/tasks/cli.yaml create mode 100644 test/integration/targets/cnos_facts/tasks/main.yml create mode 100644 test/integration/targets/cnos_facts/tests/cli/all_facts.yaml create mode 100644 test/integration/targets/cnos_facts/tests/cli/default_facts.yaml create mode 100644 test/integration/targets/cnos_facts/tests/cli/invalid_subset.yaml create mode 100644 test/integration/targets/cnos_facts/tests/cli/not_hardware.yaml create mode 100644 test/integration/targets/cnos_facts/vars/main.yml create mode 100644 test/integration/targets/cnos_portchannel/README.md create mode 100644 test/integration/targets/cnos_portchannel/aliases create mode 100644 test/integration/targets/cnos_portchannel/cnos_portchannel_sample_hosts create mode 100644 test/integration/targets/cnos_portchannel/tasks/main.yml create mode 100644 test/integration/targets/cnos_portchannel/vars/main.yml create mode 100644 test/integration/targets/cnos_rollback/README.md create mode 100644 test/integration/targets/cnos_rollback/aliases create mode 100644 test/integration/targets/cnos_rollback/cnos_rollback_sample_hosts create mode 100644 test/integration/targets/cnos_rollback/tasks/main.yml create mode 100644 test/integration/targets/cnos_rollback/vars/main.yml create mode 100644 test/integration/targets/cnos_save/README.md create mode 100644 test/integration/targets/cnos_save/aliases create mode 100644 test/integration/targets/cnos_save/cnos_save_sample_hosts create mode 100644 test/integration/targets/cnos_save/tasks/main.yml create mode 100644 test/integration/targets/cnos_save/vars/main.yml create mode 100644 test/integration/targets/cnos_showrun/README.md create mode 100644 test/integration/targets/cnos_showrun/aliases create mode 100644 test/integration/targets/cnos_showrun/cnos_showrun_sample_hosts create mode 100644 test/integration/targets/cnos_showrun/tasks/main.yml create mode 100644 test/integration/targets/cnos_showrun/vars/main.yml create mode 100644 test/integration/targets/cnos_template/README.md create mode 100644 test/integration/targets/cnos_template/aliases create mode 100644 test/integration/targets/cnos_template/cnos_template_sample_hosts create mode 100644 test/integration/targets/cnos_template/tasks/main.yml create mode 100644 test/integration/targets/cnos_template/templates/demo_template.j2 create mode 100644 test/integration/targets/cnos_template/vars/main.yml create mode 100644 test/integration/targets/cnos_vlag/README.md create mode 100644 test/integration/targets/cnos_vlag/aliases create mode 100644 test/integration/targets/cnos_vlag/cnos_vlag_sample_hosts create mode 100644 test/integration/targets/cnos_vlag/tasks/main.yml create mode 100644 test/integration/targets/cnos_vlag/vars/main.yml create mode 100644 test/integration/targets/cnos_vlan/README.md create mode 100644 test/integration/targets/cnos_vlan/aliases create mode 100644 test/integration/targets/cnos_vlan/cnos_vlan_sample_hosts create mode 100644 test/integration/targets/cnos_vlan/tasks/main.yml create mode 100644 test/integration/targets/cnos_vlan/vars/main.yml create mode 100644 test/integration/targets/enos_command/README.md create mode 100644 test/integration/targets/enos_command/aliases create mode 100644 test/integration/targets/enos_command/defaults/main.yaml create mode 100644 test/integration/targets/enos_command/tasks/cli.yaml create mode 100644 test/integration/targets/enos_command/tasks/main.yaml create mode 100644 test/integration/targets/enos_command/tests/cli/bad_operator.yaml create mode 100644 test/integration/targets/enos_command/tests/cli/contains.yaml create mode 100644 test/integration/targets/enos_command/tests/cli/invalid.yaml create mode 100644 test/integration/targets/enos_command/tests/cli/output.yaml create mode 100644 test/integration/targets/enos_command/tests/cli/timeout.yaml create mode 100644 test/integration/targets/enos_command/vars/main.yaml create mode 100644 test/integration/targets/enos_config/README.md create mode 100644 test/integration/targets/enos_config/aliases create mode 100644 test/integration/targets/enos_config/defaults/main.yaml create mode 100644 test/integration/targets/enos_config/tasks/cli.yaml create mode 100644 test/integration/targets/enos_config/tasks/main.yaml create mode 100644 test/integration/targets/enos_config/templates/basic/config.j2 create mode 100644 test/integration/targets/enos_config/templates/defaults/config.j2 create mode 100644 test/integration/targets/enos_config/tests/cli/backup.yaml create mode 100644 test/integration/targets/enos_config/tests/cli/basic.yaml create mode 100644 test/integration/targets/enos_config/tests/cli/defaults.yaml create mode 100644 test/integration/targets/enos_config/tests/cli/force.yaml create mode 100644 test/integration/targets/enos_config/vars/main.yml create mode 100644 test/integration/targets/enos_facts/README.md create mode 100644 test/integration/targets/enos_facts/aliases create mode 100644 test/integration/targets/enos_facts/defaults/main.yaml create mode 100644 test/integration/targets/enos_facts/tasks/cli.yaml create mode 100644 test/integration/targets/enos_facts/tasks/main.yml create mode 100644 test/integration/targets/enos_facts/tests/cli/all_facts.yaml create mode 100644 test/integration/targets/enos_facts/tests/cli/default_facts.yaml create mode 100644 test/integration/targets/enos_facts/tests/cli/invalid_subset.yaml create mode 100644 test/integration/targets/enos_facts/tests/cli/not_hardware.yaml create mode 100644 test/integration/targets/enos_facts/vars/main.yml diff --git a/test/integration/targets/cnos_backup/README.md b/test/integration/targets/cnos_backup/README.md new file mode 100644 index 0000000000..d2f161f4ed --- /dev/null +++ b/test/integration/targets/cnos_backup/README.md @@ -0,0 +1,115 @@ +# Ansible Role: cnos_backup_sample - Saving the switch configuration to a remote server +--- + + +This role is an example of using the *cnos_backup.py* Lenovo module in the context of CNOS switch configuration. This module allows you to work with switch configurations. It provides a way to back up the running or startup configurations of a switch to a remote server. This is achieved by periodically saving a copy of the startup or running configuration of the network device to a remote server using FTP, SFTP, TFTP, or SCP. + +The results of the operation can be viewed in *results* directory. + +For more details, see [Lenovo modules for Ansible: cnos_backup](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_backup.html&cp=0_3_1_0_4_4). + + +## Requirements +--- + + +- Ansible version 2.2 or later ([Ansible installation documentation](http://docs.ansible.com/ansible/intro_installation.html)) +- Lenovo switches running CNOS version 10.2.1.0 or later +- an SSH connection to the Lenovo switch (SSH must be enabled on the network device) + + +## Role Variables +--- + + +Available variables are listed below, along with description. + +The following are mandatory inventory variables: + +Variable | Description +--- | --- +`ansible_connection` | Has to be `network_cli` +`ansible_network_os` | Has to be `cnos` +`ansible_ssh_user` | Specifies the username used to log into the switch +`ansible_ssh_pass` | Specifies the password used to log into the switch +`enablePassword` | Configures the password used to enter Global Configuration command mode on the switch (this is an optional parameter) +`hostname` | Searches the hosts file at */etc/ansible/hosts* and identifies the IP address of the switch on which the role is going to be applied +`deviceType` | Specifies the type of device from where the configuration will be backed up (**g8272_cnos** - G8272, **g8296_cnos** - G8296, **g8332_cnos** - G8332, **NE10032** - NE10032, **NE1072T** - NE1072T, **NE1032** - NE1032, **NE1032T** - NE1032T, **NE2572** - NE2572) + +The values of the variables used need to be modified to fit the specific scenario in which you are deploying the solution. To change the values of the variables, you need to visits the *vars* directory of each role and edit the *main.yml* file located there. The values stored in this file will be used by Ansible when the template is executed. + +The syntax of *main.yml* file for variables is the following: + +``` +