diff --git a/README.md b/README.md index 561b802..c92173c 100644 --- a/README.md +++ b/README.md @@ -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 -------- diff --git a/defaults/main.yml b/defaults/main.yml index 50a27f2..633ead4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 8aa036c..e2c4a29 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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' @@ -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 @@ -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 diff --git a/templates/my.cnf.Debian.j2 b/templates/my.cnf.Debian.j2 index e3bf9d3..d9694f1 100644 --- a/templates/my.cnf.Debian.j2 +++ b/templates/my.cnf.Debian.j2 @@ -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 }}