Template value pairs vs. in-playbook value pairs difference

I have this inconsistency when I declare variable pairs used in a template vs. variable pairs used directly in a playbook e.g:

Works in a template:group_vars/all
fusemq_users:

  • { ‘username’: ‘admin’, ‘password’: ‘admin’, ‘role’ : ‘admin’ }

role_name/templates/users.properties
{% for line in fusemq_users %}
{{ line.username }}={{ line.password }},{{ line.role }}
{% endfor %}

The same format, used in a play book does not work - e.g. below is not working:

fusemq_activemq_jmx:

  • { ‘username’ : ‘admin’, ‘password’ : ‘admin1234’ }

  • name: set activemq.jmx.user
    lineinfile: dest={{ fusemq_home }}/etc/system.properties regexp=“^#activemq.jmx.user” line=“#activemq.jmx.user={{ fusemq_activemq_jmx.username }}”

If I remove the preceding dash, it works, e.g.
{ ‘username’ : ‘admin’, ‘password’ : ‘admin1234’ }

Is this expected?

In one, you have fusemq_users as a list, in the other, you have a hash.

If you are going to feed it a list, perhaps you want to use with_items, or otherwise, perhaps you want to reference the first element in the list.