GithubHelp home page GithubHelp logo

ansible-collections / community.proxysql Goto Github PK

View Code? Open in Web Editor NEW
18.0 10.0 26.0 231 KB

ProxySQL Ansible Collection

Home Page: http://galaxy.ansible.com/community/proxysql

License: GNU General Public License v3.0

Python 99.47% Jinja 0.53%
hacktoberfest proxysql mysql-connector proxysql-collection ansible-collection

community.proxysql's Introduction

ProxySQL collection for Ansible

Plugins CI Roles CI Codecov

This collection is a part of the Ansible package.

Code of Conduct

We follow Ansible Code of Conduct in all our interactions within this project.

If you encounter abusive behavior violating the Ansible Code of Conduct, please refer to the policy violations section of the Code of Conduct for information on how to raise a complaint.

Contributing to this collection

The content of this collection is made by good people just like you, a community of individuals collaborating on making the world better through developing automation software.

We are actively accepting new contributors.

All types of contributions are very welcome.

You don't know how to start? Refer to our contribution guide!

Collection maintenance

The current maintainers (contributors with write or higher access) are listed in the MAINTAINERS file. If you have questions or need help, feel free to mention them in the proposals.

To learn how to maintain / become a maintainer of this collection, refer to the Maintainer guidelines.

It is necessary for maintainers of this collection to be subscribed to:

  • The collection itself (the Watch button -> All Activity in the upper right corner of the repository's homepage).
  • The "Changes Impacting Collection Contributors and Maintainers" issue.

They also should be subscribed to Ansible's The Bullhorn newsletter.

Communication

We announce important development changes and releases through Ansible's The Bullhorn newsletter. If you are a collection developer, be sure you are subscribed.

Join us in the #ansible (general use questions and support), #ansible-community (community and collection development questions), and other IRC channels on Libera.Chat.

We take part in the global quarterly Ansible Contributor Summit virtually or in-person. Track The Bullhorn newsletter and join us.

For more information about communication, refer to the Ansible Communication guide.

Included content

  • Modules:
    • proxysql_backend_servers: Adds or removes mysql hosts from proxysql admin interface.
    • proxysql_global_variables: Gets or sets the proxysql global variables.
    • proxysql_info: Gathers information about proxysql server.
    • proxysql_manage_config: Writes the proxysql configuration settings between layers.
    • proxysql_mysql_users: Adds or removes mysql users from proxysql admin interface.
    • proxysql_query_rules_fast_routing.py: Modifies query rules for fast routing policies using the proxysql admin interface.
    • proxysql_query_rules: Modifies query rules using the proxysql admin interface.
    • proxysql_replication_hostgroups: Manages replication hostgroups using the proxysql admin.
    • proxysql_galera_hostgroups: Manages galera hostgroups using the proxysql admin.
    • proxysql_scheduler: Adds or removes schedules from proxysql admin interface.
  • Roles:
    • proxysql

Note: if you do not see documentation for a module on docs.ansible.come, use the ansible-doc command or see the DOCUMENTATION section in the plugins/modules/<module_name>.py file.

Supports and tested with ansible-core

  • 2.11
  • 2.12
  • 2.13
  • current development version

External requirements

The ProxySQL modules rely on a MySQL connector. The list of supported drivers is below:

  • PyMySQL
  • MySQLdb
  • Support for other Python MySQL connectors may be added in a future release.

Using this collection

Installing the Collection from Ansible Galaxy

Before using the ProxySQL collection, you need to install it with the Ansible Galaxy command-line tool:

ansible-galaxy collection install community.proxysql

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: community.proxysql

You can also download the tarball from Ansible Galaxy and install the collection manually wherever you need.

Note that if you install the collection from Ansible Galaxy with the command-line tool or tarball, it will not be upgraded automatically when you upgrade the Ansible package. To upgrade the collection to the latest available version, run the following command:

ansible-galaxy collection install community.proxysql --upgrade

You can also install a specific version of the collection, for example, if you need to downgrade when something is broken in the latest version (please report an issue in this repository). Use the following syntax:

ansible-galaxy collection install community.proxysql:==X.Y.Z

See Ansible Using collections for more details.

Licensing

GNU General Public License v3.0 or later.

See LICENSE to see the full text.

community.proxysql's People

Contributors

akimrx avatar andersson007 avatar bmildren avatar felixfontein avatar gundalow avatar jpiron avatar laurent-indermuehle avatar ls-michielrensen avatar markuman avatar mjbnz avatar mrpk1906 avatar squirrel532 avatar tompal3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

community.proxysql's Issues

proxysql_manage_config unexpectedly modifies system state in check mode

SUMMARY

Hi o/

I see in the docs that proxysql_manage_config supports check mode. I don't see in the module code that check mode actually changes the the behavior of the module in any way, and from our proxysql logs it seems like the commands are always executed regardless of check mode or not.

Since there could be modifications in proxysql memory layer that have not been saved to disk prior to the playbook run, it could be unexpected that running the task in check mode would actually execute the SAVE TO DISK command, potentially modifying the system state.

I am wondering if this is the expected behavior in the module? If not, would you except a PR so that the LOAD TO/SAVE TO commands are not actually executed by proxysql_manage_config module check mode?

Thanks!

ISSUE TYPE
  • Bug Report
COMPONENT NAME

proxysql_manage_config

ANSIBLE VERSION
ansible 2.10.10
  config file = /xxxxx/etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /data/ansible_2.10.6_venv/lib/python3.6/site-packages/ansible
  executable location = /data/ansible_2.10.6_venv/bin/ansible
  python version = 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
COLLECTION VERSION
ansible-galaxy collection list community.proxysql

# /data/ansible_2.10.6_venv/lib/python3.6/site-packages/ansible_collections
Collection         Version
------------------ -------
community.proxysql 1.0.0  

# /home/xxxxxx/git/ansible/collections/ansible_collections
Collection         Version
------------------ -------
community.proxysql 1.3.2 
CONFIGURATION
ansible-config dump --only-changed
ANSIBLE_NOCOWS(/home/xxxxxxx/git/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/home/xxxxxxx/git/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/xxxxxxx/git/ansible/ansible.cfg) = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=120s
COLLECTIONS_PATHS(/home/xxxxxxx/git/ansible/ansible.cfg) = ['/home/xxxxxxx/git/ansible/collections']
DEFAULT_CALLBACK_PLUGIN_PATH(/home/xxxxxxx/git/ansible/ansible.cfg) = ['/home/xxxxxxx/git/ansible/custom_callback_plugins']
DEFAULT_FORKS(/home/xxxxxxx/git/ansible/ansible.cfg) = 20
DEFAULT_HOST_LIST(/home/xxxxxxx/git/ansible/ansible.cfg) = ['/home/xxxxxxx/git/ansible/hosts']
DEFAULT_MANAGED_STR(/home/xxxxxxx/git/ansible/ansible.cfg) = Ansible managed file, do not edit directly
DEFAULT_PRIVATE_KEY_FILE(/home/xxxxxxx/git/ansible/ansible.cfg) = /home/xxxxxxx/.ssh/xxxxxxx_ansible_bot_id_rsa
DEFAULT_REMOTE_PORT(/home/xxxxxxx/git/ansible/ansible.cfg) = 22
DEFAULT_REMOTE_USER(/home/xxxxxxx/git/ansible/ansible.cfg) = xxxxxxx_ansible_bot
DEFAULT_ROLES_PATH(/home/xxxxxxx/git/ansible/ansible.cfg) = ['/home/xxxxxxx/git/ansible/roles', '/home/xxxxxxx/git/ansible/roles/external']
DEFAULT_VAULT_IDENTITY_LIST(env: ANSIBLE_VAULT_IDENTITY_LIST) = ['xxxxxx']
DEFAULT_VAULT_ID_MATCH(/home/xxxxxxx/git/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/home/xxxxxxx/git/ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/xxxxxxx/git/ansible/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/home/xxxxxxx/git/ansible/ansible.cfg) = ignore
OS / ENVIRONMENT
STEPS TO REPRODUCE

ansible-playbook ./test.yml --check

# test.yml
- hosts: proxysql
  gather_facts: false
  tasks:
    - name: Save mysql servers to disk
      proxysql_manage_config:
        login_user: "{{ proxysql_login_user }}"
        login_password: "{{ proxysql_login_password }}"
        config_settings: "MYSQL SERVERS"
        action: SAVE
        direction: TO
        config_layer: DISK

And when we run in check mode we see this written to proxysql log.

2023-01-06 07:19:28 [INFO] Received SAVE MYSQL SERVERS TO DISK command
EXPECTED RESULTS

SAVE MYSQL SERVERS TO DISK command is not executed when --check is used

ACTUAL RESULTS

we see this written to proxysql log.

2023-01-06 07:19:28 [INFO] Received SAVE MYSQL SERVERS TO DISK command

New Module: proxysql_galera_hostgroups

SUMMARY

Need to add a module to support changes to the proxysql_galera_hostgroups config, along with the associated integration tests.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME
  • proxysql_galera_hostgroups
ADDITIONAL INFORMATION
ProxySQL Table:
mysql> show create table mysql_galera_hostgroups\G
*************************** 1. row ***************************
       table: mysql_galera_hostgroups
Create Table: CREATE TABLE mysql_galera_hostgroups (
    writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY,
    backup_writer_hostgroup INT CHECK (backup_writer_hostgroup>=0 AND backup_writer_hostgroup<>writer_hostgroup) NOT NULL,
    reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND backup_writer_hostgroup<>reader_hostgroup AND reader_hostgroup>0),
    offline_hostgroup INT NOT NULL CHECK (offline_hostgroup<>writer_hostgroup AND offline_hostgroup<>reader_hostgroup AND backup_writer_hostgroup<>offline_hostgroup AND offline_hostgroup>=0),
    active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,
    max_writers INT NOT NULL CHECK (max_writers >= 0) DEFAULT 1,
    writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1,2)) NOT NULL DEFAULT 0,
    max_transactions_behind INT CHECK (max_transactions_behind>=0) NOT NULL DEFAULT 0,
    comment VARCHAR,
    UNIQUE (reader_hostgroup),
    UNIQUE (offline_hostgroup),
    UNIQUE (backup_writer_hostgroup))

