Ok, so since you are doing “{{” this means you are already using Ansible 1.2.
It is therefore much easier to just use all of the 1.2 syntax and stop using the old “$foo”.
This would make your example like this:
- name: add authorized key for user
action: authorized_key user={{ item.user_name }} key=“{{ lookup(‘file’, item.pub_key) }}”
with_items: users
I’m hoping that works for you. Let me know if not and I can help test further.