# Using hostvars to smuggle values into play context is not recommended

**URL:** <https://forum.ansible.com/t/using-hostvars-to-smuggle-values-into-play-context-is-not-recommended/30806>\
**Category:** Ansible Project\
**Created:** [July 18, 2019, 10:27am UTC](https://forum.ansible.com/t/using-hostvars-to-smuggle-values-into-play-context-is-not-recommended/30806 "2019-07-18T10:27:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minimus\_Geekus](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Minimus\_Geekus](https://forum.ansible.com/u/Minimus_Geekus)\
**Post date:** [July 18, 2019, 10:27am UTC](https://forum.ansible.com/t/using-hostvars-to-smuggle-values-into-play-context-is-not-recommended/30806/1 "2019-07-18T10:27:32Z")

</div>

Hi all,  
I have experienced exactly the same issue as reported in these two:

[https://github.com/ansible/ansible/issues/31407](https://github.com/ansible/ansible/issues/31407)

[https://github.com/ansible/ansible/issues/36575](https://github.com/ansible/ansible/issues/36575)

In summary something like this…

- hosts: “{{ hostvars[‘localhost’][‘server\_entry\_from\_cmdb\_lookup’] }}”

…actually runs OK, but fails the linter (and therefore our pipeline)

‘Using hostvars to smuggle values into play context is not recommended’ - this was the last entry from [Matt Martz](https://github.com/sivel)

Can somebody please explain to me then how one _should_ consume a variable containing a target host that has been gleaned from another play (i.e. a data access play to query a CMDB?)

The only option I have been able to consider is a '- hosts: all followed by delegate\_to: “{{ my\_target\_server }}” on each task - my play has \> 30 tasks and placing a delegate\_to an all seems a bit clunky to say the least.

Can somebody please advise?

Thanks in advance…
