I have config files that come from a pre-existing deployment process. (Varying formats, but java.properties files comprise most of them, if it matters.)
I need to change (if the corresponding property exists), or add (if it doesn't) multiple properties in these files.
However, I have no control over the creation of the pre-existing files. They are created externally, and the variables I want to modify are scattered throughout the lines of the file.
It looks like blockinfile
won't be useful here, since it seems to work on contiguous blocks of properties (is that correct?)
Does this mean I need to use multiple lineinfile
declarations (or one using a with_items
loop as per: ansible: lineinfile for several lines?)?
Or is there a better more canonical way to deal with this.
For example, consider the following pre-existing file.
config.item_1=bear1
config.item_2=bear2
config.item_3=bear3
config.item_4=bear4
config.item_5=bear5
And I just want to modify config.item1, config.item_3 to be (dog1, cat1). I also want to add config.arbitrary.param.name=40 resulting in:
config.item_1=dog1
config.item_2=bear2
config.item_3=cat1
config.item_4=bear4
config.item_5=bear5
config.arbitrary.param.name=40