Please help me with your guidance here.
I want to comment a line in one config file and need to uncomment the other lline using ansible.
My file content as below.
`<include location="conf/basicUserRegistry.xml"/>`
this i want to comment
`<!--include location="conf/ldapUserRegistry.xml"/-->`
this line i want to uncomment
I tried with the below play book and its not showing any error even though its not changing any changes to the file.
- name: enable LDAP
hosts: localhost
tasks:
- name: disbale basic user-registry
lineinfile:
path: /opt/IBM/605CLM/JazzTeamServer/server/liberty/servers/clm/server.xml
regexp: '^\s*<include location="conf/basicUserRegistry.xml">.*$'
line: '<!--include location="conf/basicUserRegistry.xml"-->;'
backrefs: yes
become: true
- name: enable LDAP USER_REGISTRY
hosts: localhost
tasks:
lineinfile:
dest: /opt/IBM/605CLM/JazzTeamServer/server/liberty/servers/clm/server.xml
regexp: '^(.*)<!--include location="conf/ldapUserRegistry.xml"-->(.*)$'
line: '<include location="conf/ldapUserRegistry.xml">;'
backrefs: yes
Output:
PLAY [enable LDAP] ******************************************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************************************************** ok: [localhost]
TASK [disbale basic user-registry] ************************************************************************************************************************** ok: [localhost]
PLAY RECAP ************************************************************************************************************************************************** localhost : ok=2 changed=0 unreachable=0 failed=0