File tree Expand file tree Collapse file tree 9 files changed +38
-15
lines changed Expand file tree Collapse file tree 9 files changed +38
-15
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ mysql_bind_address: '0.0.0.0'
120120mysql_datadir: /var/lib/mysql
121121mysql_socket: *default value depends on OS*
122122mysql_pid_file: *default value depends on OS*
123+
124+ mysql_login_host: ""
125+ mysql_login_user: ""
126+ mysql_login_password: ""
127+ mysql_ca_cert: ""
123128` ` `
124129
125130Default MySQL connection configuration.
Original file line number Diff line number Diff line change @@ -42,6 +42,16 @@ mysql_bind_address: '0.0.0.0'
4242mysql_skip_name_resolve : false
4343mysql_datadir : /var/lib/mysql
4444mysql_sql_mode : ~
45+
46+ # Host running the database
47+ mysql_login_host : " "
48+ # The username and password used to authenticate with
49+ mysql_login_user : " "
50+ mysql_login_password : " "
51+ # The path to a Certificate Authority (CA) certificate.
52+ # This option, if used, must specify the same certificate as used by the server
53+ mysql_ca_cert : " "
54+
4555# The following variables have a default value depending on operating system.
4656# mysql_pid_file: /var/run/mysqld/mysqld.pid
4757# mysql_socket: /var/lib/mysql/mysql.sock
Original file line number Diff line number Diff line change 11---
2- - name : restart mysql
2+ - name : Restart mysql
33 ansible.builtin.service :
44 name : " {{ mysql_daemon }}"
55 state : restarted
Original file line number Diff line number Diff line change 1313 group : root
1414 mode : 0644
1515 force : " {{ overwrite_global_mycnf }}"
16- notify : restart mysql
16+ notify : Restart mysql
1717
1818- name : Verify mysql include directory exists.
1919 ansible.builtin.file :
3333 mode : 0644
3434 force : " {{ item.force | default(False) }}"
3535 with_items : " {{ mysql_config_include_files }}"
36- notify : restart mysql
36+ notify : Restart mysql
3737
3838- name : Create slow query log file (if configured).
3939 ansible.builtin.command : " touch {{ mysql_slow_query_log_file }}"
Original file line number Diff line number Diff line change 11---
22- name : Ensure MySQL databases are present.
3- mysql_db :
3+ community.mysql. mysql_db :
44 name : " {{ item.name }}"
55 collation : " {{ item.collation | default('utf8_general_ci') }}"
66 encoding : " {{ item.encoding | default('utf8') }}"
77 state : " {{ item.state | default('present') }}"
88 target : " {{ item.target | default(omit) }}"
9+ login_user : " {{ mysql_login_user | default(omit) }}"
10+ login_password : " {{ mysql_login_password | default(omit) }}"
11+ login_host : " {{ mysql_login_host | default(omit) }}"
12+ ca_cert : " {{ mysql_ca_cert | default(omit) }}"
913 with_items : " {{ mysql_databases }}"
Original file line number Diff line number Diff line change 11---
22- name : Ensure replication user exists on master.
3- mysql_user :
3+ community.mysql. mysql_user :
44 name : " {{ mysql_replication_user.name }}"
55 host : " {{ mysql_replication_user.host | default('%') }}"
66 password : " {{ mysql_replication_user.password }}"
1414 tags : ['skip_ansible_galaxy']
1515
1616- name : Check slave replication status.
17- mysql_replication :
17+ community.mysql. mysql_replication :
1818 mode : getreplica
1919 login_user : " {{ mysql_root_username }}"
2020 login_password : " {{ mysql_root_password }}"
2828
2929# https://github.com/ansible/ansible/issues/82264
3030- name : Check master replication status.
31- mysql_replication :
31+ community.mysql. mysql_replication :
3232 mode : getprimary
3333 delegate_to : " {{ mysql_replication_master_inventory_host | default(omit, true) }}"
3434 register : master
3939 tags : ['skip_ansible_galaxy']
4040
4141- name : Configure replication on the slave.
42- mysql_replication :
42+ community.mysql. mysql_replication :
4343 mode : changeprimary
4444 master_host : " {{ mysql_replication_master }}"
4545 master_user : " {{ mysql_replication_user.name }}"
5555 - (mysql_replication_master | length) > 0
5656
5757- name : Start replication.
58- mysql_replication :
58+ community.mysql. mysql_replication :
5959 mode : startreplica
6060 when :
6161 - (slave.Is_Slave is defined and slave.Is_Slave) or (slave.Is_Replica is defined and slave.Is_Replica) or (slave.Is_Slave is not defined and slave.Is_Replica is not defined and slave is failed)
Original file line number Diff line number Diff line change 11---
22- name : Ensure default user is present.
3- mysql_user :
3+ community.mysql. mysql_user :
44 name : " {{ mysql_user_name }}"
55 host : ' localhost'
66 password : " {{ mysql_user_password }}"
8181 check_mode : false
8282
8383- name : Remove anonymous MySQL users.
84- mysql_user :
84+ community.mysql. mysql_user :
8585 name : " "
8686 host : " {{ item }}"
8787 state : absent
8888 with_items : " {{ mysql_anonymous_hosts.stdout_lines|default([]) }}"
8989
9090- name : Remove MySQL test database.
91- mysql_db :
91+ community.mysql. mysql_db :
9292 name : ' test'
9393 state : absent
Original file line number Diff line number Diff line change 66
77- name : Update apt cache if MySQL is not yet installed.
88 ansible.builtin.apt :
9- update_cache : yes
10- changed_when : False
9+ update_cache : true
10+ changed_when : false
1111 when : not mysql_installed.stat.exists
1212
1313- name : Ensure MySQL Python libraries are installed.
Original file line number Diff line number Diff line change 11---
22- name : Ensure MySQL users are present.
3- mysql_user :
3+ community.mysql. mysql_user :
44 name : " {{ item.name }}"
55 host : " {{ item.host | default('localhost') }}"
66 password : " {{ item.password }}"
77 priv : " {{ item.priv | default('*.*:USAGE') }}"
88 state : " {{ item.state | default('present') }}"
99 append_privs : " {{ item.append_privs | default('no') }}"
1010 encrypted : " {{ item.encrypted | default('no') }}"
11+ login_user : " {{ mysql_login_user | default(omit) }}"
12+ login_password : " {{ mysql_login_password | default(omit) }}"
13+ login_host : " {{ mysql_login_host | default(omit) }}"
14+ ca_cert : " {{ mysql_ca_cert | default(omit) }}"
1115 with_items : " {{ mysql_users }}"
1216 no_log : " {{ mysql_hide_passwords }}"
You can’t perform that action at this time.
0 commit comments