# local\_action and mysql\_db doesn't work together

**URL:** <https://forum.ansible.com/t/local-action-and-mysql-db-doesnt-work-together/13567>\
**Category:** Ansible Project\
**Created:** [September 27, 2013, 2:03pm UTC](https://forum.ansible.com/t/local-action-and-mysql-db-doesnt-work-together/13567 "2013-09-27T14:03:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [September 27, 2013, 2:03pm UTC](https://forum.ansible.com/t/local-action-and-mysql-db-doesnt-work-together/13567/1 "2013-09-27T14:03:53Z")

</div>

I want to make sure that a database in mysql does exist and when using the following two actions:

- name: “Ensure remote database”  
mysql\_db: login\_host=‘127.0.0.1’  
name=‘{{ migrate\_db\_remote }}’  
state=‘present’

- name: “Ensure local database”  
local\_action: module=mysql\_db  
login\_host=‘127.0.0.1’  
name=‘{{ migrate\_db\_remote }}’  
state=‘present’

the first one does work and the second one throws the following error:

fatal: [host] =\> module module=mysql\_db not found in /usr/share/ansible/inventory:/usr/share/ansible/packaging:/usr/share/ansible/database:/usr/share/ansible/monitoring:/usr/share/ansible/commands:/usr/share/ansible/files:/usr/share/ansible/net\_infrastructure:/usr/share/ansible/utilities:/usr/share/ansible/network:/usr/share/ansible/internal:/usr/share/ansible/source\_control:/usr/share/ansible/web\_infrastructure:/usr/share/ansible/system:/usr/share/ansible/messaging:/usr/share/ansible/cloud:/usr/share/ansible/notification:/usr/share/ansible

I checked, the python-mysqldb package is installed on both the local and the remote host. So I’m not sure what’s causing this issue. Any help much appreciated.

---

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [September 27, 2013, 2:09pm UTC](https://forum.ansible.com/t/local-action-and-mysql-db-doesnt-work-together/13567/2 "2013-09-27T14:09:00Z")

</div>

Found it. The correct notation for the local\_action would be like this:

- name: “Ensure local database”  
local\_action: mysql\_db  
login\_host=‘127.0.0.1’  
name=‘{{ migrate\_db\_remote }}’  
state=‘present’

What’s changed? The “module=” is stripped out.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 27, 2013, 2:42pm UTC](https://forum.ansible.com/t/local-action-and-mysql-db-doesnt-work-together/13567/3 "2013-09-27T14:42:02Z")

</div>

This is cleaner:

- name: “Ensure local database exists”  
local\_action: mysql\_db login\_host=127.0.0.1 name=‘{{ migrate\_db\_remote }}’ state=present

Don’t need the module= or a lot of the quotes.
