Skip to content

Commit

Permalink
* Updating Ansible version to 2.7.9
Browse files Browse the repository at this point in the history
* Minimal version for this role is now Ansible 2.7.9
  • Loading branch information
timorunge committed Mar 29, 2019
1 parent 1983cba commit 1dabc09
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 62 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

Currently this role is not compatible with ProxySQL v2.0.1.

This role is not compatible with Ansible 2.7.1 or higher due to a bug in the
This role is just compatible with Ansible 2.7.9 or higher due to a bug in the
migration from MySQLdb to PyMySQL
([#40123](https://github.com/ansible/ansible/pull/40123)) in the MySQL module
utils.

I've submitted a PR
([#47809](https://github.com/ansible/ansible/pull/47809)) to fix this issue.
Release 0.3.0 is compatible with Ansible 2.7.0 or lower.

---

Expand Down Expand Up @@ -45,7 +44,7 @@ or higher.
You can simply use pip to install (and define) a stable version:

```sh
pip install ansible==2.7.0
pip install ansible==2.7.9
```

All platform requirements are listed in the metadata file.
Expand Down Expand Up @@ -844,15 +843,15 @@ Tests are done with [Docker](https://www.docker.com) and
brings up the following containers with different environment settings:

- CentOS 7
- Debian 8.10 (Jessie)
- Debian 9.4 (Stretch)
- Debian 8 (Jessie)
- Debian 9 (Stretch)
- Ubuntu 14.04 (Trusty Tahr)
- Ubuntu 16.04 (Xenial Xerus)
- Ubuntu 17.10 (Artful Aardvark)
- Ubuntu 18.04 (Bionic Beaver)
- Ubuntu 18.10 (Cosmic Cuttlefish)

Ansible 2.7.0 is installed on all containers and a
Ansible 2.7.9 is installed on all containers and a
[test playbook](tests/test.yml) is getting applied.

For further details and additional checks take a look at the
Expand All @@ -863,14 +862,15 @@ An high level overview can be found in the following table:
| Distribution | Version | Official repository | Percona repository | Package |
|--------------|---------|---------------------|--------------------|---------|
| CentOS | 7 | yes | no | 1.4.14 |
| Debian | 8.10 | yes | yes | 1.4.14 |
| Debian | 9.4 | yes | yes | 1.4.14 |
| Debian | 8 | yes | yes | 1.4.14 |
| Debian | 9 | yes | yes | 1.4.14 |
| Ubuntu | 14.04 | yes | yes | 1.4.14 |
| Ubuntu | 16.04 | yes | yes | 1.4.14 |
| Ubuntu | 17.10 | no | yes | 1.4.14 |
| Ubuntu | 18.04 | no | yes | 1.4.14 |
| Ubuntu | 18.10 | no | yes | 1.4.14 |


```sh
# Testing locally:
curl https://raw.githubusercontent.com/timorunge/docker-test-runner/master/install.sh | sh
Expand All @@ -881,8 +881,8 @@ Since the build time on Travis is limited for public repositories the
automated tests are limited to:

- CentOS 7
- Debian 8.10 (Jessie)
- Debian 9.4 (Stretch)
- Debian 8 (Jessie)
- Debian 9 (Stretch)
- Ubuntu 16.04 (Xenial Xerus)
- Ubuntu 18.04 (Bionic Beaver)

Expand Down
65 changes: 27 additions & 38 deletions library/proxysql_proxysql_servers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
Expand All @@ -9,27 +8,26 @@
DOCUMENTATION = '''
---
module: proxysql_proxysql_servers
version_added: "2.5"
author: "Timo Runge (@timorunge)"
short_description: Adds or removes proxysql hosts from proxysql admin interface.
short_description: Adds or removes ProxySQL hosts from ProxySQL admin interface.
description:
- The M(proxysql_proxysql_servers) module adds or removes proxysql hosts using
the proxysql admin interface.
- The M(proxysql_proxysql_servers) module adds or removes ProxySQL hosts using
the ProxySQL admin interface.
options:
hostname:
description:
- The ip address at which the proxysql instance can be contacted.
- The ip address at which the ProxySQL instance can be contacted.
required: True
port:
description:
- The port at which the proxysql instance can be contacted.
- The port at which the ProxySQL instance can be contacted.
default: 6032
weight:
description:
- Currently unused, but in the roadmap for future enhancements.
The bigger the weight of a server relative to other weights, the higher
the probability of the server being chosen from the hostgroup. If
omitted the proxysql database default for I(weight) is 0.
omitted the ProxySQL database default for I(weight) is 0.
comment:
description:
- Text field that can be used for any purposed defined by the user.
Expand All @@ -48,32 +46,32 @@

EXAMPLES = '''
---
# This example adds a server, it saves the proxysql server config to disk, but
# avoids loading the proxysql server config to runtime (this might be because
# This example adds a server, it saves the ProxySQL server config to disk, but
# avoids loading the ProxySQL server config to runtime (this might be because
# several servers are being added and the user wants to push the config to
# runtime in a single batch using the M(proxysql_manage_config) module). It
# uses supplied credentials to connect to the proxysql admin interface.
# uses supplied credentials to connect to the ProxySQL admin interface.
- proxysql_proxysql_servers:
login_user: 'admin'
login_password: 'admin'
hostname: 'mysql01'
login_user: admin
login_password: admin
hostname: mysql01
state: present
load_to_runtime: False
# This example removes a server, saves the proxysql server config to disk, and
# dynamically loads the proxysql server config to runtime. It uses credentials
# in a supplied config file to connect to the proxysql admin interface.
# This example removes a server, saves the ProxySQL server config to disk, and
# dynamically loads the ProxySQL server config to runtime. It uses credentials
# in a supplied config file to connect to the ProxySQL admin interface.
- proxysql_proxysql_servers:
config_file: '~/proxysql.cnf'
hostname: 'mysql02'
hostname: mysql02
state: absent
'''

RETURN = '''
stdout:
description: The proxysql host modified or removed from proxysql
description: The ProxySQL host modified or removed from ProxySQL
returned: On create/update will return the newly modified host, on delete
it will return the deleted record.
type: dict
Expand All @@ -97,17 +95,10 @@


from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.mysql import mysql_connect
from ansible.module_utils.mysql import mysql_connect, mysql_driver, mysql_driver_fail_msg
from ansible.module_utils.six import iteritems
from ansible.module_utils._text import to_native

try:
import MySQLdb
import MySQLdb.cursors
except ImportError:
MYSQLDB_FOUND = False
else:
MYSQLDB_FOUND = True

# ===========================================
# proxysql module specific support methods.
Expand All @@ -127,10 +118,8 @@ def perform_checks(module):
msg="port must be a valid unix port number (0-65535)"
)

if not MYSQLDB_FOUND:
module.fail_json(
msg="the python mysqldb module is required"
)
if mysql_driver is None:
module.fail_json(msg=mysql_driver_fail_msg)


def save_config_to_disk(cursor):
Expand Down Expand Up @@ -367,10 +356,10 @@ def main():
login_user,
login_password,
config_file,
cursor_class=MySQLdb.cursors.DictCursor)
except MySQLdb.Error as e:
cursor_class=mysql_driver.cursors.DictCursor)
except mysql_driver.Error as e:
module.fail_json(
msg="unable to connect to ProxySQL Admin Module.. %s" % to_native(e)
msg="Unable to connect to ProxySQL Admin Module.. %s" % to_native(e)
)

proxysql_server = ProxySQLServer(module)
Expand All @@ -397,9 +386,9 @@ def main():
" and doesn't need to be updated.")
result['server'] = \
proxysql_server.get_server_config(cursor)
except MySQLdb.Error as e:
except mysql_driver.Error as e:
module.fail_json(
msg="unable to modify server.. %s" % to_native(e)
msg="Unable to modify server.. %s" % to_native(e)
)

elif proxysql_server.state == "absent":
Expand All @@ -412,9 +401,9 @@ def main():
result['changed'] = False
result['msg'] = ("The server is already absent from the" +
" proxysql_servers memory configuration")
except MySQLdb.Error as e:
except mysql_driver.Error as e:
module.fail_json(
msg="unable to remove server.. %s" % to_native(e)
msg="Unable to remove server.. %s" % to_native(e)
)

module.exit_json(**result)
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ galaxy_info:
the high performance, high availability, protocol aware proxy for MySQL.
role_name: proxysql
license: BSD-3-Clause
min_ansible_version: 2.5.0
min_ansible_version: 2.7.9
platforms:
- name: EL
versions:
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
params:
files:
- "{{ ansible_os_family }}-{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_os_family }}-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_os_family }}-{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
paths:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:9.4-slim
FROM debian:8-slim
LABEL maintainer="Timo Runge"

ARG ansible_role=${ansible_role}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:8.10-slim
FROM debian:9-slim
LABEL maintainer="Timo Runge"

ARG ansible_role=${ansible_role}
Expand Down
6 changes: 3 additions & 3 deletions tests/docker_test_runner.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ disable_logging: False

docker_image_build_args:
ansible_role: timorunge.proxysql
ansible_version: 2.7.0
ansible_version: 2.7.9

docker_image_path: "__PATH__/tests/docker"

docker_images:
- CentOS_7
- Debian_8_10
- Debian_9_4
- Debian_8
- Debian_9
- Ubuntu_16_04
- Ubuntu_18_04

Expand Down
6 changes: 3 additions & 3 deletions tests/docker_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ disable_logging: False

docker_image_build_args:
ansible_role: timorunge.proxysql
ansible_version: 2.7.0
ansible_version: 2.7.9

docker_image_path: "__PATH__/tests/docker"

docker_images:
- CentOS_7
- Debian_8_10
- Debian_9_4
- Debian_8
- Debian_9
- Ubuntu_14_04
- Ubuntu_16_04
- Ubuntu_17_10
Expand Down
18 changes: 18 additions & 0 deletions vars/Debian-Debian-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

# Type: Str
proxysql_distribution: "{{ ansible_distribution | lower }}"
proxysql_distribution_version: "{{ ansible_distribution_major_version }}"
proxysql_arch: amd64
proxysql_percona_repo: "https://repo.percona.com/apt/percona-release_{{ proxysql_percona_release }}.{{ ansible_distribution_release | lower }}_all.deb"
proxysql_pkg: "proxysql_{{ proxysql_version }}-{{ proxysql_distribution }}{{ proxysql_distribution_version }}_{{ proxysql_arch }}.deb"
proxysql_pkg_url: "{{ proxysql_download_url }}/v{{ proxysql_version }}/{{ proxysql_pkg }}"

# Type: List
proxysql_dependency_pkgs:
- mysql-client
- python-mysqldb
- xz-utils

# Type: List
proxysql_pip_dependency_pkgs: []
21 changes: 21 additions & 0 deletions vars/Debian-Ubuntu-14.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

# Type: Str
proxysql_distribution: "{{ ansible_distribution | lower }}"
proxysql_distribution_version: "{{ ansible_distribution_major_version }}"
proxysql_arch: amd64
proxysql_percona_repo: "https://repo.percona.com/apt/percona-release_{{ proxysql_percona_release }}.{{ ansible_distribution_release | lower }}_all.deb"
proxysql_pkg: "proxysql_{{ proxysql_version }}-{{ proxysql_distribution }}{{ proxysql_distribution_version }}_{{ proxysql_arch }}.deb"
proxysql_pkg_url: "{{ proxysql_download_url }}/v{{ proxysql_version }}/{{ proxysql_pkg }}"

# Type: List
proxysql_dependency_pkgs:
- build-essential
- libmysqlclient-dev
- mysql-client
- python-dev
- xz-utils

# Type: List
proxysql_pip_dependency_pkgs:
- mysqlclient>=1.3.8
2 changes: 1 addition & 1 deletion vars/Debian-Ubuntu-17.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ proxysql_pkg_url: "{{ proxysql_download_url }}/v{{ proxysql_version }}/{{ proxys
# Type: List
proxysql_dependency_pkgs:
- mysql-client
- python-mysqldb
- python-pymysql
- xz-utils

# Type: List
Expand Down
2 changes: 1 addition & 1 deletion vars/Debian-Ubuntu-18.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ proxysql_dependency_pkgs:
- libcrypto++6
- libssl1.0.0
- mysql-client
- python-mysqldb
- python-pymysql
- xz-utils

# Type: List
Expand Down
2 changes: 1 addition & 1 deletion vars/Debian-Ubuntu-18.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ proxysql_dependency_pkgs:
- libcrypto++6
- libssl1.0.0
- mysql-client
- python-mysqldb
- python-pymysql
- xz-utils

# Type: List
Expand Down
2 changes: 1 addition & 1 deletion vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ proxysql_pkg_url: "{{ proxysql_download_url }}/v{{ proxysql_version }}/{{ proxys
# Type: List
proxysql_dependency_pkgs:
- mysql-client
- python-mysqldb
- python-pymysql
- xz-utils

# Type: List
Expand Down

0 comments on commit 1dabc09

Please sign in to comment.