I want to connect to mysql through ansible-playbook and execute SQL statements, but there is no relevant module in the official website of ansible. Does anyone know how to operate
Asked
Active
Viewed 535 times
1 Answers
0
When there does not exist an official module to do something, you basically have two choices:
- Find a custom module that someone has written that will do it (such as this one).
- Write a custom module that will do it.
- Do it using the
command
module or any of the other arbitrary command modules.
In your case, for a one-off playbook, I would typically go with the third option as I don't much care for running custom modules. I would make sure (Via Ansible of course) that mysql
was installed on the box you were running against, and build a mysql
command line string based on what you need to do which you then run on a host with access to the DB server (or the DB server itself). That's the quickest and dirtiest method.

baggagescreen
- 126
- 3