Merge branch 'ansible-collections:main' into add_pam_service_option

This commit is contained in:
hubiongithub 2022-12-12 15:42:42 +01:00 committed by GitHub
commit 2c431a2084
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 135 additions and 119 deletions

View file

@ -15,54 +15,31 @@ on:
env: env:
mysql_version_file: "./ansible_collections/community/mysql/tests/integration/targets/setup_mysql/defaults/main.yml" mysql_version_file: "tests/integration/targets/setup_mysql/defaults/main.yml"
connector_version_file: "./ansible_collections/community/mysql/tests/integration/targets/setup_mysql/vars/main.yml" connector_version_file: "tests/integration/targets/setup_mysql/vars/main.yml"
jobs: jobs:
sanity: sanity:
name: "Sanity (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }})" name: "Sanity (Ansible: ${{ matrix.ansible }})"
runs-on: ubuntu-latest runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
ansible: ansible:
- stable-2.11
- stable-2.12 - stable-2.12
- stable-2.13 - stable-2.13
- stable-2.14
- devel - devel
python:
- 3.8
- 3.9
exclude:
- python: 3.8
ansible: stable-2.13
- python: 3.8
ansible: devel
- python: 3.9
ansible: stable-2.11
- python: 3.9
ansible: stable-2.12
steps: steps:
- name: Perform sanity testing
- name: Check out code uses: ansible-community/ansible-test-gh-action@release/v1
uses: actions/checkout@v2
with: with:
path: ansible_collections/community/mysql ansible-core-version: ${{ matrix.ansible }}
testing-type: sanity
- name: Set up Python pull-request-change-detection: true
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/community/mysql
integration: integration:
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, MySQL: ${{ matrix.db_engine_version }}, Connector: ${{ matrix.connector }})" name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, MySQL: ${{ matrix.db_engine_version }}, Connector: ${{ matrix.connector }})"
runs-on: ubuntu-latest runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -74,9 +51,9 @@ jobs:
# also change the "Set MariaDB URL sub dir" task # also change the "Set MariaDB URL sub dir" task
- mariadb_10.8.3 - mariadb_10.8.3
ansible: ansible:
- stable-2.11
- stable-2.12 - stable-2.12
- stable-2.13 - stable-2.13
- stable-2.14
- devel - devel
python: python:
- 3.6 - 3.6
@ -95,68 +72,49 @@ jobs:
ansible: stable-2.12 ansible: stable-2.12
- python: 3.6 - python: 3.6
ansible: stable-2.13 ansible: stable-2.13
- python: 3.6
ansible: stable-2.14
- python: 3.6 - python: 3.6
ansible: devel ansible: devel
- python: 3.8
ansible: stable-2.11
- python: 3.8 - python: 3.8
ansible: stable-2.13 ansible: stable-2.13
- python: 3.8
ansible: stable-2.14
- python: 3.8 - python: 3.8
ansible: devel ansible: devel
- python: 3.9
ansible: stable-2.11
- python: 3.9 - python: 3.9
ansible: stable-2.12 ansible: stable-2.12
steps: steps:
- name: >-
- name: Check out code Perform integration testing against
uses: actions/checkout@v2 Ansible version ${{ matrix.ansible }}
under Python ${{ matrix.python }}
uses: ansible-community/ansible-test-gh-action@release/v1
with: with:
path: ansible_collections/community/mysql ansible-core-version: ${{ matrix.ansible }}
pre-test-cmd: >-
- name: Set up Python DB_ENGINE=$(echo '${{ matrix.db_engine_version }}' | awk -F_ '{print $1}');
uses: actions/setup-python@v2 DB_VERSION=$(echo '${{ matrix.db_engine_version }}' | awk -F_ '{print $2}');
with: DB_ENGINE_PRETTY=$([[ "${DB_ENGINE}" == 'mysql' ]] && echo 'MySQL' || echo 'MariaDB');
python-version: ${{ matrix.python }} >&2 echo Matrix factor for the DB is ${{ matrix.db_engine_version }}...;
>&2 echo Setting ${DB_ENGINE_PRETTY} version to ${DB_VERSION}...;
- name: Install ansible-base (${{ matrix.ansible }}) sed -i -e "s/^${DB_ENGINE}_version:.*/${DB_ENGINE}_version: $DB_VERSION/g" -e 's/^mariadb_install: false/mariadb_install: true/g' '${{ env.mysql_version_file }}';
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check ${{
matrix.db_engine_version == 'mariadb_10.8.3'
- name: Set MySQL version (${{ matrix.db_engine_version }}) && format(
run: | '>&2 echo Set MariaDB v10.8.3 URL sub dir...; sed -i -e "s/^mariadb_url_subdir:.*/mariadb_url_subdir: linux-systemd/g" "{0}";', env.connector_version_file
export DB_VERSION=$(echo "${{ matrix.db_engine_version }}" | awk -F_ '{print $2}') )
sed -i "s/^mysql_version:.*/mysql_version: $DB_VERSION/g" ${{ env.mysql_version_file }} || ''
if: ${{ startsWith(matrix.db_engine_version, 'mysql') }} }}
>&2 echo Setting Connector version to ${{ matrix.connector }}...;
- name: Set MariaDB version (${{ matrix.db_engine_version }}) sed -i 's/^python_packages:.*/python_packages: [${{ matrix.connector }}]/' ${{ env.connector_version_file }}
run: | target-python-version: ${{ matrix.python }}
export DB_VERSION=$(echo "${{ matrix.db_engine_version }}" | awk -F_ '{print $2}') testing-type: integration
sed -i -e "s/^mariadb_version:.*/mariadb_version: $DB_VERSION/g" -e 's/^mariadb_install: false/mariadb_install: true/g' ${{ env.mysql_version_file }} pull-request-change-detection: true
if: ${{ startsWith(matrix.db_engine_version, 'mariadb') }}
- name: Set MariaDB URL sub dir
run: |
sed -i -e "s/^mariadb_url_subdir:.*/mariadb_url_subdir: linux-systemd/g" ${{ env.connector_version_file }}
if: matrix.db_engine_version == 'mariadb_10.8.3'
- name: Set Connector version (${{ matrix.connector }})
run: "sed -i 's/^python_packages:.*/python_packages: [${{ matrix.connector }}]/' ${{ env.connector_version_file }}"
- name: Run integration tests
run: ansible-test integration --docker -v --color --retry-on-error --continue-on-error --python ${{ matrix.python }} --diff --coverage
working-directory: ./ansible_collections/community/mysql
- name: Generate coverage report.
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: ./ansible_collections/community/mysql
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
units: units:
runs-on: ubuntu-latest runs-on: ubuntu-20.04
name: Units (Ⓐ${{ matrix.ansible }}) name: Units (Ⓐ${{ matrix.ansible }})
strategy: strategy:
# As soon as the first unit test fails, # As soon as the first unit test fails,
@ -164,9 +122,9 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
ansible: ansible:
- stable-2.11
- stable-2.12 - stable-2.12
- stable-2.13 - stable-2.13
- stable-2.14
- devel - devel
python: python:
- 3.8 - 3.8
@ -174,38 +132,20 @@ jobs:
exclude: exclude:
- python: 3.8 - python: 3.8
ansible: stable-2.13 ansible: stable-2.13
- python: 3.8
ansible: stable-2.14
- python: 3.8 - python: 3.8
ansible: devel ansible: devel
- python: 3.9
ansible: stable-2.11
- python: 3.9 - python: 3.9
ansible: stable-2.12 ansible: stable-2.12
steps: steps:
- name: Check out code - name: >-
uses: actions/checkout@v2 Perform unit testing against
Ansible version ${{ matrix.ansible }}
uses: ansible-community/ansible-test-gh-action@release/v1
with: with:
path: ./ansible_collections/community/mysql ansible-core-version: ${{ matrix.ansible }}
target-python-version: ${{ matrix.python }}
- name: Set up Python testing-type: units
uses: actions/setup-python@v2 pull-request-change-detection: true
with:
python-version: ${{ matrix.python }}
- name: Install ansible-base (${{matrix.ansible}})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
# Run the unit tests
- name: Run unit test
run: ansible-test units -v --color --docker --coverage
working-directory: ./ansible_collections/community/mysql
# ansible-test support producing code coverage date
- name: Generate coverage report
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: ./ansible_collections/community/mysql
# See the reports at https://codecov.io/gh/GITHUBORG/REPONAME
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false

