# Var substitution help

**URL:** <https://forum.ansible.com/t/var-substitution-help/23491>\
**Category:** Ansible Project\
**Created:** [January 18, 2017, 2:12pm UTC](https://forum.ansible.com/t/var-substitution-help/23491 "2017-01-18T14:12:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [January 18, 2017, 2:12pm UTC](https://forum.ansible.com/t/var-substitution-help/23491/1 "2017-01-18T14:12:26Z")

</div>

Hello, all.

A while ago, I created a quck-'n-dirty user creation playbook. With the following line, I was able to both create the user, and his/her encrypted password (for CentOS 6/7):

user: name=“someuser” password={{ ‘somepassword’|password\_hash(‘sha512’, ‘mSFRM"N4’) }} state=present

Now, I want to user “user” and password" vars in the play, rather than have to add them in the line above. Here’s what I’ve come up with:

vars:  
user: someuser  
password: somepassword

tasks:

- name: create user in Centos 6  
user: name={{ user }} password={{ ‘{{ password }}’|password\_hash(‘sha512’, ‘ies8Aech’) }} state=present

With the above, while the user is created, the password doesn’t work. Help would be appreciated.

Dimitri

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 18, 2017, 2:43pm UTC](https://forum.ansible.com/t/var-substitution-help/23491/2 "2017-01-18T14:43:37Z")

</div>

You can't use template in a template, loose the inner {{ }} lik so.  
&nbsp;&nbsp;&nbsp;user: name={{ user }} password={{ password | password\_hash('sha512', 'ies8Aech') }} state=present

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [January 18, 2017, 3:35pm UTC](https://forum.ansible.com/t/var-substitution-help/23491/3 "2017-01-18T15:35:17Z")

</div>

Thank you, Kai! Works fine now.
