# Exposing variables from connection plugin

**URL:** <https://forum.ansible.com/t/exposing-variables-from-connection-plugin/30975>\
**Category:** Ansible Project\
**Created:** [August 7, 2019, 12:20pm UTC](https://forum.ansible.com/t/exposing-variables-from-connection-plugin/30975 "2019-08-07T12:20:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_A\_S](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@Juan\_A\_S](https://forum.ansible.com/u/Juan_A_S)\
**Post date:** [August 7, 2019, 12:20pm UTC](https://forum.ansible.com/t/exposing-variables-from-connection-plugin/30975/1 "2019-08-07T12:20:46Z")

</div>

Hello all

I have modified the psrp plugin, so when connecting, it also stablishes an SSH connection with a SOCKS proxy in a random port, so psrp connection is stablished using that SOCKS proxy. As this is a random number, I want to use that value, the SOCKS port number later, in the tasks, to make some tasks use that proxy. How can I “publish” a variable from the connection plugin, so it is accesible from the tasks?

Thanks!

---

<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:** [August 7, 2019, 2:41pm UTC](https://forum.ansible.com/t/exposing-variables-from-connection-plugin/30975/2 "2019-08-07T14:41:23Z")

</div>

Currently, there is no set way for connection plugins to return  
variables, I have been thinking this would be a needed feature. There  
are probably a few hacky ways of doing it, but i dont recommend that  
approach as those are not guaranteed to continue working.

---

<div class="post-metadata">

**Author:** ![Juan\_A\_S](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@Juan\_A\_S](https://forum.ansible.com/u/Juan_A_S)\
**Post date:** [August 7, 2019, 3:44pm UTC](https://forum.ansible.com/t/exposing-variables-from-connection-plugin/30975/3 "2019-08-07T15:44:42Z")

</div>

Thanks Brian, could you share those hacks? Would it be enough to set an environment variable (at least for delegate\_to localhost tasks)?
