when:result.stderr is defined and result.stderr != ''#有错误信息,说明mariadb服务不存在
- name:mariadb service not exist; install mariadb
shell:rpm -ivh {{ install_path }}/mariadb/*.rpm --force --nodeps && systemctl start mysql && systemctl enable mysql
when:result.stderr is defined and result.stderr != ''#有错误信息,说明mariadb服务不存在
register:install_mariadb_result
- name:copy my.cnf
template:
src:my.cnf_master.j2
dest:'/etc/my.cnf'
force:yes
run_once:true
delegate_to:'{{ groups.mariadb[0] }}'
when:result.stderr is defined and result.stderr != ''#有错误信息,说明mariadb服务不存在
- name:copy my.cnf
template:
src:my.cnf_slave.j2
dest:'/etc/my.cnf'
force:yes
run_once:true
delegate_to:'{{ groups.mariadb[1] }}'
when:result.stderr is defined and result.stderr != ''#有错误信息,说明mariadb服务不存在
- name:change mariadb root password
shell:mysql -uroot -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '{{ galaxy_mariadb_pin }}';"
when:result.stderr is defined and result.stderr != ''#有错误信息,说明mariadb服务不存在
- name:change mariadb remote authority
shell:mysql -uroot -p{{ galaxy_mariadb_pin }} -e"use mysql;grant all privileges on *.* to 'root'@'%' identified by '{{ galaxy_mariadb_pin }}' with grant option;FLUSH PRIVILEGES;"
when:result.stderr is defined and result.stderr != ''#有错误信息,说明mariadb服务不存在