Categories
Rudder

Rudder and in-file text replacement

At work, we use Rudder to take care of configuration automation.

Today, I was trying to update a small script that we use on all our SMTP gateways, which does an LDAP request.
That LDAP request needed to be updated and instead of connecting to 40+ servers, I made a new Directive in Rudder. Using a regexp, I was trying to replace:

(objectCategory=msExchDynamicDistributionList)(objectCategory=group)(objectCategory=publicFolder)))",

with

(objectCategory=msExchDynamicDistributionList)(objectCategory=group)(objectCategory=publicFolder)))",

With the help of https://regex101.com, I used this regexp at first:

\(objectCategory=group\)

But for some reason it wasn’t working, and I would get:
Error: Because the regular expression '\(objectCategory=group\)' still matches the replacement string

The explanation, of course, is that the regexp I used would still match the replacement line, which means that every time rudder ran, it would be applied.

Thank you rudder for saving my script 🙂