Example usage:
- name: proxysql | config | add galera hostgroups
  proxysql_galera_hostgroups:
    login_user: 'admin'
    login_password: 'admin'
    writer_hostgroup: 1
    reader_hostgroup: 2
    state: present

refactor perform_checks function

currenty perform_checks function is included in every module

 grep -rn "def perform_checks" plugins/*
plugins/modules/proxysql_replication_hostgroups.py:108:def perform_checks(module):
plugins/modules/proxysql_info.py:64:def perform_checks(module):
plugins/modules/proxysql_query_rules.py:324:def perform_checks(module):
plugins/modules/proxysql_mysql_users.py:173:def perform_checks(module):
plugins/modules/proxysql_manage_config.py:109:def perform_checks(module):
plugins/modules/proxysql_scheduler.py:147:def perform_checks(module):
plugins/modules/proxysql_query_rules_fast_routing.py:119:def perform_checks(module):
plugins/modules/proxysql_backend_servers.py:171:def perform_checks(module):
plugins/modules/proxysql_global_variables.py:84:def perform_checks(module):

this must be refactored. it can be included in plugins/module_utils/mysql.py in the mysql_connect function.

Important information for collection maintainers

SUMMARY

Dear maintainers,

This is important for your collections!

  • In accordance with the Community decision, we have created the news-for-maintainers repository for announcements of changes impacting collection maintainers (see the examples) instead of Issue 45 that will be closed soon.

    • To keep yourself well-informed and, therefore, things in your collection working, please subscribe to the repository by using the Watch button in the upper right corner on the repository's home page.
    • If you do not want to get notifications about related discussions, please subscribe only to Issues.
    • Please read the brief guidelines on how the repository should be used.
    • Please avoid unnecessary discussions in issues, use the Discussions feature. Every comment posted will notify a lot of folks!
  • Also we would like to remind you about the Bullhorn contributor newsletter which has recently started to be released weekly. To learn what it looks like, see the past releases. Please subscribe and talk to the Community via Bullhorn!

  • Join us in #ansible-social (for news reporting & chat), #ansible-community (for discussing collection & maintainer topics), and other channels on Matrix/IRC.

  • Help the Community and the Steering Committee to make right decisions by taking part in discussing and voting on the Community Topics that impact the whole project and the collections in particular. Your opinion there will be much appreciated!

Thank you!

proxysql_mysql_users is not able to handle hashed passwords

SUMMARY

proxysql_mysql_users handles passwords only in plaintext.
Once MYSQL USERS is loaded to runtime, proxysql is hashing the passwords automatically. That means:

  • mysql_servers table holds passwords in plaintext
  • runtime_mysql_servers table holds passwords hashed.

When you now load MYSQL USERS from runtime, and save them to disk, mysql_servers holds the user passwords also hashed. But after that, proxysql_mysql_users is not able to handle this anymore and is trying to create a new user. This results in errors because of table constraints.

example: (here is a full playbook example)

    - name: add user to proxysql
      proxysql_mysql_users:
        state: present
        username: someuser
        password: password
        default_hostgroup: 0
        login_user: admin
        login_password: admin
        load_to_runtime: yes

    - name: idempotent add user to proxysql
      proxysql_mysql_users:
        state: present
        username: someuser
        password: password
        default_hostgroup: 0
        login_user: admin
        login_password: admin
        load_to_runtime: yes

    - name: load users back to memory because they are hashed in runtime
      proxysql_manage_config:
        login_user: admin
        login_password: admin
        action: "SAVE"
        config_settings: MYSQL USERS
        direction: "FROM"
        config_layer: "RUNTIME"

    - name: save hashed users also to disk
      proxysql_manage_config:
        login_user: admin
        login_password: admin
        action: "SAVE"
        config_settings: MYSQL USERS
        direction: "TO"
        config_layer: "DISK"

    - name: idempotent add user to proxysql
      proxysql_mysql_users:
        state: present
        username: someuser
        password: password
        default_hostgroup: 0
        login_user: admin
        login_password: admin
        load_to_runtime: yes

Result

TASK [add user to proxysql] *********************************************************************************************************************************************************************************************************
[WARNING]: Module did not set no_log for encrypt_********
changed: [proxysql]

TASK [idempotent add user to proxysql] **********************************************************************************************************************************************************************************************
ok: [proxysql]

TASK [load users back to runtime because they are hashed in runtime] ****************************************************************************************************************************************************************
changed: [proxysql]

TASK [save hashed users also to disk] ***********************************************************************************************************************************************************************************************
changed: [proxysql]

TASK [idempotent add user to proxysql] **********************************************************************************************************************************************************************************************
fatal: [proxysql]: FAILED! => {"changed": false, "msg": "unable to modify user.. (1045, 'ProxySQL Admin Error: UNIQUE constraint failed: mysql_users.username, mysql_users.frontend')"}

References:

select password('some-password') as password; function is not available in proxysql.
therefore the hash-creation must be implemented within python.

maybe we need a new parameter to control if a password should be hashed or not ...

ISSUE TYPE
  • Bug Report
COMPONENT NAME

proxysql_mysql_users

Inclusion of community.proxysql in Ansible 2.10

This collection will be included in Ansible 2.10 because it contains modules and/or plugins that were included in Ansible 2.9. Please review:

DEADLINE: 2020-08-18

The latest version of the collection available on August 18 will be included in Ansible 2.10.0, except possibly newer versions which differ only in the patch level. (For details, see the roadmap). Please release version 1.0.0 of your collection by this date! If 1.0.0 does not exist, the same 0.x.y version will be used in all of Ansible 2.10 without updates, and your 1.x.y release will not be included until Ansible 2.11 (unless you request an exception at a community working group meeting and go through a demanding manual process to vouch for backwards compatibility . . . you want to avoid this!).

Follow semantic versioning rules

Your collection versioning must follow all semver rules. This means:

  • Patch level releases can only contain bugfixes;
  • Minor releases can contain new features, new modules and plugins, and bugfixes, but must not break backwards compatibility;
  • Major releases can break backwards compatibility.

Changelogs and Porting Guide

Your collection should provide data for the Ansible 2.10 changelog and porting guide. The changelog and porting guide are automatically generated from ansible-base, and from the changelogs of the included collections. All changes from the breaking_changes, major_changes, removed_features and deprecated_features sections will appear in both the changelog and the porting guide. You have two options for providing changelog fragments to include:

  1. If possible, use the antsibull-changelog tool, which uses the same changelog fragment as the ansible/ansible repository (see the documentation).
  2. If you cannot use antsibull-changelog, you can provide the changelog in a machine-readable format as changelogs/changelog.yaml inside your collection (see the documentation of changelogs/changelog.yaml format).

If you cannot contribute to the integrated Ansible changelog using one of these methods, please provide a link to your collection's changelog by creating an issue in https://github.com/ansible-community/ansible-build-data/. If you do not provide changelogs/changelog.yml or a link, users will not be able to find out what changed in your collection from the Ansible changelog and porting guide.

Make sure your collection passes the sanity tests

Run ansible-test sanity --docker -v in the collection with the latest ansible-base or stable-2.10 ansible/ansible checkout.

Keep informed

Be sure you're subscribed to:

Questions and Feedback

If you have questions or want to provide feedback, please see the Feedback section in the collection requirements.

(Internal link to keep track of issues: ansible-collections/overview#102)

Release plan

SUMMARY

SUMMARY
(partially copied from ansible-collections/community.crypto#74 , thanks to @felixfontein)

We should decide eventually on how to release this collection (w.r.t. versioning).
Small collections like this one don't need a complex plan like the one for community.general and community.network.
So how about the following?

Release minor and patch releases whenever we want (like after adding new features or fixing bugs). Since this collection is small, there's no need to fix things in advance. Just add features, and after a feature either wait a bit longer for more features/bugs, or make a release.
I suggest releasing without branching https://github.com/ansible/community-docs/blob/main/releasing_collections_without_release_branches.rst
Breaking changes don't work with this schema but we might change the approach and start releasing from branches when needed.

cc @bmildren

Feature: Add an ability to specify which check type to do when defining the replication hostgroups using proxysql_replication_hostgroups module

SUMMARY

It would be great to be able to specify which check_type to use when adding the pair via proxysql_replication_hostgroups ansible module.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME
  • proxysql_replication_hostgroups
ADDITIONAL INFORMATION

Currently we rely only at the default check type value which is read_only, but there are many other values available:

  • 'read_only'
  • 'innodb_read_only'
  • 'super_read_only'
  • 'read_only|innodb_read_only'
  • 'read_only&innodb_read_only'

Saying, I use super_read_only so not able to fully automate proxysql setup with ansible.

Install role need some maintenance

Futhermore the role runs in sevaral errors on both, ubuntu 20.04 (focal) and 18.04 (bionic)

---
- hosts: localhost
  become: yes
  roles:
    - proxysql

bump version

it depends on percona repository and 2.0.10 is not available anymore.

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failure downloading https://github.com/sysown/proxysql/releases/download/v2.0.10/proxysql_2.0.10-ubuntu20_amd64.deb, HTTP Error 404: Not Found"}

alternatively, fetch packages from releases https://github.com/sysown/proxysql ?

lack of permissions

somewhere a become: yes is missing

TASK [proxysql : proxysql | config | copy proxysql config] **********************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "checksum": "4695d525ec65790820423a3051bd8fb8e5419675", "msg": "Destination /etc not writable"}

undefined variables

there are three undefined variables using proxysql_version: 2.3.2

failed: [localhost] (item={'key': 'default_sql_mode', 'value': {'variable': 'default_sql_mode', 'variable_value': None}}) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "default_sql_mode", "value": {"variable": "default_sql_mode", "variable_value": null}}, "msg": "The variable \"mysql-default_sql_mode\" was not found"}
failed: [localhost] (item={'key': 'default_time_zone', 'value': {'variable': 'default_time_zone', 'variable_value': 'SYSTEM'}}) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "default_time_zone", "value": {"variable": "default_time_zone", "variable_value": "SYSTEM"}}, "msg": "The variable \"mysql-default_time_zone\" was not found"}
failed: [localhost] (item={'key': 'forward_autocommit', 'value': {'variable': 'forward_autocommit', 'variable_value': 'false'}}) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "forward_autocommit", "value": {"variable": "forward_autocommit", "variable_value": "false"}}, "msg": "The variable \"mysql-forward_autocommit\" was not found"}

proposal to become a maintainer

#39

In the past I've contributed already many modules, features, bugs and bug-fixes to ansible and different collections. I'm become also a maintainer for comminuty.aws.

Since I'm familiar with proxysql and use it in production, I would like to answer the request for maintainers and contributors and be available as a maintainer for the proxysql collection.

CI maintenance

This version of ansible-test cannot be executed with Python version 3.8.13. Supported Python versions are: 3.9, 3.10, 3.11

New Module: proxysql_query_rules_fast_routing

SUMMARY

Need to add a module to support changes to the proxysql_query_rules_fast_routing config, along with the associated integration tests.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME
  • proxysql_query_rules_fast_routing
ADDITIONAL INFORMATION
ProxySQL Table:
mysql> show create table mysql_query_rules_fast_routing\G
*************************** 1. row ***************************
       table: mysql_query_rules_fast_routing
Create Table: CREATE TABLE mysql_query_rules_fast_routing (
    username VARCHAR NOT NULL,
    schemaname VARCHAR NOT NULL,
    flagIN INT NOT NULL DEFAULT 0,
    destination_hostgroup INT CHECK (destination_hostgroup >= 0) NOT NULL,
    comment VARCHAR NOT NULL,
    PRIMARY KEY (username, schemaname, flagIN) )

Example usage:
- name: proxysql | config | add fast routing rule
  proxysql_query_rules_fast_routing:
    username: 'productiondba'
    schemaname: 'mydb'
    destination_hostgroup: 1
    state: present

Not all proxysql installd have a version() suffix

SUMMARY

The proxysql version() suffix isn't standard, but plugins/module_utils/mysql.py expects it to exist. ie;

def _version(cursor):
    cursor.execute("select version();")
    res = cursor.fetchone()

    # 2.2.0-72-ge14accd
    # 2.3.2-percona-1.1
    raw_version = res.get('version()').split('-', 1)
    _version = raw_version[0].split('.')

    version = dict()
    version['full'] = res.get('version()')
    version['major'] = int(_version[0])
    version['minor'] = int(_version[1])
    version['release'] = int(_version[2])
    version['suffix'] = raw_version[1]

If no suffix exists, this results in an exception

ISSUE TYPE
  • Bug Report
COMPONENT NAME

plugins/module_utils/mysql.py

ANSIBLE VERSION
ansible [core 2.14.0]
  config file = /home/gbyers/work/git/a4-ansible/ansible.cfg
  configured module search path = ['/home/gbyers/work/git/a4-ansible/modules', '/home/gbyers/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/gbyers/venv/ansible2.14/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/gbyers/work/git/a4-ansible/collections:/home/gbyers/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/gbyers/venv/ansible2.14/bin/ansible
  python version = 3.11.5 (main, Sep 22 2023, 15:34:29) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/home/gbyers/venv/ansible2.14/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True

COLLECTION VERSION

# /home/xxxx/work/git/a4-ansible/collections/ansible_collections
Collection         Version
------------------ -------
community.proxysql 1.5.1  

CONFIGURATION
CALLBACKS_ENABLED(env: ANSIBLE_CALLBACKS_ENABLED) = ['default']
COLLECTIONS_PATHS(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/collections', '/home/xxxx/.ansible/collections', '/usr/share/ansible/collections']
COLOR_VERBOSE(/home/xxxx/work/git/a4-ansible/ansible.cfg) = dark gray
CONFIG_FILE() = /home/xxxx/work/git/a4-ansible/ansible.cfg
DEFAULT_ACTION_PLUGIN_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/plugins/action', '/usr/share/ansible/plugins/action']
DEFAULT_ASK_PASS(/home/xxxx/work/git/a4-ansible/ansible.cfg) = True
DEFAULT_BECOME(/home/xxxx/work/git/a4-ansible/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/home/xxxx/work/git/a4-ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/home/xxxx/work/git/a4-ansible/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/home/xxxx/work/git/a4-ansible/ansible.cfg) = root
DEFAULT_CONNECTION_PLUGIN_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/plugins/connection', '/usr/share/ansible/plugins/connection']
DEFAULT_FILTER_PLUGIN_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/plugins/filter', '/usr/share/ansible/plugins/filter']
DEFAULT_LOOKUP_PLUGIN_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/plugins/lookup', '/usr/share/ansible/plugins/lookup']
DEFAULT_MANAGED_STR(/home/xxxx/work/git/a4-ansible/ansible.cfg) = This file is Ansible managed from role: {{{{ ansible_role_name }}}}
DEFAULT_MODULE_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/modules', '/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
DEFAULT_ROLES_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/roles', '/home/xxxx/.ansible/roles', '/usr/share/ansible/roles', '/etc/ansible/roles']
DEFAULT_STRATEGY(env: ANSIBLE_STRATEGY) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(env: ANSIBLE_STRATEGY_PLUGINS) = ['/home/xxxx/.local/share/ansible/mitogen-0.3.4.dev0/ansible_mitogen/plugins/strategy']
DEFAULT_TEST_PLUGIN_PATH(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['/home/xxxx/work/git/a4-ansible/plugins/test', '/usr/share/ansible/plugins/test']
GALAXY_ROLE_SKELETON(/home/xxxx/work/git/a4-ansible/ansible.cfg) = /home/xxxx/work/git/a4-ansible/roles/skel
GALAXY_ROLE_SKELETON_IGNORE(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['^.git$', '^.*/.git_keep$']
GALAXY_SERVER_LIST(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['galaxy', 'automation_hub']
HOST_KEY_CHECKING(/home/xxxx/work/git/a4-ansible/ansible.cfg) = False
INVENTORY_ENABLED(/home/xxxx/work/git/a4-ansible/ansible.cfg) = ['advanced_host_list', 'host_list', 'constructed', 'generator', 'ini', 'auto', 'yaml']
MAX_FILE_SIZE_FOR_DIFF(/home/xxxx/work/git/a4-ansible/ansible.cfg) = 150000
PERSISTENT_CONNECT_TIMEOUT(/home/xxxx/work/git/a4-ansible/ansible.cfg) = 30

OS / ENVIRONMENT

RHEL9

STEPS TO REPRODUCE

Install proxysql on a rhel9 (rocky9, alma9) system from the epel repo & attempt to use the community.proxysql.proxysql role to manage config.

    - hosts: servers
      tasks:
        - name: Import the proxysql role
          ansible.builtin.import_role:
            name: community.proxysql.proxysql
          tags:
            - proxysql
EXPECTED RESULTS

proxysql modules run to completion.

ACTUAL RESULTS

Using any of the modules that rely on community/proxysql/plugins/module_utils/mysql.py result in the following exception;

Traceback (most recent call last):
  File "<stdin>", line 107, in <module>
  File "<stdin>", line 99, in _ansiballz_main
  File "<stdin>", line 47, in invoke_module
  File "/usr/lib64/python3.9/runpy.py", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_2f6jvovi/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/modules/proxysql_backend_servers.py", line 503, in <module>
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_2f6jvovi/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/modules/proxysql_backend_servers.py", line 445, in main
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_2f6jvovi/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/module_utils/mysql.py", line 124, in mysql_connect
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_2f6jvovi/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/module_utils/mysql.py", line 57, in _version
IndexError: list index out of range

proxysql_mysql_query_rules becomes incompatible with 1.4.x since 1.1.0

SUMMARY

community.proxysql 1.1.0 introduced cache_empty_result parameter.
However, this column does not exist in proxysql < 2.0.0. Therefore the module will always fail atm.

1.4.15 schema

CREATE TABLE mysql_query_rules (
    rule_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 0,
    username VARCHAR,
    schemaname VARCHAR,
    flagIN INT NOT NULL DEFAULT 0,
    client_addr VARCHAR,
    proxy_addr VARCHAR,
    proxy_port INT,
    digest VARCHAR,
    match_digest VARCHAR,
    match_pattern VARCHAR,
    negate_match_pattern INT CHECK (negate_match_pattern IN (0,1)) NOT NULL DEFAULT 0,
    re_modifiers VARCHAR DEFAULT 'CASELESS',
    flagOUT INT,
    replace_pattern VARCHAR,
    destination_hostgroup INT DEFAULT NULL,
    cache_ttl INT CHECK(cache_ttl > 0),
    reconnect INT CHECK (reconnect IN (0,1)) DEFAULT NULL,
    timeout INT UNSIGNED,
    retries INT CHECK (retries>=0 AND retries <=1000),
    delay INT UNSIGNED,
    next_query_flagIN INT UNSIGNED,
    mirror_flagOUT INT UNSIGNED,
    mirror_hostgroup INT UNSIGNED,
    error_msg VARCHAR,
    OK_msg VARCHAR,
    sticky_conn INT CHECK (sticky_conn IN (0,1)),
    multiplex INT CHECK (multiplex IN (0,1,2)),
    log INT CHECK (log IN (0,1)),
    apply INT CHECK(apply IN (0,1)) NOT NULL DEFAULT 0,
    comment VARCHAR)

2.2.0 schema

CREATE TABLE mysql_query_rules (
    rule_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 0,
    username VARCHAR,
    schemaname VARCHAR,
    flagIN INT CHECK (flagIN >= 0) NOT NULL DEFAULT 0,
    client_addr VARCHAR,
    proxy_addr VARCHAR,
    proxy_port INT CHECK (proxy_port >= 0 AND proxy_port <= 65535),
    digest VARCHAR,
    match_digest VARCHAR,
    match_pattern VARCHAR,
    negate_match_pattern INT CHECK (negate_match_pattern IN (0,1)) NOT NULL DEFAULT 0,
    re_modifiers VARCHAR DEFAULT 'CASELESS',
    flagOUT INT CHECK (flagOUT >= 0),
    replace_pattern VARCHAR CHECK(CASE WHEN replace_pattern IS NULL THEN 1 WHEN replace_pattern IS NOT NULL AND match_pattern IS NOT NULL THEN 1 ELSE 0 END),
    destination_hostgroup INT DEFAULT NULL,
    cache_ttl INT CHECK(cache_ttl > 0),
    cache_empty_result INT CHECK (cache_empty_result IN (0,1)) DEFAULT NULL,
    cache_timeout INT CHECK(cache_timeout >= 0),
    reconnect INT CHECK (reconnect IN (0,1)) DEFAULT NULL,
    timeout INT UNSIGNED CHECK (timeout >= 0),
    retries INT CHECK (retries>=0 AND retries <=1000),
    delay INT UNSIGNED CHECK (delay >=0),
    next_query_flagIN INT UNSIGNED,
    mirror_flagOUT INT UNSIGNED,
    mirror_hostgroup INT UNSIGNED,
    error_msg VARCHAR,
    OK_msg VARCHAR,
    sticky_conn INT CHECK (sticky_conn IN (0,1)),
    multiplex INT CHECK (multiplex IN (0,1,2)),
    gtid_from_hostgroup INT UNSIGNED,
    log INT CHECK (log IN (0,1)),
    apply INT CHECK(apply IN (0,1)) NOT NULL DEFAULT 0,
    attributes VARCHAR CHECK (JSON_VALID(attributes) OR attributes = '') NOT NULL DEFAULT '',
    comment VARCHAR)
ISSUE TYPE
  • Bug Report
COMPONENT NAME

proxysql_mysql_query_rules

Schedule module: creating an excess task

SUMMARY

Hi there. As you can see, I have only one scheduled task in the playbook and I just wanted to turn it off. Instead of updating an existing task, the module created a new one. This, unfortunately, does not have the effect that would be expected from disabling, because the old job still exists.

Also, if I want to change, for example, the interval for a task, the module will simply create a new one, thus generating exactly the same task and now it will be executed even more often.

The task I'm running:

- name: proxysql - configure scheduler
  proxysql_scheduler:
    login_user: "{{ proxysql.admin.user }}"
    login_password: "{{ proxysql.admin.password }}"
    login_port: "{{ proxysql.admin.listen.port.plain | int }}"
    filename: "{{ proxysql.path.lib }}/{{ item.bin }}"
    interval_ms: "{{ item.interval }}"
    arg1: "{{ item.arg1 | default('NULL') }}"
    arg2: "{{ item.arg2 | default('NULL') }}"
    arg3: "{{ item.arg3 | default('NULL') }}"
    arg4: "{{ item.arg4 | default('NULL') }}"
    arg5: "{{ item.arg5 | default('NULL') }}"
    state: present
    active: no
    load_to_runtime: true
    save_to_disk: true
  with_items:
    - bin: replica_check
      interval: 5000  # 5s
      arg1: "127.0.0.1"
      arg2: "{{ proxysql.admin.listen.port.plain }}"
      arg3: "{{ proxysql_replication_hostgroups.product.reader_hostgroup }}"
      arg4: warning
      arg5: "{{ proxysql.path.log }}/replica_check.log"
  tags:
    - proxysql-external-checks

Task result:

TASK [service/proxysql : proxysql - configure scheduler] ********************************************************************************************************************************************
changed: [HIDDEN SERVER NAME] => (item={'bin': 'replica_check', 'interval': 5000, 'arg1': '127.0.0.1', 'arg2': '7030', 'arg3': '2', 'arg4': 'warning', 'arg5': '/opt/log/proxysql/replica_check.log'})

Scheduler table from ProxySQL:

ProxySQL> select * from scheduler;
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| id | active | interval_ms | filename                        | arg1      | arg2 | arg3 | arg4    | arg5                                | comment |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
| 1  | 1      | 5000        | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2    | warning | /opt/log/proxysql/replica_check.log |         |
| 2  | 0      | 5000        | /opt/lib/proxysql/replica_check | 127.0.0.1 | 7030 | 2    | warning | /opt/log/proxysql/replica_check.log |         |
+----+--------+-------------+---------------------------------+-----------+------+------+---------+-------------------------------------+---------+
ISSUE TYPE
  • Bug Report
COMPONENT NAME

proxysql_scheduler

ANSIBLE VERSION
$ ansible --version
ansible 2.9.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/Users/akimrx/<HIDDEN>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/akimrx/<HIDDEN>/ansible/venv/lib/python3.7/site-packages/ansible
  executable location = /Users/akimrx/<HIDDEN>/ansible/venv/bin/ansible
  python version = 3.7.6 (default, Mar 29 2021, 14:13:20) [Clang 11.0.3 (clang-1103.0.32.62)]
CONFIGURATION
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/etc/ansible/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=60s -o PreferredAuthentications=publickey
COLOR_CHANGED(/etc/ansible/ansible.cfg) = bright blue
COLOR_ERROR(/etc/ansible/ansible.cfg) = bright red
COLOR_HIGHLIGHT(/etc/ansible/ansible.cfg) = white
COLOR_VERBOSE(/etc/ansible/ansible.cfg) = dark gray
COLOR_WARN(/etc/ansible/ansible.cfg) = bright purple
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 30
DEFAULT_GATHER_SUBSET(/etc/ansible/ansible.cfg) = ['all', '!facter', '!ohai']
DEFAULT_MANAGED_STR(/etc/ansible/ansible.cfg) = This file is managed by ansible, don't make changes here - they will be overwritten.
DEFAULT_POLL_INTERVAL(/etc/ansible/ansible.cfg) = 1
DEFAULT_PRIVATE_KEY_FILE(/etc/ansible/ansible.cfg) = /Users/akimrx/.ssh/id_rsa
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = root
DEFAULT_ROLES_PATH(env: ANSIBLE_ROLES_PATH) = ['/Users/akimrx/<HIDDEN>/playbooks/roles']
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = skippy
DEFAULT_TRANSPORT(/etc/ansible/ansible.cfg) = smart
DISPLAY_SKIPPED_HOSTS(/etc/ansible/ansible.cfg) = False
DUPLICATE_YAML_DICT_KEY(env: ANSIBLE_DUPLICATE_YAML_DICT_KEY) = ignore
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
INVENTORY_CACHE_ENABLED(/etc/ansible/ansible.cfg) = True
INVENTORY_CACHE_PLUGIN(/etc/ansible/ansible.cfg) = jsonfile
PLAYBOOK_DIR(env: ANSIBLE_PLAYBOOK_DIR) = /Users/akimrx/<HIDDEN>/ansible/playbooks
PLAYBOOK_VARS_ROOT(env: ANSIBLE_PLAYBOOK_VARS_ROOT) = all
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT
  • macOS Catalina 10.15.6
  • Darwin macbook-pro 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
RECOMMENDATIONS

I think it is necessary to add the id for the scheduled task. That is, just as it is done in the query rules module -- rule_id.
That is:

  proxysql_scheduler:
    ...
    id: 1  <--- This
    filename: "{{ proxysql.path.lib }}/{{ item.bin }}"
    interval_ms: "{{ item.interval }}"
    ...

Query rules: missing parameters

SUMMARY

New versions of Proxy SQL have added new parameters for query rules. One of the important parameters, at least for me and my company, are the following:

  • cache_empty_result
  • multiplex
  • sticky_conn - at the moment, this not implemented even though the field in the table exists. In future versions, this functionality will be relevant.
  • OK_msg

The full list can be found in the official documentation

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

Query Rules

proxysql_query_rules_fast_routing module can not update existed rules

SUMMARY

proxysql_query_rules_fast_routing module can not update destination_hostgroup of a rule.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

proxysql_query_rules_fast_routing

ANSIBLE VERSION
ansible [core 2.12.5]
  config file = /home/user/Workspace/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.pyenv/versions/3.10.1/envs/ansible/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.pyenv/versions/ansible/bin/ansible
  python version = 3.10.1 (main, Jan  5 2022, 13:00:07) [GCC 9.3.0]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
# /home/user/.pyenv/versions/3.10.1/envs/ansible/lib/python3.10/site-packages/ansible_collections
Collection         Version
------------------ -------
community.proxysql 1.3.2

# /home/user/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
community.proxysql 1.4.0
CONFIGURATION
OS / ENVIRONMENT

Ubuntu 20.04

STEPS TO REPRODUCE
  1. Config a proxysql instance with admin credential admin/admin.
  2. Run ansible-playbook proxysql.yml
# playbook proxysql.yml
- hosts: all
  vars:
    proxysql_admin_user: admin
    proxysql_admin_password: admin
    proxysql_admin_interface: "127.0.0.1"
    proxysql_admin_port: 6032

  tasks:
    - name: Create fast routing rules
      community.proxysql.proxysql_query_rules_fast_routing:
        # rule args
        username: user
        schemaname: test_database"
        destination_hostgroup: 1
        # auth args
        login_user: "{{ proxysql_admin_user }}"
        login_password: "{{ proxysql_admin_password }}"
        login_host: "{{ proxysql_admin_interface }}"
        login_port: "{{ proxysql_admin_port }}"
        state: present

    - name: Update fast routing rules
      community.proxysql.proxysql_query_rules_fast_routing:
        # rule args
        username: user
        schemaname: test_database"
        destination_hostgroup: 2
        # auth args
        login_user: "{{ proxysql_admin_user }}"
        login_password: "{{ proxysql_admin_password }}"
        login_host: "{{ proxysql_admin_interface }}"
        login_port: "{{ proxysql_admin_port }}"
        state: present
EXPECTED RESULTS
PLAY [proxysql] ***************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************
ok: [proxysql]

TASK [Create fast routing rules] **********************************************************************************
ok: [proxysql]

TASK [Update fast routing rules] **********************************************************************************
changed: [proxysql]

PLAY RECAP ********************************************************************************************************
proxysql                   : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 
ACTUAL RESULTS
PLAY [proxysql] ***************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************
ok: [proxysql]

TASK [Create fast routing rules] **********************************************************************************
ok: [proxysql]

TASK [Update fast routing rules] **********************************************************************************
fatal: [proxysql]: FAILED! => {"changed": false, "msg": "unable to modify rule: (1045, 'ProxySQL Admin Error: UNIQUE constraint failed: mysql_query_rules_fast_routing.username, mysql_query_rules_fast_routing.schemaname, mysql_query_rules_fast_routing.flagIN')"}

PLAY RECAP ********************************************************************************************************
proxysql                   : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 

Ansible Contributor Summit. Tuesday, April 12, 2022.

Ansible Contributor Summit

We are happy to announce that the registration for the Ansible Contributor Summit is open!

Why
  • This is a great opportunity for interested people to meet, discuss related topics, share their stories and opinions, get the latest important updates and just to hang out together.

  • There will be different announcements & presentations by Community, Core, Cloud, Network, and other teams.

  • Current contributors will be happy to share their stories and experience with newcomers.

  • There will be links to interactive self-passed instruqt scenarios shared during the event that help newcomers learn different aspects of development.

Where/when

Online on Matrix and Youtube. Tuesday, April 12, 2022, 12:00 - 20:00 UTC.

How to join
  • Add the event to your calendar. Use the ical URL (for example, in Google Calendar "Add other calendars" > "Import from URL") instead of importing the .ics file so that any updates to the event will be reflected in your calendar.

  • Check out the Summit page:

    • Add you name to attendees.
    • Suggest summit topics that would be interesting to you to hear about.
    • Vote on and propose changes to topics suggested by others.
    • If you want to be a presenter, please contact the Ansible Community team via [email protected].

We are looking forward to seeing you!:)

