Ah Ok, i see.
Using a string manipulating module like replace is inherently fragile,
so whatever works now may break tomorrow (as you pointed out).
Since your input is yaml, I would look into another approach, like
lookup the file content, parse it as yaml, change the required
keys/values, and then write the file back.
This way is more robust in terms of input (the ordering/comments/etc
won't matter), and also output, as that will be valid yaml.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7ba33283-cdd6-4b37-852c-42c5b5c90b79n%40googlegroups.com.