I’m trying to use Ansible to add several lines of text after a specific line in a config file using the replace module and for whatever reason when I run the playbook, I get back OK responses instead of CHANGED. Below is the following line in the config file:
check_interval 24x7
Replace code in Ansible playbook:
replace: path: "{{ nameof }}.cfg" regexp: '\b24x7' replace: '24x7\n\t.....' after: '\b24x7'
Verbose response:
TASK [Add alerting procedures] ********************************************************************************************************************************************************************************************* task path: /opt/ansible/ansible-to-nagios.yml:81 ok: [127.0.0.1] => { "changed": false, "invocation": { "module_args": { "after": "\\b24x7", "attributes": null, "backup": false, "before": null, "content": null, "delimiter": null, "directory_mode": null, "encoding": "utf-8", "follow": false, "force": null, "group": null, "mode": null, "owner": null, "path": "test.cfg", "regexp": "\\b24x7", "remote_src": null, "replace": "24x7\\n\\t.....", "selevel": null, "serole": null, "setype": null, "seuser": null, "src": null, "unsafe_writes": null, "validate": null } }, "msg": "" }