# Help In Refactoring Soon-To-Be-Depreciated Statment

**URL:** <https://forum.ansible.com/t/help-in-refactoring-soon-to-be-depreciated-statment/44315>\
**Category:** Get Help\
**Created:** [August 18, 2025, 11:26am UTC](https://forum.ansible.com/t/help-in-refactoring-soon-to-be-depreciated-statment/44315 "2025-08-18T11:26:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dulux-Oz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulux-oz/32/9047_2.png) [@Dulux-Oz](https://forum.ansible.com/u/Dulux-Oz)\
**Post date:** [August 18, 2025, 11:26am UTC](https://forum.ansible.com/t/help-in-refactoring-soon-to-be-depreciated-statment/44315/1 "2025-08-18T11:26:59Z")

</div>

Hi All,

Could someone please give me a hand in refactoring the below task as I’m getting the below warning message, and I can’t figure this out (and the provide (simplified) example doesn’t really help (me - brain went “duuurrr”)) 🙂

The task:

```auto
- name: Install User Public Key
  ansible.posix.authorized_key:
     exclusive: true
     key: "{{lookup('file','public_keys/{{ USER_NAME }}_ssh_key.public')}}"

```

The warning:

```auto
[WARNING]: Jinja constant strings should not contain embedded templates. This feature will be disabled by default in ansible-core 2.23.

Use inline expressions, for example: `msg: "{{ lookup('env', '{{ a_var }}') }}"` becomes `msg:"{{ lookup('env', a_var) }}"`

```

Can you, for example, use the below, because if so then that (to me) is _really_ un-intuitive?

```auto
key: "{{lookup('file','public_keys/USER_NAME_ssh_key.public')}}"

```

Thank you in advance

Cheers  
Dulux-Oz

---

<div class="post-metadata">

**Author:** ![mkrizek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mkrizek/32/2055_2.png) [@mkrizek](https://forum.ansible.com/u/mkrizek)\
**Post date:** [August 18, 2025, 12:26pm UTC](https://forum.ansible.com/t/help-in-refactoring-soon-to-be-depreciated-statment/44315/2 "2025-08-18T12:26:13Z")

</div>

Using `~` to concatenate strings should work:

```auto
- name: Install User Public Key
  ansible.posix.authorized_key:
    exclusive: true
    key: "{{ lookup('file', 'public_keys/' ~ USER_NAME ~ '_ssh_key.public') }}"

```

See [Template Designer Documentation — Jinja Documentation (3.1.x)](https://jinja.palletsprojects.com/en/stable/templates/#other-operators)

---

<div class="post-metadata">

**Author:** ![Dulux-Oz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulux-oz/32/9047_2.png) [@Dulux-Oz](https://forum.ansible.com/u/Dulux-Oz)\
**Post date:** [August 18, 2025, 12:58pm UTC](https://forum.ansible.com/t/help-in-refactoring-soon-to-be-depreciated-statment/44315/3 "2025-08-18T12:58:07Z")

</div>

Thank you @mkrizek , I’ll give that a try

Cheers
