I've been trying to finish up a playbook for deploying a new server. I'm struggling with changing data within brackets containing quotes via lineinfile
and a regex:
- name: "Configuring: filebeat agent - configuring output to logstash"
lineinfile:
dest: "/etc/filebeat/filebeat.yml"
regexp: '#hosts: ["localhost:5044"]'
line: 'hosts: ["elk.home:5044"]'
tags: application
After the playbook is executed, the desired line:
#hosts: ["localhost:5044"]
is not updated to reflect:
hosts: ["elk.home:5044"]
What I'm trying to achieve is:
#hosts: ["localhost:5044"]
is replaced with hosts: ["elk.home:5044"]
There are no errors generated. I've tried varying "
and '
along with escapes \
, but I can't get the expression correct. Any suggestions would be greatly appreciated!