# Need assistance

**URL:** <https://forum.ansible.com/t/need-assistance/38507>\
**Category:** Ansible Developer\
**Created:** [October 10, 2023, 11:33am UTC](https://forum.ansible.com/t/need-assistance/38507 "2023-10-10T11:33:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Y.G\_Kumar](https://avatars.discourse-cdn.com/v4/letter/y/8e8cbc/32.png) [@Y.G\_Kumar](https://forum.ansible.com/u/Y.G_Kumar)\
**Post date:** [October 10, 2023, 11:33am UTC](https://forum.ansible.com/t/need-assistance/38507/1 "2023-10-10T11:33:29Z")

</div>

Hi All,

I want to refer user defined ansible variables inside a shell script. Can anyone help me how to accomplish this ? For example, for the below code:

---

<div class="post-metadata">

**Author:** ![Avinash\_Jadhav](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Avinash\_Jadhav](https://forum.ansible.com/u/Avinash_Jadhav)\
**Post date:** [October 10, 2023, 11:38am UTC](https://forum.ansible.com/t/need-assistance/38507/2 "2023-10-10T11:38:06Z")

</div>

You can try

Yaml

- name: Execute the script with variables  
ansible.builtin.command: bash /tmp/test.sh  
vars:  
script\_var1: “{{ ansible\_var1 }}”  
script\_var2: “{{ ansible\_var2 }}”

Shell script

#!/bin/bash

echo “Script variable 1: $script\_var1”  
echo “Script variable 2: $script\_var2”

---

<div class="post-metadata">

**Author:** ![Y.G\_Kumar](https://avatars.discourse-cdn.com/v4/letter/y/8e8cbc/32.png) [@Y.G\_Kumar](https://forum.ansible.com/u/Y.G_Kumar)\
**Post date:** [October 10, 2023, 2:51pm UTC](https://forum.ansible.com/t/need-assistance/38507/3 "2023-10-10T14:51:57Z")

</div>

I am trying this:

---

<div class="post-metadata">

**Author:** ![Jonathan\_Kamens](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@Jonathan\_Kamens](https://forum.ansible.com/u/Jonathan_Kamens)\
**Post date:** [October 10, 2023, 3:06pm UTC](https://forum.ansible.com/t/need-assistance/38507/4 "2023-10-10T15:06:22Z")

</div>

1. This is the second message you have sent to this list asking for help with using Ansible when that’s not what this list is for, after I (and perhaps others) emailed you privately and politely pointed out you were on the wrong list and pointed you at the correct forums for Ansible usage questions. Please respect the members of this list and do not continue to seek Ansible usage help here.

2. The previous answer you were given is not correct. Please see [https://docs.ansible.com/ansible/latest/playbook\_guide/playbooks\_environment.html](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_environment.html).
