template not expanding on Ubuntu 12.04 target host

Why would the following template not expand (instead it is copied verbatim) on an Ubuntu 12.04 host, while it expands alright on a similar 16.04 host? Client is ansible 2.3.1.0.

`

cat templates/etc/security/access.conf.j2

{{ ansible_managed }}

{% for current_scope in access_scope %}
{% for scope_current_content in access_scope_types[current_scope] %}
{{scope_current_content}}
{% endfor %}
{% endfor %}
-:ALL:ALL
`

The corresponding action is:

`

  • name: Restrict access through pam
    action: template src=etc/security/access.conf.j2 dest=/etc/security/access.conf mode=0644
    tags:
  • access
  • restrict
    `

There is no error message, nor anything enlightening when I add -vvv.

I know I already posted when I had a very similar problem before, but I do not see the connection, as last time the issue was when moving the client to another Ubuntu version. This time only the template changed.

Thanks,
Sebastian

Turns out I was stupid and forget to change a host variable (“access_scope”) from a plain string to a list of strings. Is there a recommended way to check in a template that a variable is not only set but has the right type?