多平台统一管理软件接口,如何实现多平台统一管理软件接口
585
2022-09-12
ansible 批量配置cisco 交换机---接口篇(ansible windows)
关于ansible不做介绍。本例主要通过实例介绍ansible配置ios接口的几种方法,或者说可利用哪些模块配置接口。
1 .主机列表,本次测试以1台主机为例
[root@Ansible-01 ansible]# cat hosts [cisco] 172.16.254.130 ansible_connection=local
2.playbooks内容
[root@Ansible-01 interface]# cat interface-phy.yml --- - name: interface config hosts: cisco # vars: # creds: # username: "{{ username }}" # password: "{{ password }}" gather_facts: no tasks: - name: action interface G1-2 configure ios_config: lines: - no shutdown - switch mode trunk - switch trunk allow vlan all - do wr parents: interface range gigabitEthernet 1/0/1 - 2 - name: action interface G3 configuration ios_l2_interface: name: GigabitEthernet1/0/3 mode: access access_vlan: 100 - name: action interface G3 configuration ios_l2_interface: name: GigabitEthernet1/0/4 mode: trunk native_vlan: 100 trunk_allowed_vlans: 10-255 - name: save configuration ios_command: commands: - wr
3.执行playbooks
[root@Ansible-01 interface]# ansible-playbook interface-phy.yml -u admin -k SSH password: PLAY [interface config] ************************************************************************************************************** TASK [action interface G1-2 configure] *********************************************************************************************** changed: [172.16.254.130] TASK [action interface G3 configuration] ********************************************************************************************* changed: [172.16.254.130] TASK [action interface G4 configuration] ********************************************************************************************* changed: [172.16.254.130] TASK [save configuration] ************************************************************************************************************ ok: [172.16.254.130] PLAY RECAP *************************************************************************************************************************** 172.16.254.130 : ok=4 changed=3 unreachable=0 failed=0
4.查看执行效果
interface GigabitEthernet1/0/1 switchport mode trunk ! interface GigabitEthernet1/0/2 switchport mode trunk ! interface GigabitEthernet1/0/3 switchport access vlan 100 switchport mode access ! interface GigabitEthernet1/0/4 switchport trunk native vlan 100 switchport trunk allowed vlan 10-255 switchport mode trunk !
可见 ios_config和 ios_l2_interface 两个模块都可以操作,只有三层接口则可以使用ios_comfig或者ios_l3_interface模块。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
评论列表
文章构思独特,创意无限。您的文笔细腻,情感表达真挚,让人感同身受。https://www.sljrkg.com