-1

I have over 2k devices under management. We are retiring the old syslog server, and have to point all the devices to the new syslog server IP address. The challenge is that some devices have different 'words' or 'functions' after the ip address:

Goal is to replace the syslog server IP, but keep the rest of the command intact - for example, some will have:

logging x.x.x.x
logging host x.x.x.x
logging x.x.x.x source-interface <something>
logging x.x.x.x use-vrf <blah>

I would like to end up with the same config on the device, just y.y.y.y for the IP. Is this possible?

Otherwise, the only way I can think of to solve the problem would be to write a playbook for each scenario, and end up with a separate inventory and playbook for each different syslog configuration line.

1 Answers1

1

You want to use the replace module. This will let you key in the on old IP address and change all instances of it, without having to swap out the whole line like you would with lineinfile.

https://docs.ansible.com/ansible/latest/modules/replace_module.html

ebrewer
  • 474
  • 5
  • 11