# How can I pass extra variables to a shell script in my playbooks

**URL:** <https://forum.ansible.com/t/how-can-i-pass-extra-variables-to-a-shell-script-in-my-playbooks/29652>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [February 11, 2019, 4:24pm UTC](https://forum.ansible.com/t/how-can-i-pass-extra-variables-to-a-shell-script-in-my-playbooks/29652 "2019-02-11T16:24:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Conor\_Proud](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Conor\_Proud](https://forum.ansible.com/u/Conor_Proud)\
**Post date:** [February 11, 2019, 4:24pm UTC](https://forum.ansible.com/t/how-can-i-pass-extra-variables-to-a-shell-script-in-my-playbooks/29652/1 "2019-02-11T16:24:29Z")

</div>

Hi,  
This looks like the right place for posting questions- but please point me in the right direction if not.  
I’m using the “extra variables” box on the awx web front-end to provide key-value pairs to a shell script in my playbook. The problem I’m having is how I can use those variables in my shell script, as they all appear as {u’key’: u’value’} when I print them from within my shell script. This means that they don’t conform to the standard JSON format (which uses double-quotes) and also as these are unicode strings I’m having other issues trying to pull out the information I want. What I would like is to easily put these key-value pairs into an associative array so I can access the values when they’re required. Is there a good way to do this? At the moment I’m having to use sed to substitute out the bits I don’t want (the single quotes have to be converted to double quotes and I have to remove the “u” character and then pass this to a package called jq to read the string as a JSON object). This feels like the wrong approach, so I’m look for some advice or examples of whether this can be done more elegantly?

---

<div class="post-metadata">

**Author:** ![JonTheNiceGuy](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jontheniceguy/32/2267_2.png) [@JonTheNiceGuy](https://forum.ansible.com/u/JonTheNiceGuy)\
**Post date:** [February 11, 2019, 8:37pm UTC](https://forum.ansible.com/t/how-can-i-pass-extra-variables-to-a-shell-script-in-my-playbooks/29652/2 "2019-02-11T20:37:53Z")

</div>

Hi Conor, sounds like you’re probably doing this (untested pseudocode):

- shell: “/path/to/script {{ var }}”  
vars:  
var:  
some\_key: some\_data

Instead, you need to do something like this (untested pseudocode):

- shell: “/path/to/script {% for item in var|dict2items %}{{ item.key }}={{ item.value }}{% endfor %}”  
vars:  
var:  
some\_key: some\_data

If not, if you can post some example script, that might help…

All the best,
