Michael,
My version of ansible is -master (currently 1.4). I realized it wasn't substituting by testing with and without the variable. So for instance;
[ group_vars/lab.yml ]
---
ansible_ssh_private_key_file: "/keys/path/lab-server+root.key"
[application.yml]
---
- name: "prepare application {{ namespace }}"
hosts: "lab"
remote_user: "root"
Will *work* (e.g. the play connects to host(s) in the lab group && runs tasks remotely).
If I keep the same playbook with remote_user defined as "root", and use the remote_user variable in the inventory file as:
[ group_vars/lab.yml ]
---
ansible_ssh_private_key_file: "/keys/path/lab-server+{{ remote_user }}.key"
It will fail to connect w/ an ssh error.
OF NOTE: If testing ansible_ssh_private_key I recommend testing variable
substitution first; and/or test against a different host each time. Tthe ssh connection key was seemingly cached per host; so if you test with the hardcoded key file first, and it works, and then later change to using a variable; it may still work.
My workaround is to always connect as the root user for application deployment/preparation, and then pass sudo: yes, sudo_user: <restricted_application_user> to included *deployment* tasks. This encouraged the use of tags [prepare, deploy] and a single application playbook file, which feels more "ansibley". Now I hope my other team members find it understandable! :)
~ Brice