  - name: transfer sql statement to remonte
    template:
     src: /tmp/envoyinstack/include/replmgr/deploy/ansible/mysql/template/config_mysql_group_replication.sql
     dest: /tmp/config_mysql_group_replication.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: restart mysqld
    service: name=mysqld state=restarted

  - name: config mysql group replication
    shell: source /etc/profile;mysql -hlocalhost -uroot -p{{ mysql_root_password.stdout }} -S /tmp/mysql.sock  < /tmp/config_mysql_group_replication.sql

#  - name: restart mysqld
#    service: name=mysqld state=restarted

  - name: remove temp file /tmp/config_mysql_group_replication.sql
    file:
     dest: /tmp/config_mysql_group_replication.sql
     state: absent
