Ansible自动化框架高级特性解析
1. Ansible Arista示例
在Ansible中,我们可以使用Arista命令模块来对Arista设备进行操作。Arista设备可以配置为使用CLI或EAPI进行传输,这里我们使用CLI。
首先是主机文件:
[eos_devices]
A1 ansible_host=192.168.199.158
对应的playbook如下:
---
- name: EOS Show Commands
hosts: "eos_devices"
gather_facts: false
connection: local
vars:
cli:
host: "{
{ ansible_host }}"
username: "arista"
password: "arista"
authorize: true
transport: cli
tasks:
- name: eos show commands
eos_command:
commands:
- show version | i Arista
provider: "{
{ cli }}"
register: output
- name: show output
debug:
v