Published: 26.04.2021 | Edited: 09.05.2021 | Tags: 100daystooffload

Nginx on Arch using Ansible pt.3

See also part 1 and part 2.

Digging deeper after successfully made use of the template for the nginx.conf.j2 in the previous post I tried to utilize the virtual hosts template accessible in vhosts.j2 by copying the template and referencing it locally (the thing same I did with with the nginx.conf template mention above previously) like so:

  - template: "{{ playbook_dir }}/templates/vhost.j2"

This however it resulted in the following error when the playbook is run:

"msg": "AnsibleUndefinedVariable: 'nginx_listen_ipv6' is undefined"

At the same time I have stumbled upon this quite elaborate thread about ansible stating quite amusingly:


I always say the same thing, check out Geeelingguys github. Star and contribute to his repos

So, quite naturally, I did.

Reasons for a local template

I decided to copy and reference the local template again instead of using the upstream one for reasons, some of which are similar to ones I described in the previous post:

  • The vhost.j2 template appears to contain a bug that might not get patched upstream
  • It allows for easier customization, when the required variables are not exposed
  • Due some changes in ansible, documented template extending seems no longer supported

I felt like sticking to upstream was not even possible, so the custom local copy with minor customizations was chosen as a path of least resistance.

This is a 47th post of #100daystooffload.