信息系统日常运维中除了服务器,我们还有很多网络设备,比如路由器、交换机、防火墙等。虽然从专业线上分类由主机工程师、网络工程师分别管理,但是在很多小单位可能配置的岗位并不充足,往往是一人身兼数个角色。很荣幸,Ansible也支持网络设备的管理,本文介绍如何使用Ansible管理华为交换机,目前只支持管理CE系列交换机。
环境说明:
如下所示跟华为相关的模块有68个,均以ce开头
[root@centos8 ~]# ansible-doc -l |grep -i huawei |wc -l
68
[root@centos7 ~]# ansible-doc -l |grep -i huawei
ce_aaa_server Manages AAA server global configuration on HUAWEI CloudEngine switches
ce_aaa_server_host Manages AAA server host configuration on HUAWEI CloudEngine switches
ce_acl Manages base ACL configuration on HUAWEI CloudEngine switches
…
hwc_network_vpc Creates a Huawei Cloud VPC
hwc_smn_topic Creates a resource of SMNTopic in Huaweicloud Cloud
[root@centos8 ansible]# cat switchs
[hw]
192.168.200.100 ansible_ssh_port=22 ansible_ssh_user=admin1 ansible_ssh_pass=123456
创建备份交换机配置的playbook,备份到目录/tmp/backup
[root@centos7 ansible]# vim ce.yml
[root@centos8 ansible]# cat ce.yaml - name: CE switch command test. hosts: hw connection: local gather_facts: no vars: cli: host: "{{ inventory_hostname }}" port: "{{ ansible_ssh_port }}" username: "{{ ansible_ssh_user }}" password: "{{ ansible_ssh_pass }}" transport: cli tasks: - name: configurable backup path ce_config: lines: sysname {{ inventory_hostname }} provider: "{{ cli }}" backup: yes backup_options: filename: backup.cfg dir_path: /tmp/backup
[root@centos8 ansible]# ansible-playbook -i switchs ce.yaml
[root@centos8 ansible]# pip3 install ncclient
写在最后,尝试了各种python版本、操作系统版本都是报这个错,估计与eNSP模拟器ce6800有关。折腾了3天了,只能放弃了。直接执行是成功的,执行play-book报错没有收到交换机的任何信息。
如果您发现该资源为电子书等存在侵权的资源或对该资源描述不正确等,可点击“私信”按钮向作者进行反馈;如作者无回复可进行平台仲裁,我们会在第一时间进行处理!
加入交流群
请使用微信扫一扫!