our SSL certificate runs out in a couple of days. So I thought Ansible can put the new certs on the server und change the apache2 sites.
Serveral sites are running on this server.
I want to replace the following lines:
- SSLCertificateChainFile
- SSLCertificateKeyFile
- SSLCertificateFile
I use this command to get a list of all sites in /etc/apache2 where the pattern "SSLCertificate" exists.
- name: Apache 2.2 list sites files and store it in register
command: grep -lR --exclude default-ssl "SSLCertificate" /etc/apache2/
register: apache22_sites
This is what I use, when only one file has to be changed:
- name: apache2.2.* | configure certs
lineinfile: dest=/path/to/... regexp={{ item.regexp }} line={{ item.line}} backrefs=yes
with_items:
- { regexp: "SSLCertificateChainFile", line: " SSLCertificateChainFile = ..." }
- { regexp: "SSLCertificateKeyFile ", line: " SSLCertificateKeyFile = ..." }
- { regexp: "SSLCertificateFile", line: " SSLCertificateFile = ..."
notify: reload apache2
How can i tell ansible to use this code with multiple files listed in variable "apache22_sites" and multiples lines?
I found a good hint here, bad sadly only for one line.
I appreciate any tipps, tricks, hints :)
Greetings Dennis