New Module: proxysql_aws_aurora_hostgroups

SUMMARY

Need to add a module to support changes to the mysql_aws_aurora_hostgroups config, along with the associated integration tests.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME
  • proxysql_aws_aurora_hostgroups
ADDITIONAL INFORMATION
ProxySQL Table:
mysql> show create table mysql_aws_aurora_hostgroups\G
*************************** 1. row ***************************
       table: mysql_aws_aurora_hostgroups
Create Table: CREATE TABLE mysql_aws_aurora_hostgroups (
    writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY,
    reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND reader_hostgroup>0),
    active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,
    aurora_port INT NOT NUlL DEFAULT 3306,
    domain_name VARCHAR NOT NULL CHECK (SUBSTR(domain_name,1,1) = '.'),
    max_lag_ms INT NOT NULL CHECK (max_lag_ms>= 10 AND max_lag_ms <= 600000) DEFAULT 600000,
    check_interval_ms INT NOT NULL CHECK (check_interval_ms >= 100 AND check_interval_ms <= 600000) DEFAULT 1000,
    check_timeout_ms INT NOT NULL CHECK (check_timeout_ms >= 80 AND check_timeout_ms <= 3000) DEFAULT 800,
    writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1)) NOT NULL DEFAULT 0,
    new_reader_weight INT CHECK (new_reader_weight >= 0 AND new_reader_weight <=10000000) NOT NULL DEFAULT 1,
    comment VARCHAR,
    UNIQUE (reader_hostgroup))

