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.


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
    state: import
    target: /path/to/import/file.sql
  • Thanks for the idea! This sounds like a good way of importing the plugin once it's already provisioned to the server, yes. I will give it a try if I have any issues, but I already solved the problem using the shell module after all - turned out to be a bit neater than expected. I will add it as an answer. – insideClaw Jul 10 '18 at 13:02

Solved by obtaining the missing group_replication.so file (I got it from MySQL Community Edition), then provisioning and enabling it using these two Ansible tasks:

- name: Provision the MySQL group_replication plugin
    src: group_replication.so
    dest: /usr/lib/mysql/plugin/group_replication.so
    mode: 0644

- name: Install MySQL plugin group_replication
  shell: >
         mysql -u root -e "SHOW PLUGINS\G" | grep -q group_replication
         && echo -n FOUND
         || mysql -u root -e "INSTALL PLUGIN group_replication SONAME 'group_replication.so';"
  register: plugin_state
  changed_when: plugin_state.stdout != 'FOUND'

The plugin itself I placed under a local files/ folder for Ansible to find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.