Hey everyone,
I’m giving Ansible a try and I’m quite impressed.
I have a couple of questions regarding the ios_config module.
`
Hey everyone,
I’m giving Ansible a try and I’m quite impressed.
I have a couple of questions regarding the ios_config module.
`
Hi Stijn:
For the host argument use the following syntax: host: “{{ inventory_hostname }}”
That will replace the value for host based on the node defined in inventory.
For the using the env var you need to set that in your shell environment, not the inventory file. If you want to keep the password in the inventory file, then reference in your playbook as such:
[ios]
ios01
[ios:vars]
ios_password=mysecret
ios_config
commands: show version
host: “{{ inventory_hostname }}”
username: cisco
password: “{{ ios_password }}”
Lastly, with regards to how Ansible makes decisions about how to push config. Its based on what is in the running config with exact string matching. In other words, the values in lines must match exactly what is reflected in the device running-config otherwise Ansible thinks it needs to push the command.
Thanks a lot Peter, that works flawlessly.
Regarding the pushing of the config I found the “mistake”, my config pushes the sequence of the ACL rules which is not shown in the running config. So that’s why there’s no exact match as you explained. I removed the sequence numbers and now it’s ok.
I tried the
save: yes
option and that doesn’t seem to work. It says
`
fatal: [192.168.1.1]: FAILED! => {“changed”: false, “failed”: true, “msg”: “timeout trying to send command: copy running-config startup-config\r”}
`
I also think I know why it says that. When I run this command directly on the router I get
`
Router#copy running-config startup-config
Destination filename [startup-config]?
Building configuration…
[OK]
`
So it seems Ansible times out on the confirmation the router is expecting for the file to write to, in this case startup-config.
This is an old box so don’t know if it’s the same on newer IOS versions, but this looks like a bug in the ios_config module or am I doing something wrong?
Thanks everyone!!!
Stijn