• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..11-Oct-2021-

tasks/H03-May-2022-1915

vars/H03-May-2022-109

README.mdH A D03-May-20224.8 KiB9666

aliasesH A D03-May-202261 32

cnos_save_sample_hostsH A D03-May-2022681 1513

README.md

1# Ansible Role: cnos_save_sample - Saving the switch running configuration
2---
3<add role description below>
4
5This role is an example of using the *cnos_save.py* Lenovo module in the context of CNOS switch configuration. This module allows you to copy the running configuration of a switch over its startup configuration. It is recommended to use this module shortly after any major configuration changes so they persist after a switch restart.
6
7The results of the operation can be viewed in *results* directory.
8
9For more details, see [Lenovo modules for Ansible: cnos_save](http://systemx.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.switchmgt.ansible.doc%2Fcnos_save.html&cp=0_3_1_0_4_3).
10
11
12## Requirements
13---
14<add role requirements information below>
15
16- Ansible version 2.2 or later ([Ansible installation documentation](http://docs.ansible.com/ansible/intro_installation.html))
17- Lenovo switches running CNOS version 10.2.1.0 or later
18- an SSH connection to the Lenovo switch (SSH must be enabled on the network device)
19
20
21## Role Variables
22---
23<add role variables information below>
24
25Available variables are listed below, along with description.
26
27The following are mandatory inventory variables:
28
29Variable | Description
30--- | ---
31`ansible_connection` | Has to be `network_cli`
32`ansible_network_os` | Has to be `cnos`
33`ansible_ssh_user` | Specifies the username used to log into the switch
34`ansible_ssh_pass` | Specifies the password used to log into the switch
35`enablePassword` | Configures the password used to enter Global Configuration command mode on the switch (this is an optional parameter)
36`hostname` | Searches the hosts file at */usr/local/etc/ansible/hosts* and identifies the IP address of the switch on which the role is going to be applied
37`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, **NE0152T** - NE0152T)
38
39
40## Dependencies
41---
42<add dependencies information below>
43
44- username.iptables - Configures the firewall and blocks all ports except those needed for web server and SSH access.
45- username.common - Performs common server configuration.
46- cnos_save.py - This modules needs to be present in the *library* directory of the role.
47- cnos.py - This module needs to be present in the PYTHONPATH environment variable set in the Ansible system.
48- /usr/local/etc/ansible/hosts - You must edit the */usr/local/etc/ansible/hosts* file with the device information of the switches designated as leaf switches. You may refer to *cnos_save_sample_hosts* for a sample configuration.
49
50Ansible keeps track of all network elements that it manages through a hosts file. Before the execution of a playbook, the hosts file must be set up.
51
52Open the */usr/local/etc/ansible/hosts* file with root privileges. Most of the file is commented out by using **#**. You can also comment out the entries you will be adding by using **#**. You need to copy the content of the hosts file for the role into the */usr/local/etc/ansible/hosts* file. The sample hosts file for the role is located in the main directory.
53
54```
55[cnos_save_sample]
5610.241.107.39   ansible_network_os=cnos ansible_ssh_user=<username> ansible_ssh_pass=<password> deviceType=g8272_cnos
5710.241.107.40   ansible_network_os=cnos ansible_ssh_user=<username> ansible_ssh_pass=<password> deviceType=g8272_cnos
58```
59
60**Note:** You need to change the IP addresses to fit your specific topology. You also need to change the `<username>` and `<password>` to the appropriate values used to log into the specific Lenovo network devices.
61
62
63## Example Playbook
64---
65<add playbook samples below>
66
67To execute an Ansible playbook, use the following command:
68
69```
70ansible-playbook cnos_save_sample.yml -vvv
71```
72
73`-vvv` is an optional verbos command that helps identify what is happening during playbook execution. The playbook for each role is located in the main directory of the solution.
74
75```
76 - name: Module to  do save configurations
77   hosts: cnos_save_sample
78   gather_facts: no
79   connection: local
80   roles:
81    - cnos_save_sample
82```
83
84
85## License
86---
87<add license information below>
88Copyright (C) 2017 Lenovo, Inc.
89
90This file is part of Ansible
91
92Ansible 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.
93
94Ansible 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.
95
96You should have received a copy of the GNU General Public License along with Ansible.  If not, see <http://www.gnu.org/licenses/>.