# deprecated vars - nested lookup in authorized\_key

**URL:** <https://forum.ansible.com/t/deprecated-vars-nested-lookup-in-authorized-key/14179>\
**Category:** Ansible Project\
**Created:** [December 19, 2013, 12:30pm UTC](https://forum.ansible.com/t/deprecated-vars-nested-lookup-in-authorized-key/14179 "2013-12-19T12:30:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Cottlehuber](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Dave\_Cottlehuber](https://forum.ansible.com/u/Dave_Cottlehuber)\
**Post date:** [December 19, 2013, 12:30pm UTC](https://forum.ansible.com/t/deprecated-vars-nested-lookup-in-authorized-key/14179/1 "2013-12-19T12:30:44Z")

</div>

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.

```yaml
- 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.

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [December 19, 2013, 3:55pm UTC](https://forum.ansible.com/t/deprecated-vars-nested-lookup-in-authorized-key/14179/2 "2013-12-19T15:55:29Z")

</div>

Remove the {{}} around the inner "item". I have some examples in:

[https://github.com/jctanner/ansible-tests/blob/master/authorized\_key/misc-types.yml](https://github.com/jctanner/ansible-tests/blob/master/authorized_key/misc-types.yml)

key="{{ lookup('file', '/tmp/genkeys/' + item + '.pub') }}"

---

<div class="post-metadata">

**Author:** ![Dave\_Cottlehuber](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Dave\_Cottlehuber](https://forum.ansible.com/u/Dave_Cottlehuber)\
**Post date:** [December 24, 2013, 1:48pm UTC](https://forum.ansible.com/t/deprecated-vars-nested-lookup-in-authorized-key/14179/3 "2013-12-24T13:48:08Z")

</div>

perfect - thanks James!