Example usage:
- name: proxysql | config | add aws aurora hostgroups
  proxysql_aws_aurora_hostgroups:
    login_user: 'admin'
    login_password: 'admin'
    writer_hostgroup: 1
    reader_hostgroup: 2
    state: present

We are looking for new maintainers and contributors

SUMMARY

Hi everyone!

This collection is a part of Ansible package and is looking for new maintainers and contributors.
To learn how to contribute to the collection and how to maintain it / become a maintainer, refer to the Contributing guidelines which also includes the Quick-start guide.

This collection is made by good people like you.
If you are interested in becoming a maintainer, feel free to create an issue in this repository!

mysql.py. suffix in _version may not be an integer value ==> error

SUMMARY

in mysql.py::_version suffix variable may not be an integer value
example: With Percona's proxysql :

mysql> select version();
+-------------------+
| version()         |
+-------------------+
| 2.3.2-percona-1.1 |
+-------------------+
1 row in set (0,00 sec)

In that case, suffix (raw_version[1]) is : 'percona'

Suffix should be a string value, and raw_version should have a maximum of 2 elements :
so suffix should be percona-1.1

I would suggest the following code :

def _version(cursor):
    cursor.execute("select version();")
    res = cursor.fetchone()

    # 2.2.0-72-ge14accd
    raw_version = res.get('version()').split('-',1)
    _version = raw_version[0].split('.')

    version = dict()
    version['full'] = res.get('version()')
    version['major'] = int(_version[0])
    version['minor'] = int(_version[1])
    version['release'] = int(_version[2])
    version['suffix'] = raw_version[1]

    return version

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql.py, line 56

