# Variable in Ansible Role

**URL:** <https://forum.ansible.com/t/variable-in-ansible-role/31776>\
**Category:** Ansible Project\
**Created:** [December 6, 2019, 7:48am UTC](https://forum.ansible.com/t/variable-in-ansible-role/31776 "2019-12-06T07:48:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Rawat](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Rahul\_Rawat](https://forum.ansible.com/u/Rahul_Rawat)\
**Post date:** [December 6, 2019, 7:48am UTC](https://forum.ansible.com/t/variable-in-ansible-role/31776/1 "2019-12-06T07:48:18Z")

</div>

Hi,

I have to parse variable in static PowerShell script which will copy through win\_copy module on target machine.  
Means when file copy on target machine after running playbook it should have values of those variable.

I’ve keep variable in default like:  
user\_name: \*\*\*\*\*\*  
password: \*\*\*\*\*\*

and tasks/main.yml file:

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 6, 2019, 7:51am UTC](https://forum.ansible.com/t/variable-in-ansible-role/31776/2 "2019-12-06T07:51:47Z")

</div>

> Hi,
> 
> I have to parse variable in static PowerShell script which will copy through win\_copy module on target machine.  
> Means when file copy on target machine after running playbook it should have values of those variable.
> 
> I've keep variable in default like:  
> user\_name: \*\*\*\*\*\*  
> password: \*\*\*\*\*\*
> 
> and tasks/main.yml file:
> 
> ---  
> # tasks file for trust  
> - name: Copy a single file, but keep a backup  
> win\_copy:  
> src: templates/fixtrust.ps1.j2  
> dest: C:\fixtrust.ps1  
> backup: yes
> 
> - name: Run powershell script to resolve break trust  
> win\_shell: C:\fixtrust.ps1
> 
> and powershell file kept in files or template directory:
> 
> netdom resetpwd /Server:devqacloud.com /UserD:{{ user\_name }} /PasswordD:{{ password }}  
> nltest /sc\_verify:devqacloud.com  
> gpupdate /force
> 
> Please help me out if you have worked related to this,

Hello Rahul,

Why don't you use the template module instead of win\_copy?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Rahul\_Rawat](https://avatars.discourse-cdn.com/v4/letter/r/7feea3/32.png) [@Rahul\_Rawat](https://forum.ansible.com/u/Rahul_Rawat)\
**Post date:** [December 6, 2019, 8:02am UTC](https://forum.ansible.com/t/variable-in-ansible-role/31776/3 "2019-12-06T08:02:04Z")

</div>

Bingo!

Really appreciate your valuable response. It’s work for me.

Thanks,  
Rahul
