Lineinfile + insertafter

Hello,
The task is as below:

  • name: replace
    lineinfile:
    dest: /tmp/sample/test_file.txt
    regexp: “#}”
    insertafter: ’ "compute": 2,’
    line: “}”
    state: present

And below is my file content:

#OPENSTACK_API_VERSIONS = {

“data-processing”: 1.1,

“identity”: 3,

“image”: 2,

“volume”: 2,

“compute”: 2,

#}

#PROJECT_TABLE_EXTRA_INFO = {

‘phone_num’: _(‘Phone Number’),

#}
#USER_TABLE_EXTRA_INFO = {

‘phone_num’: _(‘Phone Number’),

#}

EXPECTED RESULT:

OPENSTACK_API_VERSIONS = {

“data-processing”: 1.1,

“identity”: 3,

“image”: 2,

“volume”: 2,

“compute”: 2,

}

#PROJECT_TABLE_EXTRA_INFO = {

‘phone_num’: _(‘Phone Number’),

#}

#USER_TABLE_EXTRA_INFO = {

‘phone_num’: _(‘Phone Number’),

#}

CURRENT RESULT:

OPENSTACK_API_VERSIONS = {

“data-processing”: 1.1,

“identity”: 3,

“image”: 2,

“volume”: 2,

“compute”: 2,

#}

#PROJECT_TABLE_EXTRA_INFO = {

‘phone_num’: _(‘Phone Number’),

#}

#USER_TABLE_EXTRA_INFO = {

‘phone_num’: _(‘Phone Number’),

}

The line mentioned in insertafter is not recognized. Kindly, suggest a way forward.

Regards,

Mona G

You should read this thread
https://groups.google.com/forum/#!topic/ansible-project/SK3VF7R4aB4