ANSIBLE VERSION
ansible [core 2.11.8] 
  config file = /root/architecture_percona/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
# /usr/local/lib/python3.7/dist-packages/ansible_collections
Collection         Version
------------------ -------
community.proxysql 1.3.0  
CONFIGURATION
CACHE_PLUGIN(/root/architecture_percona/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/root/architecture_percona/ansible.cfg) = cache
DEFAULT_BECOME(/root/architecture_percona/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/root/architecture_percona/ansible.cfg) = False
DEFAULT_BECOME_METHOD(/root/architecture_percona/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/root/architecture_percona/ansible.cfg) = root
DEFAULT_CACHE_PLUGIN_PATH(/root/architecture_percona/ansible.cfg) = ['/usr/share/ansible/plugins/cache']
DEFAULT_GATHERING(/root/architecture_percona/ansible.cfg) = smart
DEFAULT_HOST_LIST(/root/architecture_percona/ansible.cfg) = ['/root/architecture_percona/hosts']
DEFAULT_PRIVATE_KEY_FILE(/root/architecture_percona/ansible.cfg) = /root/architecture_percona/rsa_ansible
DEFAULT_REMOTE_USER(/root/architecture_percona/ansible.cfg) = ansible
HOST_KEY_CHECKING(/root/architecture_percona/ansible.cfg) = False

