Jcrespo has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316541

Change subject: Add new module proxysql
......................................................................

Add new module proxysql

For now this only has basic functionality:
* Install the recentely uploaded package
* Set the admin configuration, forcing the change of admin password

The puppet module itself will be very basic because most of the
configuration is handled on the mysql-like interface, not on the
config. We will see how that can be handled later.

Bug: T148500
Change-Id: Iea6e3715ccb00a065bf4a9c75f3eb6340c0c7996
---
A modules/proxysql/manifests/init.pp
A modules/proxysql/templates/proxysql.cnf.erb
2 files changed, 205 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/41/316541/1

diff --git a/modules/proxysql/manifests/init.pp 
b/modules/proxysql/manifests/init.pp
new file mode 100644
index 0000000..9b6e008
--- /dev/null
+++ b/modules/proxysql/manifests/init.pp
@@ -0,0 +1,28 @@
+# Class proxysql
+
+class proxysql (
+    $admin_user = 'admin',
+    $admin_password,
+    $admin_port = 6032,
+    $admin_interface = '127.0.0.1',
+    $admin_socket = '/tmp/proxysql_admin.sock',
+    $mysql_interface = '0.0.0.0',
+    $mysql_port = 6033,
+    $mysql_socket = '/tmp/proxysql.sock',
+    ) {
+
+    package { [
+        'proxysql',
+    ]:
+        ensure => present,
+    }
+
+    file { '/etc/proxysql.cnf':
+        ensure  => present,
+        mode    => '0444',
+        owner   => 'root',
+        group   => 'root',
+        content => template('proxysql/proxysql.cnf.erb'),
+    }
+
+}
diff --git a/modules/proxysql/templates/proxysql.cnf.erb 
b/modules/proxysql/templates/proxysql.cnf.erb
new file mode 100644
index 0000000..bd457aa
--- /dev/null
+++ b/modules/proxysql/templates/proxysql.cnf.erb
@@ -0,0 +1,177 @@
+#file proxysql.cfg
+
+# This config file is parsed using libconfig , and its grammar is described in:
+# 
http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
+# Grammar is also copied at the end of this file
+
+
+
+datadir="/var/lib/proxysql"
+
+admin_variables=
+{
+       admin_credentials="<%= @admin_user -%>:<%= @admin_password -%>"
+       mysql_ifaces="<%= @admin_interface -%>:<%= @admin_port -%>;<%= 
@admin_socket -%>"
+#      refresh_interval=2000
+#      debug=true
+}
+
+mysql_variables=
+{
+       threads=4
+       max_connections=2048
+       default_query_delay=0
+       default_query_timeout=36000000
+       have_compress=true
+       poll_timeout=2000
+       interfaces="<%= @mysql_interface -%>:<%= @mysql_port -%>;<%= 
@mysql_socket -%>"
+       default_schema="information_schema"
+       stacksize=1048576
+       server_version="5.5.30"
+       connect_timeout_server=3000
+       monitor_history=600000
+       monitor_connect_interval=60000
+       monitor_ping_interval=10000
+       monitor_read_only_interval=1500
+       monitor_read_only_timeout=500
+       ping_interval_server=120000
+       ping_timeout_server=500
+       commands_stats=true
+       sessions_sort=true
+       connect_retries_on_failure=10
+}
+
+
+# defines all the MySQL servers
+mysql_servers =
+(
+#      {
+#              address = "127.0.0.1" # no default, required . If port is 0 , 
address is interpred as a Unix Socket Domain
+#              port = 3306           # no default, required . If port is 0 , 
address is interpred as a Unix Socket Domain
+#              hostgroup = 0           # no default, required
+#              status = "ONLINE"     # default: ONLINE
+#              weight = 1            # default: 1
+#              compression = 0       # default: 0
+#   max_replication_lag = 10  # default 0 . If greater than 0 and replication 
lag passes such threshold, the server is shunned
+#      },
+#      {
+#              address = "/var/lib/mysql/mysql.sock"
+#              port = 0
+#              hostgroup = 0
+#      },
+#      {
+#              address="127.0.0.1"
+#              port=21891
+#              hostgroup=0
+#              max_connections=200
+#      },
+#      { address="127.0.0.2" , port=3306 , hostgroup=0, max_connections=5 },
+#      { address="127.0.0.1" , port=21892 , hostgroup=1 },
+#      { address="127.0.0.1" , port=21893 , hostgroup=1 }
+#      { address="127.0.0.2" , port=3306 , hostgroup=1 },
+#      { address="127.0.0.3" , port=3306 , hostgroup=1 },
+#      { address="127.0.0.4" , port=3306 , hostgroup=1 },
+#      { address="/var/lib/mysql/mysql.sock" , port=0 , hostgroup=1 }
+)
+
+
+# defines all the MySQL users
+mysql_users:
+(
+#      {
+#              username = "username" # no default , required
+#              password = "password" # default: ''
+#              default_hostgroup = 0 # default: 0
+#              active = 1            # default: 1
+#      },
+#      {
+#              username = "root"
+#              password = ""
+#              default_hostgroup = 0
+#              max_connections=1000
+#              default_schema="test"
+#              active = 1
+#      },
+#      { username = "user1" , password = "password" , default_hostgroup = 0 , 
active = 0 }
+)
+
+
+
+#defines MySQL Query Rules
+mysql_query_rules:
+(
+#      {
+#              rule_id=1
+#              active=1
+#              match_pattern="^SELECT .* FOR UPDATE$"
+#              destination_hostgroup=0
+#              apply=1
+#      },
+#      {
+#              rule_id=2
+#              active=1
+#              match_pattern="^SELECT"
+#              destination_hostgroup=1
+#              apply=1
+#      }
+)
+
+scheduler=
+(
+#  {
+#    id=1
+#    active=0
+#    interval_ms=10000
+#    filename="/var/lib/proxysql/proxysql_galera_checker.sh"
+#    arg1="0"
+#    arg2="0"
+#    arg3="0"
+#    arg4="1"
+#    arg5="/var/lib/proxysql/proxysql_galera_checker.log"
+#  }
+)
+
+
+mysql_replication_hostgroups=
+(
+#        {
+#                writer_hostgroup=30
+#                reader_hostgroup=40
+#                comment="test repl 1"
+#       },
+#       {
+#                writer_hostgroup=50
+#                reader_hostgroup=60
+#                comment="test repl 2"
+#        }
+)
+
+
+
+
+# 
http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
+#
+# Below is the BNF grammar for configuration files. Comments and include 
directives are not part of the grammar, so they are not included here. 
+#
+# configuration = setting-list | empty
+#
+# setting-list = setting | setting-list setting
+#     
+# setting = name (":" | "=") value (";" | "," | empty)
+#     
+# value = scalar-value | array | list | group
+#     
+# value-list = value | value-list "," value
+#     
+# scalar-value = boolean | integer | integer64 | hex | hex64 | float
+#                | string
+#     
+# scalar-value-list = scalar-value | scalar-value-list "," scalar-value
+#     
+# array = "[" (scalar-value-list | empty) "]"
+#     
+# list = "(" (value-list | empty) ")"
+#     
+# group = "{" (setting-list | empty) "}"
+#     
+# empty =

-- 
To view, visit https://gerrit.wikimedia.org/r/316541
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea6e3715ccb00a065bf4a9c75f3eb6340c0c7996
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Jcrespo <jcre...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to