I have the following task in one of my roles:
- name: Moodle--{{ moodle_domain }}--Apache--Virtual Host--Configuration-- Copy
become: yes
loop:
- src: ../templates/moodle.test.conf.j2
dest: /etc/apache2/sites-enabled/{{ moodle_domain }}.conf
- src: ../templates/moodle.test-ssl.conf.j2
dest: /etc/apache2/sites-enabled/{{ moodle_domain }}-ssl.conf
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: u+rw,g+r,o+r
notify: Apache--Service-- Restart
One of the templates used above, look like this:
<VirtualHost *:80>
ServerName {{ moodle_domain }}
Redirect permanent / https://{{ moodle_domain }}/
</VirtualHost>
I know the moodle_domain
variable is passed to the loop, because I can see that the file names on the target host are correct.
But it is not passed to the template. I know this, because on the target host, the files still contain {{ moodle_domain }}
instead of the actual domain.
What am I doing wrong?