OS / ENVIRONMENT
$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
STEPS TO REPRODUCE

In Percona's ProxySQL, the select version() command returns something like : 2.3.2-percona-1.1

- name: Ajout du noeud à la topologie proxysql (groupe readers)
  community.proxysql.proxysql_backend_servers:
    login_host: '{{clusterAlias}}'
    login_user: '{{ProxySQLAdmin}}'
    login_password: '{{ProxySQLAdminPass}}'
    hostname: '{{inventory_hostname}}'
    max_connections: 400
    max_replication_lag: 1
    status: ONLINE
    state: present
    load_to_runtime: True
    save_to_disk: True
EXPECTED RESULTS
ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/home/ansible/.ansible/tmp/ansible-tmp-1645102377.3971581-48503-277139286733265/AnsiballZ_proxysql_backend_servers.py", line 100, in <module>
    _ansiballz_main()
  File "/home/ansible/.ansible/tmp/ansible-tmp-1645102377.3971581-48503-277139286733265/AnsiballZ_proxysql_backend_servers.py", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/ansible/.ansible/tmp/ansible-tmp-1645102377.3971581-48503-277139286733265/AnsiballZ_proxysql_backend_servers.py", line 41, in invoke_module
    run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/modules/proxysql_backend_servers.py", line 511, in <module>
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/modules/proxysql_backend_servers.py", line 457, in main
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/module_utils/mysql.py", line 123, in mysql_connect
  File "/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/module_utils/mysql.py", line 56, in _version
