Support mariadb and other mysql implementations that have a mysql include directory for my.cnf overrides

pull/63/head
Solomon Gifford 9 years ago
parent 9de3121b26
commit 2a8b19fe11
  1. 11
      README.md
  2. 11
      defaults/main.yml
  3. 20
      tasks/configure.yml
  4. 14
      templates/my.cnf.j2
  5. 1
      vars/Debian.yml
  6. 1
      vars/RedHat.yml

@ -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.
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: []
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.
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_max_binlog_size: "100M"
mysql_expire_logs_days: "10"

@ -28,8 +28,6 @@ mysql_bind_address: '0.0.0.0'
mysql_datadir: /var/lib/mysql
mysql_pid_file: /var/run/mysqld/mysqld.pid
mysqld_performance_settings: []
# Slow query log settings.
mysql_slow_query_log_enabled: no
mysql_slow_query_log_file: /var/log/mysql-slow.log
@ -67,13 +65,18 @@ mysql_innodb_lock_wait_timeout: 50
# mysqldump settings.
mysql_mysqldump_max_allowed_packet: "64M"
mysql_dump_settings: []
# Logging settings.
mysql_log: ""
mysql_log_error: /var/log/mysql.err
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.
mysql_databases: []
# Full example:

@ -9,6 +9,26 @@
force: "{{ overwrite_global_mycnf }}"
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).
shell: "touch {{ mysql_slow_query_log_file }} creates={{ mysql_slow_query_log_file }}"
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_lock_wait_timeout = {{ mysql_innodb_lock_wait_timeout }}
{% for setting in mysqld_performance_settings %}
{{ setting.name }} = {{ setting.value }}
{% endfor %}
[mysqldump]
quick
max_allowed_packet = {{ mysql_mysqldump_max_allowed_packet }}
{% for setting in mysql_dump_settings %}
{{ setting.name }} = {{ setting.value }}
{% endfor %}
[mysqld_safe]
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_slow_query_log_file: /var/log/mysql/mysql-slow.log
mysql_config_file: /etc/mysql/my.cnf
mysql_config_include_dir: /etc/mysql/conf.d/
mysql_socket: /var/run/mysqld/mysqld.sock

@ -5,4 +5,5 @@ __mysql_packages:
- mysql-server
__mysql_slow_query_log_file: /var/log/mysql-slow.log
mysql_config_file: /etc/my.cnf
mysql_config_include_dir: /etc/my.cnf.d
mysql_socket: /var/lib/mysql/mysql.sock