View file

@ -14,7 +14,7 @@ on:
jobs: jobs:
molecule: molecule:
name: "Molecule (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, MySQL: ${{ matrix.mysql }})" name: "Molecule (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, MySQL: ${{ matrix.mysql }})"
runs-on: ubuntu-latest runs-on: ubuntu-20.04
env: env:
PY_COLORS: 1 PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1 ANSIBLE_FORCE_COLOR: 1

3
.gitignore vendored
View file

@ -134,3 +134,6 @@ dmypy.json
# MacOS # MacOS
.DS_Store .DS_Store
# IntelliJ IDEA or PyCharm
.idea/

View file

@ -33,6 +33,7 @@ baldpale
banyek banyek
BarbzYHOOL BarbzYHOOL
Berbe Berbe
bizmate
bjne bjne
bmalynovytch bmalynovytch
bmildren bmildren

View file

@ -1,5 +1,5 @@
# MySQL collection for Ansible # MySQL collection for Ansible
[![Plugins CI](https://github.com/ansible-collections/community.mysql/workflows/Plugins%20CI/badge.svg?event=push)](https://github.com/ansible-collections/community.mysql/actions?query=workflow%3A"Plugins+CI") [![Roles CI](https://github.com/ansible-collections/community.mysql/workflows/Roles%20CI/badge.svg?event=push)](https://github.com/ansible-collections/community.mysql/actions?query=workflow%3A"Roles+CI") [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.mysql)](https://codecov.io/gh/ansible-collections/community.mysql) [![Plugins CI](https://github.com/ansible-collections/community.mysql/workflows/Plugins%20CI/badge.svg?event=push)](https://github.com/ansible-collections/community.mysql/actions?query=workflow%3A"Plugins+CI") [![Roles CI](https://github.com/ansible-collections/community.mysql/workflows/Roles%20CI/badge.svg?event=push)](https://github.com/ansible-collections/community.mysql/actions?query=workflow%3A"Roles+CI") [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.mysql)](https://codecov.io/gh/ansible-collections/community.mysql) [![](https://img.shields.io/matrix/mysql:ansible.com.svg?server_fqdn=ansible-accounts.ems.host&label=Discuss%20at%20%23mysql:ansible.com&logo=matrix)]
This collection is a part of the Ansible package. This collection is a part of the Ansible package.
@ -36,7 +36,7 @@ They also should be subscribed to Ansible's [The Bullhorn newsletter](https://do
We announce releases and important changes through Ansible's [The Bullhorn newsletter](https://eepurl.com/gZmiEP). Be sure you are subscribed. We announce releases and important changes through Ansible's [The Bullhorn newsletter](https://eepurl.com/gZmiEP). 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](https://docs.ansible.com/ansible/devel/community/communication.html#irc-channels) on [Libera.Chat](https://libera.chat). Join us on Matrix in the `#mysql:ansible.com` [room](https://matrix.to/#/#mysql:ansible.com), the `#users:ansible.com` [room](https://matrix.to/#/#users:ansible.com) (general use questions and support), `#ansible-community:ansible.com` [room](https://matrix.to/#/#community:ansible.com) (community and collection development questions), and other Matrix rooms or corresponding bridged Libera.Chat channels. See the [Ansible Communication Guide](https://docs.ansible.com/ansible/devel/community/communication.html) for details.
We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit) virtually or in-person. Track [The Bullhorn newsletter](https://eepurl.com/gZmiEP) and join us. We take part in the global quarterly [Ansible Contributor Summit](https://github.com/ansible/community/wiki/Contributor-Summit) virtually or in-person. Track [The Bullhorn newsletter](https://eepurl.com/gZmiEP) and join us.

View file

@ -0,0 +1,5 @@
---
minor_changes:
- mysql_user - display a more informative invalid privilege exception.
Changes the exception handling of the granting permission logic to show the query executed , params
and the exception message granting privileges fails` (https://github.com/ansible-collections/community.mysql/issues/465).

View file

@ -79,8 +79,6 @@ requirements:
- PyMySQL (Python 2.7 and Python 3.x) or - PyMySQL (Python 2.7 and Python 3.x) or
- MySQLdb (Python 2.x) - MySQLdb (Python 2.x)
notes: notes:
- "To avoid the C(Please explicitly state intended protocol) error, use the I(login_unix_socket) argument,
for example, C(login_unix_socket: /run/mysqld/mysqld.sock)."
- Requires the PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) package installed on the remote host. - Requires the PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) package installed on the remote host.
The Python package may be installed with apt-get install python-pymysql (Ubuntu; see M(ansible.builtin.apt)) or The Python package may be installed with apt-get install python-pymysql (Ubuntu; see M(ansible.builtin.apt)) or
yum install python2-PyMySQL (RHEL/CentOS/Fedora; see M(ansible.builtin.yum)). You can also use dnf install python2-PyMySQL yum install python2-PyMySQL (RHEL/CentOS/Fedora; see M(ansible.builtin.yum)). You can also use dnf install python2-PyMySQL
@ -107,4 +105,9 @@ notes:
- "If credentials from the config file (for example, C(/root/.my.cnf)) are not needed to connect to a database server, but - "If credentials from the config file (for example, C(/root/.my.cnf)) are not needed to connect to a database server, but
the file exists and does not contain a C([client]) section, before any other valid directives, it will be read and this the file exists and does not contain a C([client]) section, before any other valid directives, it will be read and this
will cause the connection to fail, to prevent this set it to an empty string, (for example C(config_file: ''))." will cause the connection to fail, to prevent this set it to an empty string, (for example C(config_file: ''))."
- "To avoid the C(Please explicitly state intended protocol) error, use the I(login_unix_socket) argument,
for example, C(login_unix_socket: /run/mysqld/mysqld.sock)."
- Alternatively, to avoid using I(login_unix_socket) argument on each invocation you can specify the socket path
using the `socket` option in your MySQL config file (usually C(~/.my.cnf)) on the destination host, for
example C(socket=/var/lib/mysql/mysql.sock).
''' '''

View file

@ -733,7 +733,8 @@ def privileges_grant(cursor, user, host, db_table, priv, tls_requires, maria_rol
try: try:
cursor.execute(query, params) cursor.execute(query, params)
except (mysql_driver.ProgrammingError, mysql_driver.OperationalError, mysql_driver.InternalError) as e: except (mysql_driver.ProgrammingError, mysql_driver.OperationalError, mysql_driver.InternalError) as e:
raise InvalidPrivsError("Error granting privileges, invalid priv string: %s" % priv_string) raise InvalidPrivsError("Error granting privileges, invalid priv string: %s , params: %s, query: %s ,"
" exception: %s." % (priv_string, str(params), query, str(e)))
def convert_priv_dict_to_str(priv): def convert_priv_dict_to_str(priv):

View file

@ -4,3 +4,5 @@
src: installed_file.j2 src: installed_file.j2
dest: "{{ dbdeployer_installed_file }}" dest: "{{ dbdeployer_installed_file }}"
listen: create zookeeper installed file listen: create zookeeper installed file
tags:
- setup_mysql

View file

@ -5,7 +5,17 @@
#################################################################### ####################################################################
- import_tasks: setvars.yml - import_tasks: setvars.yml
tags:
- setup_mysql
- import_tasks: dir.yml - import_tasks: dir.yml
tags:
- setup_mysql
- import_tasks: install.yml - import_tasks: install.yml
tags:
- setup_mysql
- import_tasks: config.yml - import_tasks: config.yml
tags:
- setup_mysql
- import_tasks: verify.yml - import_tasks: verify.yml
tags:
- setup_mysql

View file

@ -1,5 +1,9 @@
- name: delete temporary directory - name: delete temporary directory
include_tasks: default-cleanup.yml include_tasks: default-cleanup.yml
tags:
- setup_remote_tmp_dir
- name: delete temporary directory (windows) - name: delete temporary directory (windows)
include_tasks: windows-cleanup.yml include_tasks: windows-cleanup.yml
tags:
- setup_remote_tmp_dir

View file

@ -7,9 +7,13 @@
setup: setup:
gather_subset: distribution gather_subset: distribution
when: ansible_facts == {} when: ansible_facts == {}
tags:
- setup_remote_tmp_dir
- include_tasks: "{{ lookup('first_found', files)}}" - include_tasks: "{{ lookup('first_found', files)}}"
vars: vars:
files: files:
- "{{ ansible_os_family | lower }}.yml" - "{{ ansible_os_family | lower }}.yml"
- "default.yml" - "default.yml"
tags:
- setup_remote_tmp_dir

View file

@ -281,6 +281,10 @@
- include: test_priv_subtract.yml enable_check_mode=no - include: test_priv_subtract.yml enable_check_mode=no
- include: test_priv_subtract.yml enable_check_mode=yes - include: test_priv_subtract.yml enable_check_mode=yes
- import_tasks: test_privs_issue_465.yml
tags:
- issue_465
# Tests for the TLS requires dictionary # Tests for the TLS requires dictionary
- include: tls_requirements.yml - include: tls_requirements.yml

View file

@ -0,0 +1,31 @@
---
# test code for privileges for mysql_user module - issue 465
- vars:
mysql_parameters: &mysql_params
login_user: '{{ mysql_user }}'
login_password: '{{ mysql_password }}'
login_host: 127.0.0.1
login_port: '{{ mysql_primary_port }}'
block:
# ============================================================
- name: create a user with parameters that will always cause an exception
mysql_user:
<<: *mysql_params
name: user_issue_465
password: a_test_password_465
priv: '*.{{ db_name }}:SELECT'
state: present
ignore_errors: true
register: result
- name: assert output message for current privileges
assert:
that:
- result is failed
- result.msg is search('invalid priv string')
- result.msg is search('params')
- result.msg is search('query')
- result.msg is search('exception')

View file

@ -0,0 +1,8 @@
plugins/modules/mysql_db.py validate-modules:doc-elements-mismatch
plugins/modules/mysql_db.py validate-modules:parameter-list-no-elements
plugins/modules/mysql_db.py validate-modules:use-run-command-not-popen
plugins/modules/mysql_info.py validate-modules:doc-elements-mismatch
plugins/modules/mysql_info.py validate-modules:parameter-list-no-elements
plugins/modules/mysql_query.py validate-modules:parameter-list-no-elements
plugins/modules/mysql_user.py validate-modules:undocumented-parameter
plugins/modules/mysql_variables.py validate-modules:doc-required-mismatch