ValueError: invalid literal for int() with base 10: 'percona'
fatal: [mysql8-test]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to mysql8-test closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1645102377.3971581-48503-277139286733265/AnsiballZ_proxysql_backend_servers.py\", line 100, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1645102377.3971581-48503-277139286733265/AnsiballZ_proxysql_backend_servers.py\", line 92, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1645102377.3971581-48503-277139286733265/AnsiballZ_proxysql_backend_servers.py\", line 41, in invoke_module\r\n    run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/modules/proxysql_backend_servers.py\", line 511, in <module>\r\n  File \"/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/modules/proxysql_backend_servers.py\", line 457, in main\r\n  File \"/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/module_utils/mysql.py\", line 123, in mysql_connect\r\n  File \"/tmp/ansible_community.proxysql.proxysql_backend_servers_payload_5zn4mrte/ansible_community.proxysql.proxysql_backend_servers_payload.zip/ansible_collections/community/proxysql/plugins/module_utils/mysql.py\", line 56, in _version\r\nValueError: invalid literal for int() with base 10: 'percona'\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Release 2.0.0 plan

Status: Draft

Next release will be 2.0.0

  • It will drop ubuntu xenial support for the installation role, because it is EOL
  • rework of the schedule task module
    • the current absent logic will be marked as deprecated and removed with 3.0.0
    • #23 (comment)
  • deprecation warnings for proxysql 1.x?

