# db module?

**URL:** <https://forum.ansible.com/t/db-module/11720>\
**Category:** Ansible Project\
**Created:** [July 25, 2012, 5:47am UTC](https://forum.ansible.com/t/db-module/11720 "2012-07-25T05:47:39Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [July 25, 2012, 5:47am UTC](https://forum.ansible.com/t/db-module/11720/1 "2012-07-25T05:47:39Z")

</div>

I'm thinking about creating a 'db' module for Ansible with the following  
synopsis:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;module name: db  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;args:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init=template.j2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest=dbname.ext  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type={anydbm|gdbm|bdb|dbm|cdb|csv|lsearch}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key=key  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value="whatever"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ensure={present|absent}

type: most of these should be self-explanatory. Lsearch is typical for  
Exim, for example, and is "key: value".

Thoughts?

Questions:

1. Michael added daisychaining \*out\* of a module into, say, 'file'  
&nbsp;&nbsp;&nbsp;module (see get\_url and/or assemble). Is there a way to daisychain  
&nbsp;&nbsp;&nbsp;\*from\* a module? I'd very much like to be able to INITIALIZE a  
&nbsp;&nbsp;&nbsp;database from a template on the ansible manager. (This can of course  
&nbsp;&nbsp;&nbsp;be completed in two steps: 1. copy template and 2. run db module) but  
&nbsp;&nbsp;&nbsp;doing it all in a single step seems cleaner.  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;Not vital, but nice to have: maybe Michael can think about this ... 🙂

2. Suggestions Python modules for DB-handling? There's anydbm, gdbm,  
&nbsp;&nbsp;&nbsp;etc. I'd like to be able to support as many types as possible without  
&nbsp;&nbsp;&nbsp;requiring installation on the nodes ... Any feedback welcome.

Regards,

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

---

<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:** [July 25, 2012, 12:04pm UTC](https://forum.ansible.com/t/db-module/11720/2 "2012-07-25T12:04:43Z")

</div>

> Questions:
> 
> 1. Michael added daisychaining \*out\* of a module into, say, 'file'  
> module (see get\_url and/or assemble). Is there a way to daisychain  
> \*from\* a module? I'd very much like to be able to INITIALIZE a  
> database from a template on the ansible manager. (This can of course  
> be completed in two steps: 1. copy template and 2. run db module) but  
> doing it all in a single step seems cleaner.

Nope, the daisy chain stuff was called that because it allows a module to decide what to call next, but you can't in Ansible call another module from another module. The daisy chaining is useful for saying "this module creates a file, and then the file module should be able to set attributes on it", and I don't see it really being used for anything other than file. (For end users, they should never need to know this exists)

I really don't want to add this either, because the changes would be rather intrusive to the core for what is hopefully a bit of an edge case.
