# creating my own dynamic vars module

**URL:** <https://forum.ansible.com/t/creating-my-own-dynamic-vars-module/24169>\
**Category:** Ansible Project\
**Created:** [April 7, 2017, 12:51pm UTC](https://forum.ansible.com/t/creating-my-own-dynamic-vars-module/24169 "2017-04-07T12:51:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Graham](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Matt\_Graham](https://forum.ansible.com/u/Matt_Graham)\
**Post date:** [April 7, 2017, 12:51pm UTC](https://forum.ansible.com/t/creating-my-own-dynamic-vars-module/24169/1 "2017-04-07T12:51:50Z")

</div>

Hi All

Im probably doing this wrong. I’m working on a version of include\_vars module where by my variables (based off a text file) get added to the global vars like include\_vars

Im trying to figure out how I add it. I can see when I use include\_vars, that gets added to the global vars

I checked that by doing

- debug:  
var: vars

and it showed all the run time vars.

Hell, I can’t seem to find the include\_var module to see how its done. Ive tried this variable manager class but I must be doing it all wrong

Thanks for any help

Regards

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 7, 2017, 6:45pm UTC](https://forum.ansible.com/t/creating-my-own-dynamic-vars-module/24169/2 "2017-04-07T18:45:03Z")

</div>

I suspect include\_vars is an action plugin, as it is the sort of thing that only runs on the controller, so isn’t a module (which is typically delivered to the machines you are managing and run remotely).

However, I’m wondering if the simplest thing to do is just to wrap ansible-playbook in your own script that just adds the vars from a file to the ansible playbook as a -e @/path/to/some/yaml/or/json/file

I guess you might need to load different vars files for different playbooks or something, but just wondering if doing the simples thing might be enough.

What is your goal? What problem are you trying to solve. There might be a way to solve it without resorting to adding your own custom code on top of ansible?

Jon

---

<div class="post-metadata">

**Author:** ![Matt\_Graham](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@Matt\_Graham](https://forum.ansible.com/u/Matt_Graham)\
**Post date:** [April 8, 2017, 3:49am UTC](https://forum.ansible.com/t/creating-my-own-dynamic-vars-module/24169/3 "2017-04-08T03:49:51Z")

</div>

Thanks J

Thats not a bad idea. It was more of a mini project i was testing my python/ansible skills on but its also because at the new place Im working at, they also use the Output from Cloud-formation templates as variables that are then upload into for Bamboo to use. Bamboo tends to use the format of

VPC=vpc-35627  
AWS\_REGION=us-east-1

My code was going to work something like this

inlcude\_cfn\_vars:  
stack: name-of-my-stack  
stack\_prefix:  
regex:

This would add it into the play list instead of having to use a wrapper. I also allowed it to work with S3 bucket. So, when bamboo uploaded a VARS file to the S3 buck, you have to sometimes pull that back down and inject back into Bamboo etc. where I wanted to see if my plugin could do that.

I just thought there was a function or something to add my vars to the play like include\_vars does.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [April 10, 2017, 7:00am UTC](https://forum.ansible.com/t/creating-my-own-dynamic-vars-module/24169/4 "2017-04-10T07:00:15Z")

</div>

Sounds like maybe an ini-file lookup might be able to get what you want?

[http://docs.ansible.com/ansible/playbooks\_lookups.html#the-ini-file-lookup](http://docs.ansible.com/ansible/playbooks_lookups.html#the-ini-file-lookup)

Lookups run on the controller so that might be a hindrance depending on where bamboo and ansible are running, but I guess you could allways use ‘fetch’ to retrieve the file you want to use back onto the controller.

Hope this helps,

Jon
