[maxscale]
threads=auto
admin_host=127.0.0.1
admin_secure_gui=false
{% for host in groups['db_hosts'] %}
[{{ host }}]
type=server
address={{ hostvars[host].ansible_host }}
port=3336
protocol=MariaDBBackend
monitoruser=maxscale
monitorpw={{ master_pass }}
{% endfor %}
[MainMonitor]
type=monitor
module=mariadbmon
servers={% for host in groups['db_hosts'] %}{{ host }},{% endfor %}
user=maxscale
password={{ master_pass }}
{% if "monitor" in maxscale_roles %}
auto_failover=true
auto_rejoin=true
enforce_read_only_slaves=true
enforce_simple_topology=true
enforce_writable_master=true
#cooperative_monitoring_locks=majority_of_all
script=/root/scripts/scripts/monitor_script.sh --initiator=$INITIATOR --parent=$PARENT --children=$CHILDREN --event=$EVENT --node_list=$NODELIST --list=$LIST --master_list=$MASTERLIST --slave_list=$SLAVELIST --synced_list=$SYNCEDLIST
ssh_user=maxscale
ssh_keyfile=/ssh_key
ssh_check_host_key=false
{% else %}
auto_failover=false
auto_rejoin=false
enforce_read_only_slaves=false
enforce_simple_topology=false
enforce_writable_master=false
{% endif %}
{% if inventory_hostname in groups['routers'] %}
[MainService]
type=service
#router=readwritesplit
router=Readconnroute
router_options=master
user=maxscale
password={{ master_pass }}
cluster=MainMonitor
[MainListener]
type=listener
service=MainService
protocol=MariaDB
port=3306
{% endif %}