Ansible + Cisco 幂等性 [英] Ansible + Cisco idempotence
问题描述
所以我正在使用 Ansible 进行一些测试来管理 Cisco 设备(在本例中特别是 3750).我可以毫无问题地添加我的 VLAN 和环回.
So I'm doing some testing with Ansible to manage Cisco devices (specifically a 3750 in this case). I'm able to add my VLAN's and Loopbacks with no issue.
当存在环回或 VLAN 时,只是试图让 Ansible 停止在任务中注册更改.
Just trying to get Ansible to stop registering a change in the task when the Loopback or VLAN exists.
现在我的剧本是这样的:
Right now my play looks like this:
- name: Set the IP for Loop 0
ios_config:
provider: "{{ connection }}"
lines:
- description AnsibleLoop0
- ip address 8.8.8.8 255.255.255.0
before:
- interface Loopback0
match: exact
任何时候运行这个任务,Ansible 都会像更改一样注册它:
Anytime this task is run, Ansible registers it like a change:
已更改:[switch] =>{"changed": true, "updates": ["interface Loopback0", "description AnsibleLoop0", "ip address 8.8.8.8 255.255.255.0"], "warnings": []}
我尝试了不同的 match
类型(line,exact
),但无济于事.也许我在这里弄错了.
I've tried different match
types (line, exact
) to no avail.
Maybe I'm getting something wrong here.
我想,如果我让剧本插入这些行,就像它们在 show run
中的显示方式一样,它就不会将其注册为更改?
I thought that if I had the play insert the lines exactly like how they would show up in a show run
it wouldnt register it as a change?
这里的任何帮助将不胜感激!
Any help here would be appreciated!
推荐答案
您可能遇到此问题:
https://github.com/ansible/ansible/pull/24345
您是否每次都使用剧本中的 save: "yes"
将配置更改保存到 Cisco 设备中?我遇到了同样的问题,每次运行剧本时我都保存配置.设置no
只是为了测试,在第一次运行报告 changed=True
后,Ansible 将报告 changed=False
连续运行.
Are you saving the configuration changes each time to the Cisco device using save: "yes"
in your playbook? I had the same problem and I was saving the config each time the playbook ran. Setting that to no
just to test, after the first run reports changed=True
sequential runs would report back changed=False
by Ansible.
这篇关于Ansible + Cisco 幂等性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!