关于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 in