Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add variables for other mysql settings #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ them are as follows:
# A unique id for the mysql server (used in replication):
mysql_db_id: 7

# Other settings
mysql_key_buffer: 16M
mysql_max_allowed_packet: 16M
mysql_thread_stack: 192K
mysql_thread_cache_size: 8

mysql_query_cache_limit: 1M
mysql_query_cache_size: 16M

Examples
--------

Expand Down
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ mysql_repl_user:

mysql_repl_role: master
mysql_db_id: 7

mysql_key_buffer: 16M
mysql_max_allowed_packet: 16M
mysql_thread_stack: 192K
mysql_thread_cache_size: 8

mysql_query_cache_limit: 1M
mysql_query_cache_size: 16M
17 changes: 11 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

- name: Install the mysql packages in Redhat derivatives
yum: name={{ item }} state=installed
with_items: mysql_pkgs
with_items:
- "{{ mysql_pkgs }}"
when: ansible_os_family == 'RedHat'

- name: Install the mysql packages in Debian derivatives
apt: name={{ item }} state=installed update_cache=yes
with_items: mysql_pkgs
with_items:
- "{{ mysql_pkgs }}"
environment: env
when: ansible_os_family == 'Debian'

Expand Down Expand Up @@ -57,19 +59,22 @@

- name: Create the database's
mysql_db: name={{ item.name }} state=present
with_items: mysql_db
with_items:
- "{{ mysql_db }}"
when: mysql_db|lower() != 'none'

- name: Create the database users
mysql_user: name={{ item.name }} password={{ item.pass|default("foobar") }}
priv={{ item.priv|default("*.*:ALL") }} state=present host={{ item.host | default("localhost") }}
with_items: mysql_users
with_items:
- "{{ mysql_users }}"
when: mysql_users|lower() != 'none'

- name: Create the replication users
mysql_user: name={{ item.name }} host="%" password={{ item.pass|default("foobar") }}
priv=*.*:"REPLICATION SLAVE" state=present
with_items: mysql_repl_user
with_items:
- "{{ mysql_repl_user }}"
when: mysql_repl_role == 'master'

- name: Check if slave is already configured for replication
Expand All @@ -79,7 +84,7 @@
when: mysql_repl_role == 'slave'

- name: Ensure the hostname entry for master is available for the client.
lineinfile: dest=/etc/hosts regexp="{{ mysql_repl_master }}" line="{{ hostvars[mysql_repl_master].ansible_default_ipv4.address + " " + mysql_repl_master }}" state=present
lineinfile: dest=/etc/hosts regexp="{{ mysql_repl_master }}" line="{{ hostvars[mysql_repl_master].ansible_default_ipv4.address + ' ' + mysql_repl_master }}" state=present
when: slave|failed and mysql_repl_role == 'slave' and mysql_repl_master is defined

- name: Get the current master servers replication status
Expand Down
12 changes: 6 additions & 6 deletions templates/my.cnf.Debian.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ skip-external-locking

bind-address = {{ mysql_bind_address }}

key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
key_buffer = {{ mysql_key_buffer }}
max_allowed_packet = {{ mysql_max_allowed_packet }}
thread_stack = {{ mysql_thread_stack }}
thread_cache_size = {{ mysql_thread_cache_size }}

query_cache_limit = 1M
query_cache_size = 16M
query_cache_limit = {{ mysql_query_cache_limit }}
query_cache_size = {{ mysql_query_cache_size }}
log_error = /var/log/mysql/error.log
server-id = {{ mysql_db_id }}

Expand Down