I cannot find a way to much a literal (a dot) in Ansible's regex_replace filter. Here is the task:
- name: Display database name
debug:
msg: "{{ vhost | regex_replace('(.+\.)(.+)$', \\1) }}"
tags: [debug]
My intention is to match and replace the whole URL like test.staging.domain.com with its first part (test in the example).
Ansible would report the following error:
debug:
msg: "{{ vhost | regex_replace('(.+\.)(.+)$', \\1) }}"
^ here
We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value.
How can I match literals in Ansible regexp_replace
filter?