What is the Ansible playbook backup Cisco ios configuration like
This article is to share with you about Ansible playbook backup Cisco ios configuration, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's follow the editor to have a look.
The hosts file contains the host asset information
Secrets.yml is used to place the user name and password
Success_backup.yml is the yaml file to be executed
192.168.60.120.txt is a post-execution production file.
# hosts
[ios_device]
192.168.60.120
# secrets.yml
-
Creds:
Username: cisco
Password: cisco
Auth_pass: cisco
# success_backup.yml
-
-hosts: ios_device
Gather_facts: no
Connection: local
Tasks:
-name: OBTAIN LOGIN CREDENTIALS # get login credentials (username and password)
Include_vars: secrets.yml
-name: DEFINE PROVIDER # defines a provider
Set_fact:
Provider:
Host: "{{inventory_hostname}}"
Username: "{{creds ['username']}}"
Password: "{{creds ['password']}}"
Auth_pass: "{{creds ['auth_pass']}}"
-name: show run # View configuration file
Ios_command:
Provider: "{{provider}}"
Authorize: yes
Commands:
-show run
Register: output
-debug: var=output.stdout_lines # outputs the output variable
-name: save the output content to a file # put the content locally on the control machine
Local_action: copy content= {{output.stdout_lines}} dest= ". / {{inventory_hostname}} .txt"
-
Note:
The host where the 1.Ansible is located should be able to communicate with cisco ios devices with ssh
2.cisco ios configuration ssh process:
Ip domain-name [cisco.com] / / cisco.com this is filled in according to your actual situation.
Cryto key generate
Line vty 0 4
Login local
Transparent input ssh
Ip ssh time-out 120 / / modify timeout
Ip ssh authentication-retries 1 / / modify the number of recertification times.
Ip ssh version 2 / / modified version
The above is what the Ansible playbook backup Cisco ios configuration is like, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.