# Grabbing data from a pool...

**URL:** <https://forum.ansible.com/t/grabbing-data-from-a-pool/12207>\
**Category:** Ansible Project\
**Created:** [January 17, 2013, 2:42pm UTC](https://forum.ansible.com/t/grabbing-data-from-a-pool/12207 "2013-01-17T14:42:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nigel\_Metheringham](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nigel\_Metheringham](https://forum.ansible.com/u/Nigel_Metheringham)\
**Post date:** [January 17, 2013, 2:42pm UTC](https://forum.ansible.com/t/grabbing-data-from-a-pool/12207/1 "2013-01-17T14:42:41Z")

</div>

I've put together a module, and would like to get some feedback on whether the idea is hated or usable - ie should I put it together as a pull request for the main development or not...

The idea is that sometimes you need to grab some data from a pool of data items - think of something like root passwords if you have a unique root password per machine policy, or software licenses, or ...

pooldata takes data in from json files. One parameter is the name of the file for this host/group/whatever (so you use a variable to make it appropriately unique). If that file exists then it is read and added to the current facts. If the file does not exist then a file from a pool directory is renamed into place and that file's contents returned.

Reactions?

[Database - why - I have a filesystem!]

&nbsp;&nbsp;Nigel.

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [January 17, 2013, 2:52pm UTC](https://forum.ansible.com/t/grabbing-data-from-a-pool/12207/2 "2013-01-17T14:52:35Z")

</div>

Nigel,

> pooldata takes data in from json files. One parameter is the name  
> of the file for this host/group/whatever (so you use a variable to  
> make it appropriately unique). If that file exists then it is read  
> and added to the current facts.

Sounds to me a bit like group\_vars. What's the difference? Can you show  
an example?

> If the file does not exist then a  
> file from a pool directory is renamed into place and that file's  
> contents returned.

... as in returning defaults? If so, why would that file be renamed in  
place. I dread the thought of having to enable that on some crazy  
read-only file system...

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

---

<div class="post-metadata">

**Author:** ![Nigel\_Metheringham](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nigel\_Metheringham](https://forum.ansible.com/u/Nigel_Metheringham)\
**Post date:** [January 17, 2013, 3:22pm UTC](https://forum.ansible.com/t/grabbing-data-from-a-pool/12207/3 "2013-01-17T15:22:47Z")

</div>

Jan-Piet Mens wrote:

> Nigel,
> 
> > pooldata takes data in from json files. One parameter is the name  
> > of the file for this host/group/whatever (so you use a variable to  
> > make it appropriately unique). If that file exists then it is read  
> > and added to the current facts.
> 
> Sounds to me a bit like group\_vars. What's the difference? Can you show  
> an example?

in that case its not much different, but...

> > If the file does not exist then a  
> > file from a pool directory is renamed into place and that file's  
> > contents returned.
> 
> ... as in returning defaults? If so, why would that file be renamed in  
> place. I dread the thought of having to enable that on some crazy  
> read-only file system...

OK, a fictional use case. Each node used within a service needs a service IP. You have a pool (directory) of service IPs, one per json file.

&nbsp;&nbsp;&nbsp;- name: Allocate a service IP  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;action:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pooldata  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data\_file=pools/service\_ip/alloc/${ansible\_fqdn}.json  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pool\_directory=pools/service\_ip/pool

First time you use this with a machine it grabs a new service IP record, removing it from the pool. Subsequent times it reuses the same record it was given the first time round.

There are ways I could implement this without the rename (although would need permanent storage), but they are likely to involve more grovelling through the directory structure...

&nbsp;&nbsp;Nigel.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [January 17, 2013, 3:34pm UTC](https://forum.ansible.com/t/grabbing-data-from-a-pool/12207/4 "2013-01-17T15:34:47Z")

</div>

If you want to write a custom fact module or something or a custom  
module that's totally fine and welcome, I think this is too  
off-the-beaten-track for core.

---

<div class="post-metadata">

**Author:** ![Nigel\_Metheringham](https://avatars.discourse-cdn.com/v4/letter/n/3ec8ea/32.png) [@Nigel\_Metheringham](https://forum.ansible.com/u/Nigel_Metheringham)\
**Post date:** [January 17, 2013, 4:58pm UTC](https://forum.ansible.com/t/grabbing-data-from-a-pool/12207/5 "2013-01-17T16:58:46Z")

</div>

Michael DeHaan wrote:

> If you want to write a custom fact module or something or a custom  
> module that's totally fine and welcome, I think this is too  
> off-the-beaten-track for core.

Thats fine - I suspected it might suffer from a limited requirement.

I currently have some prototyping of what I described. I may in future look at using a database rather than a filesystem, but in any case I can easily run it locally without it needing to go into the mainline

&nbsp;&nbsp;Nigel.
