I am new to ansible.
Is there a simple way to replace the line starting with option domain-name-servers
in /etc/dhcp/interface-br0.conf
with mo
we can use lineinfile module to replace a line
using ad-hoc command:
ansible -m lineinfile -a "path=/etc/dhcp/interface-br0.conf regexp=''^(.*)option domain-name-servers(.*)$'' line='1option domain-name-servers 10.116.184.1,10.116.144.1,10.116.136.1;' backrefs: yes"
using ansible playbook:
- name: replacing a line in file
lineinfile:
path: /etc/dhcp/interface-br0.conf
regexp: '^(.*)option domain-name-servers(.*)$'
line: 'option domain-name-servers 10.116.184.1,10.116.144.1,10.116.136.1;'
backrefs: yes
for more we can check for other options: in lineinfile module
https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html