Mysql – How to install a MySQL plugin with Ansible

ansibleautomationdatabasedeploymentMySQL

So far we've been using the Geerlingguy Ansible role for all of our database deployments, but now I'm expanding our usage of it for a new project, and it doesn't seem installing plugins is a supported option. The command I need executed in one way or another in MySQL is

INSTALL PLUGIN group_replication SONAME 'group_replication.so';

I doubt it's a good idea to even consider gathering facts and using the shell module to actually execute the commands directly, but so far I don't see any other options. Is there anything relevant I haven't spotted? Thanks in advance.

Best Answer

I think you could generate an sql file with the INSTALL PLUGIN line and use the MySQL import function of the Ansible mysql_db module to run it.

This might be better than using the shell.

- name: Import sql similar to mysql -u <username> -p <password> < file.sql
  mysql_db:
    state: import
    name: DATABASE-NAME
    target: /path/to/import/file.sql