Make innodb_buffer_pool_size configurable

Usage:

  galera:
    master:
      innodb_buffer_pool_size: 1024M
    slave:
      innodb_buffer_pool_size: 1024M

If innodb_buffer_pool_size is not set then 35% of the available
ram will be allocated for the buffer pool.

Change-Id: Iaffa3f5b4ded8bc838f9d707916e360ed873c13b
diff --git a/README.rst b/README.rst
index e692b69..98eba4a 100644
--- a/README.rst
+++ b/README.rst
@@ -56,13 +56,28 @@
           user: root
           password: pass
 
+InnoDB parameters
+=================
+
+- **innodb_buffer_pool_size** - the default value is 35% of the available ram
+
+Usage:
+
+.. code-block:: yaml
+
+    galera:
+        master:
+          innodb_buffer_pool_size: 1024M
+        slave:
+          innodb_buffer_pool_size: 1024M
+
 Usage
 =====
 
 MySQL Galera check sripts
 
 .. code-block:: bash
-    
+
     mysql> SHOW STATUS LIKE 'wsrep%';
 
     mysql> SHOW STATUS LIKE 'wsrep_cluster_size' ;"
@@ -80,15 +95,15 @@
 
 .. code-block:: bash
 
-    Enter current password for root (enter for none): 
+    Enter current password for root (enter for none):
     OK, successfully used password, moving on...
 
     Setting the root password ensures that nobody can log into the MySQL
     root user without the proper authorisation.
 
     Set root password? [Y/n] y
-    New password: 
-    Re-enter new password: 
+    New password:
+    Re-enter new password:
     Password updated successfully!
     Reloading privilege tables..
      ... Success!
@@ -127,7 +142,7 @@
     Cleaning up...
 
 5. service mysql stop
-6. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://'; 
+6. uncomment all wsrep* lines except first server, where leave only in my.cnf wsrep_cluster_address='gcomm://';
 7. start first node
 8. Start third node which is connected to first one
 9. Start second node which is connected to third one
diff --git a/galera/files/my.cnf b/galera/files/my.cnf
index 5ceb376..ebcdb22 100644
--- a/galera/files/my.cnf
+++ b/galera/files/my.cnf
@@ -38,7 +38,12 @@
 
 innodb_file_format=Barracuda
 innodb_file_per_table=1
-innodb_buffer_pool_size=3138M
+{%- if service.innodb_buffer_pool_size is not defined %}
+  {% set buffer_pool_size = '%.2fM'%(grains['mem_total']*0.35) %}
+{%- else %}
+  {% set buffer_pool_size = service.innodb_buffer_pool_size %}
+{%- endif %}
+innodb_buffer_pool_size={{ buffer_pool_size }}
 innodb_log_file_size=627M
 innodb_read_io_threads=8
 innodb_write_io_threads=8
@@ -48,7 +53,6 @@
 innodb_doublewrite=0
 innodb_autoinc_lock_mode=2
 innodb_locks_unsafe_for_binlog=1
-
 wsrep_cluster_address="gcomm://{% for member in service.members %}{{ member.host}}:4567{% if not loop.last %},{% endif %}{% endfor %}/?pc.wait_prim=no"
 wsrep_provider={{ service.wsrep_provider }}
 wsrep_cluster_name="openstack"