---
 - name: stransfer sql to remote host
   template: 
    src: /tmp/envoyinstack/include/replmgr/deploy/ansible/mysql/template/master_slaves.sql
    dest: /tmp/master_slaves.sql

 - name: register mysql_root_password
   shell: /usr/bin/cat /tmp/envoyinstack/include/replmgr/config.yaml |grep ^mysql_root_password|awk -F ' ' '{print $2}'
   register: mysql_root_password #(?<=mysql_root_password: )\S+
 
 - name: create replication user on master / start slave on slave
   when:
   shell: source /etc/profile;mysql -hlocalhost -uroot -p{{ mysql_root_password.stdout }} -S /tmp/mysql.sock < /tmp/master_slaves.sql

 - name: restart mysqld
   service: name=mysqld state=restarted
#   with_items:
#     - "{{ ansible_all_ipv4_addresses }}"
#   when: item != master_ip

 - name: clear temp file /tmp/master_slaves.sql
   file:
    dest: /tmp/master_slaves.sql
    state: absent