Summary of deprecations in 2.0.0 for 3.0.0

  • current absent logic in schedule_task module
  • Support for Proxysql 1.x.x

Hopefully end of february :)

cc @Andersson007

Consider using true/false for all booleans in docs

Based on the community decision to use true/false for boolean values in documentation and examples, we ask that you evaluate booleans in this collection and consider changing any that do not use true/false (lowercase).

See documentation block format for more info (specifically, option defaults).

If you have already implemented this or decide not to, feel free to close this issue.


P.S. This is auto-generated issue, please raise any concerns here

New Module: proxysql_group_replication_hostgroups

SUMMARY

Need to add a module to support changes to the proxysql_group_replication_hostgroups config, along with the associated integration tests.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME
  • proxysql_group_replication_hostgroups
ADDITIONAL INFORMATION
ProxySQL Table:
mysql> show create table mysql_group_replication_hostgroups\G
*************************** 1. row ***************************
       table: mysql_group_replication_hostgroups
Create Table: CREATE TABLE mysql_group_replication_hostgroups (
    writer_hostgroup INT CHECK (writer_hostgroup>=0) NOT NULL PRIMARY KEY,
    backup_writer_hostgroup INT CHECK (backup_writer_hostgroup>=0 AND backup_writer_hostgroup<>writer_hostgroup) NOT NULL,
    reader_hostgroup INT NOT NULL CHECK (reader_hostgroup<>writer_hostgroup AND backup_writer_hostgroup<>reader_hostgroup AND reader_hostgroup>0),
    offline_hostgroup INT NOT NULL CHECK (offline_hostgroup<>writer_hostgroup AND offline_hostgroup<>reader_hostgroup AND backup_writer_hostgroup<>offline_hostgroup AND offline_hostgroup>=0),
    active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,
    max_writers INT NOT NULL CHECK (max_writers >= 0) DEFAULT 1,
    writer_is_also_reader INT CHECK (writer_is_also_reader IN (0,1,2)) NOT NULL DEFAULT 0,
    max_transactions_behind INT CHECK (max_transactions_behind>=0) NOT NULL DEFAULT 0,
    comment VARCHAR,
    UNIQUE (reader_hostgroup),
    UNIQUE (offline_hostgroup),
    UNIQUE (backup_writer_hostgroup))

Example usage:
- name: proxysql | config | add mysql group replication hostgroups
  proxysql_group_replication_hostgroups:
    login_user: 'admin'
    login_password: 'admin'
    writer_hostgroup: 1
    reader_hostgroup: 2
    state: present

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.