# Passing json in shell module in ansible

**URL:** <https://forum.ansible.com/t/passing-json-in-shell-module-in-ansible/36363>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 23, 2022, 5:32pm UTC](https://forum.ansible.com/t/passing-json-in-shell-module-in-ansible/36363 "2022-02-23T17:32:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 23, 2022, 5:32pm UTC](https://forum.ansible.com/t/passing-json-in-shell-module-in-ansible/36363/1 "2022-02-23T17:32:25Z")

</div>

Can you confirm that the exact same command (without single quotes around it) actually works from an interactive shell?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 24, 2022, 8:08am UTC](https://forum.ansible.com/t/passing-json-in-shell-module-in-ansible/36363/2 "2022-02-24T08:08:02Z")

</div>

I would supply it as a yaml formatted variable to your task and then use the filter combo to\_json|quote

At least that’s how I supply crazy complex dicts on aws cli commands and those work

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [March 16, 2022, 10:13pm UTC](https://forum.ansible.com/t/passing-json-in-shell-module-in-ansible/36363/3 "2022-03-16T22:13:23Z")

</div>

easiest way:

shell: !unsafe aws autoscaling start-instance-refresh  
--auto-scaling-group-name Test\_Iwo\_nodes\_Development\_zone1  
--preferences '{"InstanceWarmup": 400, "MinHealthyPercentage": 50}'

but breaking it down into variables is still a good idea, you only  
need `!unsafe` on the 'dictionary looking' parts.
