1 proxysql
Markus Bergholz edited this page 1 year ago

Playground Environment

1. Container Image

FROM ubuntu:20.04

RUN apt update && apt install -y python3-pymysql mariadb-client wget
RUN wget https://github.com/sysown/proxysql/releases/download/v2.2.0/proxysql_2.2.0-ubuntu20_amd64.deb && \
  dpkg -i proxysql_2.2.0-ubuntu20_amd64.deb

CMD proxysql --idle-threads -f

start with `docker run -d --rm proxysq_container <image_name>

2. Ansible Inventory

[testing]
proxysql_container ansible_connection=docker ansible_python_interpreter=/usr/bin/python3

3. Playbooks

---
- hosts: testing
  
  tasks:
    - name: change check mode
      community.proxysql.proxysql_query_rules_fast_routing:
        login_user: admin
        login_password: admin
        username: 'user_ro'
        schemaname: 'default'
        destination_hostgroup: 1
        comment: 'fast route user_ro to default schema'
        state: present
        save_to_disk: yes
        load_to_runtime: yes
      check_mode: yes
    
    - name: change
      community.proxysql.proxysql_query_rules_fast_routing:
        login_user: admin
        login_password: admin
        username: 'user_ro'
        schemaname: 'default'
        destination_hostgroup: 1
        comment: 'fast route user_ro to default schema'
        state: present
        save_to_disk: yes
        load_to_runtime: yes

    - name: no change
      community.proxysql.proxysql_query_rules_fast_routing:
        login_user: admin
        login_password: admin
        username: 'user_ro'
        schemaname: 'default'
        destination_hostgroup: 1
        comment: 'fast route user_ro to default schema'
        state: present
        save_to_disk: yes
        load_to_runtime: yes

    - name: no change check mode
      community.proxysql.proxysql_query_rules_fast_routing:
        login_user: admin
        login_password: admin
        username: 'user_ro'
        schemaname: 'default'
        destination_hostgroup: 1
        comment: 'fast route user_ro to default schema'
        state: present
        save_to_disk: yes
        load_to_runtime: yes
      check_mode: yes