问题
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.
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
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": []}
I've tried different match
types (line, exact
) to no avail.
Maybe I'm getting something wrong here.
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!
回答1:
You could be experiencing this issue:
https://github.com/ansible/ansible/pull/24345
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.
来源:https://stackoverflow.com/questions/45157181/ansible-cisco-idempotence