MySQL variables module for ansible

I’ve created and another module for this besides the mysql_replication named mysql_variables.

The purpose of this module to get/set variables from running MySQL servers, and avoid to use shell module for this, because that is a bit frustrating, and there are long commands to run.

For example, when you wanna to set read_only mode via shell, you can do that like this:

ansible -m shell -a "mysql -e 'select @@read_only'" | success | rc=0 >>

[root@admin banyek]# ansible -m shell -a "mysql -e 'set global read_only=1'" | success | rc=0 >>

Not so neat, isn’t it, eh? And I have not spoken about the —user and —password variables, so this could be really annoying.

That’s why I made this module, because it is a bit easier to use (and I like to use own toolset with the same alike problems.) and it can be act as more ‘ansible like’ with ‘changed’ tags, and so on. Like this:

[root@admin banyek]# ansible -m mysql_variables -a "variable=read_only" | success >> {
    "changed": false,
    "msg": [

[root@admin banyek]# ansible -m mysql_variables -a "variable=read_only value=1" | success >> {
    "changed": true,
    "msg": "Variable change succeeded"


That’s it. Its simple like a hammer, and useful like a … yeah, like a hammer. 😀

So use it, hopefully it will be part of official ansible release (along with mysql_replication) but until that, you can download it from my GitHub. Just place it under library/databases and you can start using it.