mirror of
https://github.com/aljazceru/ansible-role-mysql.git
synced 2025-12-19 09:14:20 +01:00
Support mariadb and other mysql implementations that have a mysql include directory for my.cnf overrides
This commit is contained in:
11
README.md
11
README.md
@@ -32,6 +32,10 @@ Whether MySQL should be enabled on startup.
|
|||||||
|
|
||||||
Whether the global my.cnf should be overwritten each time this role is run. Setting this to `no` tells Ansible to only create the `my.cnf` file if it doesn't exist. This should be left at its default value (`yes`) if you'd like to use this role's variables to configure MySQL.
|
Whether the global my.cnf should be overwritten each time this role is run. Setting this to `no` tells Ansible to only create the `my.cnf` file if it doesn't exist. This should be left at its default value (`yes`) if you'd like to use this role's variables to configure MySQL.
|
||||||
|
|
||||||
|
mysql_config_include_files: []
|
||||||
|
|
||||||
|
A list of files that should override the default global my.cnf. Each item in the array requires a "src" parameter which is a path to a file. An optional "force" parameter can force the file to be updated each time ansible runs.
|
||||||
|
|
||||||
mysql_databases: []
|
mysql_databases: []
|
||||||
|
|
||||||
The MySQL databases to create. A database has the values `name`, `encoding` (defaults to `utf8`), `collation` (defaults to `utf8_general_ci`) and `replicate` (defaults to `1`, only used if replication is configured). The formats of these are the same as in the `mysql_db` module.
|
The MySQL databases to create. A database has the values `name`, `encoding` (defaults to `utf8`), `collation` (defaults to `utf8_general_ci`) and `replicate` (defaults to `1`, only used if replication is configured). The formats of these are the same as in the `mysql_db` module.
|
||||||
@@ -75,13 +79,6 @@ Slow query log settings. Note that the log file will be created by this role, bu
|
|||||||
|
|
||||||
The rest of the settings in `defaults/main.yml` control MySQL's memory usage. The default values are tuned for a server where MySQL can consume ~512 MB RAM, so you should consider adjusting them to suit your particular server better.
|
The rest of the settings in `defaults/main.yml` control MySQL's memory usage. The default values are tuned for a server where MySQL can consume ~512 MB RAM, so you should consider adjusting them to suit your particular server better.
|
||||||
|
|
||||||
mysqld_performance_settings:
|
|
||||||
- { name: key_buffer_size, value: "256M" }
|
|
||||||
mysql_dump_settings: []
|
|
||||||
- { name: mysqldump_max_allowed_packet, value: "64M" }
|
|
||||||
|
|
||||||
Any additional performance settings you would like to add beyond the defaults.
|
|
||||||
|
|
||||||
mysql_server_id: "1"
|
mysql_server_id: "1"
|
||||||
mysql_max_binlog_size: "100M"
|
mysql_max_binlog_size: "100M"
|
||||||
mysql_expire_logs_days: "10"
|
mysql_expire_logs_days: "10"
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ mysql_bind_address: '0.0.0.0'
|
|||||||
mysql_datadir: /var/lib/mysql
|
mysql_datadir: /var/lib/mysql
|
||||||
mysql_pid_file: /var/run/mysqld/mysqld.pid
|
mysql_pid_file: /var/run/mysqld/mysqld.pid
|
||||||
|
|
||||||
mysqld_performance_settings: []
|
|
||||||
|
|
||||||
# Slow query log settings.
|
# Slow query log settings.
|
||||||
mysql_slow_query_log_enabled: no
|
mysql_slow_query_log_enabled: no
|
||||||
mysql_slow_query_log_file: /var/log/mysql-slow.log
|
mysql_slow_query_log_file: /var/log/mysql-slow.log
|
||||||
@@ -67,13 +65,18 @@ mysql_innodb_lock_wait_timeout: 50
|
|||||||
# mysqldump settings.
|
# mysqldump settings.
|
||||||
mysql_mysqldump_max_allowed_packet: "64M"
|
mysql_mysqldump_max_allowed_packet: "64M"
|
||||||
|
|
||||||
mysql_dump_settings: []
|
|
||||||
|
|
||||||
# Logging settings.
|
# Logging settings.
|
||||||
mysql_log: ""
|
mysql_log: ""
|
||||||
mysql_log_error: /var/log/mysql.err
|
mysql_log_error: /var/log/mysql.err
|
||||||
mysql_syslog_tag: mysql
|
mysql_syslog_tag: mysql
|
||||||
|
|
||||||
|
mysql_config_include_files: []
|
||||||
|
# Full example:
|
||||||
|
# mysql_config_include_files:
|
||||||
|
# - src: path/relative/to/playbook/file.cnf
|
||||||
|
# - { src: path/relative/to/playbook/anotherfile.cnf, force: yes }
|
||||||
|
|
||||||
|
|
||||||
# Databases.
|
# Databases.
|
||||||
mysql_databases: []
|
mysql_databases: []
|
||||||
# Full example:
|
# Full example:
|
||||||
|
|||||||
@@ -9,6 +9,26 @@
|
|||||||
force: "{{ overwrite_global_mycnf }}"
|
force: "{{ overwrite_global_mycnf }}"
|
||||||
notify: restart mysql
|
notify: restart mysql
|
||||||
|
|
||||||
|
- name: Verify mysql include directory exists.
|
||||||
|
file:
|
||||||
|
path: "{{ mysql_config_include_dir }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0755
|
||||||
|
when: mysql_config_include_files|length
|
||||||
|
|
||||||
|
- name: Copy my.cnf override files into include directory.
|
||||||
|
template:
|
||||||
|
src: "{{ item.src }}"
|
||||||
|
dest: "{{ mysql_config_include_dir }}/{{ item.src | basename }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
force: "{{ item.force|default(False) }}"
|
||||||
|
with_items: mysql_config_include_files
|
||||||
|
notify: restart mysql
|
||||||
|
|
||||||
- name: Create slow query log file (if configured).
|
- name: Create slow query log file (if configured).
|
||||||
shell: "touch {{ mysql_slow_query_log_file }} creates={{ mysql_slow_query_log_file }}"
|
shell: "touch {{ mysql_slow_query_log_file }} creates={{ mysql_slow_query_log_file }}"
|
||||||
when: mysql_slow_query_log_enabled
|
when: mysql_slow_query_log_enabled
|
||||||
|
|||||||
@@ -90,16 +90,16 @@ innodb_log_buffer_size = {{ mysql_innodb_log_buffer_size }}
|
|||||||
innodb_flush_log_at_trx_commit = {{ mysql_innodb_flush_log_at_trx_commit }}
|
innodb_flush_log_at_trx_commit = {{ mysql_innodb_flush_log_at_trx_commit }}
|
||||||
innodb_lock_wait_timeout = {{ mysql_innodb_lock_wait_timeout }}
|
innodb_lock_wait_timeout = {{ mysql_innodb_lock_wait_timeout }}
|
||||||
|
|
||||||
{% for setting in mysqld_performance_settings %}
|
|
||||||
{{ setting.name }} = {{ setting.value }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
[mysqldump]
|
[mysqldump]
|
||||||
quick
|
quick
|
||||||
max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }}
|
max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }}
|
||||||
{% for setting in mysql_dump_settings %}
|
|
||||||
{{ setting.name }} = {{ setting.value }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
[mysqld_safe]
|
[mysqld_safe]
|
||||||
pid-file = {{ mysql_pid_file }}
|
pid-file = {{ mysql_pid_file }}
|
||||||
|
|
||||||
|
{% if mysql_config_include_files|length %}
|
||||||
|
# * IMPORTANT: Additional settings that can override those from this file!
|
||||||
|
# The files must end with '.cnf', otherwise they'll be ignored.
|
||||||
|
#
|
||||||
|
!includedir {{ mysql_config_include_dir }}
|
||||||
|
{% endif %}
|
||||||
@@ -5,4 +5,5 @@ __mysql_packages:
|
|||||||
- mysql-server
|
- mysql-server
|
||||||
__mysql_slow_query_log_file: /var/log/mysql/mysql-slow.log
|
__mysql_slow_query_log_file: /var/log/mysql/mysql-slow.log
|
||||||
mysql_config_file: /etc/mysql/my.cnf
|
mysql_config_file: /etc/mysql/my.cnf
|
||||||
|
mysql_config_include_dir: /etc/mysql/conf.d/
|
||||||
mysql_socket: /var/run/mysqld/mysqld.sock
|
mysql_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ __mysql_packages:
|
|||||||
- mysql-server
|
- mysql-server
|
||||||
__mysql_slow_query_log_file: /var/log/mysql-slow.log
|
__mysql_slow_query_log_file: /var/log/mysql-slow.log
|
||||||
mysql_config_file: /etc/my.cnf
|
mysql_config_file: /etc/my.cnf
|
||||||
|
mysql_config_include_dir: /etc/my.cnf.d
|
||||||
mysql_socket: /var/lib/mysql/mysql.sock
|
mysql_socket: /var/lib/mysql/mysql.sock
|
||||||
|
|||||||
Reference in New Issue
Block a user