Hi All,
I’m learning Ansible and am preparing to try and execute both deployment and configuration maintenance on a few systems at work.
One configuration file in particular is giving me issues however. I want to be able to update Min and Max Instances in this section of a cfg file:
`
…
[PSAPPSRV]
;=========================================================================
; Settings for PSAPPSRV
;=========================================================================
;-------------------------------------------------------------------------
; UBBGEN settings
Min Instances=25
Max Instances=25
Service Timeout=300
;-------------------------------------------------------------------------
; Number of services after which PSAPPSRV will automatically restart.
…
`
The problem is the file also contains other sections with identical Min/Max lines like this:
`
…
[PSQRYSRV]
;=========================================================================
; Settings for PSQRYSRV
;=========================================================================
;-------------------------------------------------------------------------
; UBBGEN settings
Min Instances=6
Max Instances=6
Service Timeout=1200
;-------------------------------------------------------------------------
; Number of services after which PSQRYSRV will automatically restart.
…
`
I want to be able to run an ansible task repeatedly against this file to update the Min/Max lines only if changed. I don’t want to use the template or shell modules because if the lines are changed, I need to initiate a restart of the dependent services and I don’t want to do that unnecessarily. I also want to have some sort of record of the file being changed via the ansible-playbook output.
I’ve looked into lineinfile module, but have yet to find a way to only update a single line number. I looked into sed with ansible variables, but again, that doesn’t meet the idempotent requirement.
Is there any way to achieve what i’m looking for here?
Thanks,
Jason