template not expanding on Ubuntu 12.04 target host

20 views
Skip to first unread message

seb....@gmail.com

unread,
Sep 6, 2017, 8:34:08 AM9/6/17
to Ansible Project
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

seb....@gmail.com

unread,
Sep 11, 2017, 9:26:29 AM9/11/17
to Ansible Project

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?
Reply all
Reply to author
Forward
0 new messages