Hello Ansible users,
I'm trying to replace multiple lines in multiple files using the lineinfile and register, and this is what I got so far.
- name: list of the .conf files
raw: ls /etc/httpd/conf.d/*.conf
register: certs_dir
tags: update-cert
- name: update certs with the new name in *conf
lineinfile: dest={{item}} backup=yes state=present regexp="^ SSLCertificateFile" insertafter="^ SSLCertificateFile" line=" SSLCertificateFile /etc/pki/tls/certs/new_cert.cer"
with_items: certs_dir.stdout_lines
tags: update-cert
the problem with this is It will only replace one line in multiple files, is there any better way of doing this other than making another copy of the second task to replace line?
please advise,
thank you