I’m using this snippet in several playbooks, selecting a few specific files from a very large set of templates. This particular one is ssh keys, but it’s not the only example.
- name: enable key-based ssh access for ansible user
authorized_key: user=ansible key='$FILE(./credentials/ssh_keys/{{item}})'
with_items:
- ansible_20130625.pub
- admin_20121025.pub
Obviously this returns a deprecation currently (below) and I’m not sure how best to replace it.
The most obvious solution “{{ lookup(‘file’, ‘./credentials/ssh_keys/’ + {{item}}) }}” and variants
I’ve tried all fail with quoting issues.
Any suggestions?
A+
Dave
TASK: [enable key-based ssh access for ansible user] **************************
[DEPRECATION WARNING]: Legacy variable substitution, such as using ${foo} or
$foo instead of {{ foo }} is currently valid but will be phased out and has
been out of favor since version 1.2. This is the last of legacy features on our
deprecation list. You may continue to use this if you have specific needs for
now. This feature will be removed in version 1.6. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.