Ansible +思科幂等 [英] Ansible + Cisco idempotence

查看:143
本文介绍了Ansible +思科幂等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用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.

现在我的游戏如下:

    - 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:

changed: [switch] => {"changed": true, "updates": ["interface Loopback0", "description AnsibleLoop0", "ip address 8.8.8.8 255.255.255.0"], "warnings": []}

changed: [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 +思科幂等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