Here's how I implemented this using the command line mysql args:

- name: Check if slave is already configured for replication
  mysql_replication: mode=getslave
  register: slave
  ignore_errors: true # on the first run, this will error because not 
replicating yet
  when: ansible_default_ipv4.address != mysql_master_ip

- name: Get the current master server's replication status
  mysql_replication: "mode=getmaster login_user='{{ mysql_replication_user 
}}' login_password='{{ mysql_replication_pass }}' login_host='{{ 
mysql_master_ip }}'"
  register: mysql_repl_stat
  delegate_to: "{{ mysql_master_name }}"
  when: ansible_default_ipv4.address != mysql_master_ip

- name: ensure mysql replication
  when: "slave|failed and ansible_default_ipv4.address != mysql_master_ip
  command: "
      /usr/bin/mysql -u {{ mysql_user }} -p{{ mysql_pass }} -e 
      \" 
      STOP SLAVE;
      RESET MASTER;
      SET GLOBAL gtid_purged='{{ mysql_repl_stat.Executed_Gtid_Set }}'; 
      CHANGE MASTER TO MASTER_HOST='{{ mysql_master_ip }}', MASTER_USER='{{ 
mysql_replication_user }}', MASTER_PASSWORD='{{ mysql_replication_pass }}', 
MASTER_AUTO_POSITION=1; 
      START SLAVE; 
      \"
    "

On Monday, December 15, 2014 10:07:23 PM UTC-8, Evan Tahler wrote:
>
> Hi!
>
> Is there any (planned) support for GTID-based replication 
> <http://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html> in 
> the mysql-replication package 
> <https://github.com/ansible/ansible-modules-extras/blob/devel/database/mysql/mysql_replication.py>
> ?
>
> It looks like someone started this here 
> <http://ops.kinja.com/mysql_replciation-ansible-module-update-1525041688>, 
> but didn't get it back into master. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/25400a9c-673e-4c44-a13c-6a2e0b710c4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to