Ansible playbook to create mysql user on remote host

1,429 views
Skip to first unread message

Trinh Nguyen

unread,
Aug 17, 2017, 12:09:20 PM8/17/17
to Open edX operations
Hi,

I'm working on a playbook that install and create user on a remote MySQL database for my Open edX instance. But, I couldn't find a correct variable to let Ansible create the mysql user for my stateless (edx apps only) instance accessing the db even though I've already set the mysql host is the app's ip address:

The playbook runs successfully but it only creates local user (e.g. edxapp001@'loclahost'...) which means that the user from the stateless server cannot access the database.

So now after I deploy the datastores server, I have to go in and add the needed users. I wonder if I'm using  the correct variables?

If you have any ideas, please let me know.

Many thanks,


Trinh Nguyen | Founder & CTO




LIubov Fomicheva

unread,
Aug 18, 2017, 6:31:35 AM8/18/17
to Open edX operations
Hello Trinh,

  I usually use created_db_and_users.yml playbook by edX to create new databases and users for new installations - instead of using edxlocal role. It uses additional yml-file with database_users variable (including values from your main configuration), you may set any user hosts you like (for testing purposes % is enough). The comment in that playbook describes the syntax.

Hope that helps,
  Liubov.

четверг, 17 августа 2017 г., 19:09:20 UTC+3 пользователь Trinh Nguyen написал:

Trinh Nguyen

unread,
Aug 18, 2017, 11:18:16 AM8/18/17
to Open edX operations
Thanks Liubov, I will try.

Trinh Nguyen | Founder & CTO




--
You received this message because you are subscribed to the Google Groups "Open edX operations" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openedx-ops/55330ed9-2d3c-4953-bf49-3aef9f14ca9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Trinh Nguyen

unread,
Aug 19, 2017, 5:33:48 AM8/19/17
to Open edX operations, liu...@lektorium.tv
Hello Liubov,

One quick question, how did you use this playbook along with the installation playbooks? Let's say I'm want to create the Open edx's databases and users when deploying a new open edx instance? If you can give me a general strategy that would be great

Many thanks,


Trinh Nguyen | Founder & CTO




LIubov Fomicheva

unread,
Aug 21, 2017, 6:07:06 AM8/21/17
to Open edX operations, liu...@lektorium.tv
Hello Trinh,

  First of all, we usually install databases and application on a separate server. So I have two main playbooks: one for the application server and one for the database server. For a new installation I:
- run playbook for the database server (it installs mysql, mongo, etc);
- run create_db_and_users.yml playbook (the same host in inventory);
- run playbook for the application server.
  After the provisioning of the application server, the system is ready for work (just create an admin superuser).
  I've tried this solution for small installations - no database clustering or replication: the database playbook included only edxapp_common, mysql and mongo roles.

  Liubov

суббота, 19 августа 2017 г., 12:33:48 UTC+3 пользователь Trinh Nguyen написал:
To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops...@googlegroups.com.

Trinh Nguyen

unread,
Aug 21, 2017, 10:32:33 AM8/21/17
to Open edX operations, liu...@lektorium.tv
Thanks Liubov. It's awesome!

Trinh Nguyen | Founder & CTO




To unsubscribe from this group and stop receiving emails from it, send an email to openedx-ops+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openedx-ops/6ab09145-492f-4fe5-a728-840b1b2809af%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages