2.ansible备份设备文件
[root@localhost ~]# tree ansible
ansible
├── ansible.cfg
├── ce.yml
├── cisco.yml
└── inventory
ansible.cfg文件
[root@localhost ansible]# cat ansible.cfg
[defaults]
host_key_checking = False
inventory文件
[root@localhost ansible]# cat inventory
[all:vars]
#ansible_connection=network_cli
ansible_ssh_user=admin
ansible_ssh_pass=Tonghao@2021
ansible_ssh_port=22
#ansible_network_os=ios
[ce]
192.168.0.156
[cisco]
192.168.1.253
[h3c]
192.168.0.254
[linux]
192.168.0.147 ansible_host=192.168.0.147 anasible_user=root ansible_password=lnops@123
ansible playbook配置
# 华为网络设备备份配置文件
[root@localhost ansible]# cat ce.yml
- name: CloudEngine ce_interface test
hosts: ce
connection:
gather_facts: no
tasks:
- name: configurable backup path
ce_config:
backup: yes
backup_options:
filename: "{{ ansible_host }}.cfg"
dir_path: /opt
# cisco设备备份
[root@localhost ansible]# cat cisco.yml
---
- name: backup config
connection: local
hosts: cisco
gather_facts: false
vars:
dir: /opt
tasks:
- name: backup ios devices
ios_config:
backup: yes
backup_options:
dir_path: "{{ dir }}"
filename: "{{ ansible_host }}.cfg"
provider:
authorize: yes
auth_pass: Tonghao@2021

浙公网安备 33010602011771号