# want to pass output of external shell script as variable to ansible task

**URL:** <https://forum.ansible.com/t/want-to-pass-output-of-external-shell-script-as-variable-to-ansible-task/36105>\
**Category:** Ansible Project\
**Created:** [December 13, 2021, 7:03am UTC](https://forum.ansible.com/t/want-to-pass-output-of-external-shell-script-as-variable-to-ansible-task/36105 "2021-12-13T07:03:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![devopstrainer1](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@devopstrainer1](https://forum.ansible.com/u/devopstrainer1)\
**Post date:** [December 13, 2021, 7:03am UTC](https://forum.ansible.com/t/want-to-pass-output-of-external-shell-script-as-variable-to-ansible-task/36105/1 "2021-12-13T07:03:15Z")

</div>

_I have a scenario where i have a shell script running externally which at every execution generates dynamic value(can’t add it as ansible task since it is not being executed on any inventory host), i want to use output of this shell script as variable in my current ansible playbook._

_Any help on this will be highly appreciated_

---

<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:** [December 13, 2021, 8:23am UTC](https://forum.ansible.com/t/want-to-pass-output-of-external-shell-script-as-variable-to-ansible-task/36105/2 "2021-12-13T08:23:05Z")

</div>

How does this mysterious "output" reach you normally (without ansible)?

---

<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:** [December 13, 2021, 8:56am UTC](https://forum.ansible.com/t/want-to-pass-output-of-external-shell-script-as-variable-to-ansible-task/36105/3 "2021-12-13T08:56:38Z")

</div>

(replying to the list as you've (hopefully accidentally) sent me a  
private message)

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [December 13, 2021, 12:40pm UTC](https://forum.ansible.com/t/want-to-pass-output-of-external-shell-script-as-variable-to-ansible-task/36105/4 "2021-12-13T12:40:42Z")

</div>

You certainly can add it as an Ansible task even though it runs on a host not in your inventory.  
Read up on [delegate\_to](https://docs.ansible.com/ansible/latest/user_guide/playbooks_delegation.html).
