Skip to content

Commit

Permalink
fix missing check_mode (#138) (#139)
Browse files Browse the repository at this point in the history
* fix missing check_mode

* #131 add --changed

* rework

* try to fix path

* remove debug output

(cherry picked from commit b14ca9f)

Co-authored-by: Markus Bergholz <[email protected]>
  • Loading branch information
patchback[bot] and markuman authored Jan 10, 2023
1 parent 5dc30b7 commit dd55da4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 54 deletions.
73 changes: 23 additions & 50 deletions .github/workflows/ansible-test-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:


env:
proxysql_version_file: "./ansible_collections/community/proxysql/tests/integration/targets/setup_proxysql/defaults/main.yml"
proxysql_version_file: "./tests/integration/targets/setup_proxysql/defaults/main.yml"

jobs:
sanity:
Expand All @@ -29,23 +29,12 @@ jobs:
- stable-2.14
- devel
steps:

- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/community/proxysql

- name: Set up Python
uses: actions/setup-python@v2
- name: Perform sanity testing
uses: ansible-community/ansible-test-gh-action@release/v1
with:
python-version: 3.9

- 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/proxysql
ansible-core-version: ${{ matrix.ansible }}
testing-type: sanity
pull-request-change-detection: true

integration:
name: "Integration (Python: ${{ matrix.python }}, Ansible: ${{ matrix.ansible }}, ProxySQL: ${{ matrix.proxysql }})"
Expand All @@ -63,51 +52,35 @@ jobs:
python:
- 3.9
include:
- python: "3.9"
- python: 3.9
ansible: "stable-2.12"
proxysql: 2.4.4
- python: "3.9"
- python: 3.9
ansible: "stable-2.13"
proxysql: 2.4.4
- python: "3.9"
- python: 3.9
ansible: "stable-2.14"
proxysql: 2.4.4
- python: "3.9"
- python: 3.9
ansible: "stable-2.12"
proxysql: 2.3.2
- python: "3.9"
- python: 3.9
ansible: "stable-2.13"
proxysql: 2.3.2
- python: "3.9"
- python: 3.9
ansible: "stable-2.14"
proxysql: 2.3.2

steps:

- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/community/proxysql

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check

- name: Set ProxySQL version (${{ matrix.proxysql }})
run: "sed -i 's/^proxysql_version:.*/proxysql_version: \"${{ matrix.proxysql }}\"/g' ${{ env.proxysql_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/proxysql

- name: Generate coverage report.
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: ./ansible_collections/community/proxysql

- uses: codecov/codecov-action@v1
- name: >-
Perform integration testing against
Ansible version ${{ matrix.ansible }}
under Python ${{ matrix.python }}
uses: ansible-community/ansible-test-gh-action@release/v1
with:
fail_ci_if_error: false
ansible-core-version: ${{ matrix.ansible }}
pre-test-cmd: >-
sed -i 's/^proxysql_version:.*/proxysql_version: \"${{ matrix.proxysql }}\"/g' ${{ env.proxysql_version_file }}
target-python-version: ${{ matrix.python }}
testing-type: integration
pull-request-change-detection: true
2 changes: 2 additions & 0 deletions changelogs/fragments/137-missing_check_mode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- proxysql_manage_config - Fix ``check_mode`` (https://github.com/ansible-collections/community.proxysql/pull/138).
9 changes: 5 additions & 4 deletions plugins/modules/proxysql_manage_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ def perform_checks(module):
module.fail_json(msg=msg_string % module.params["direction"])


def manage_config(manage_config_settings, cursor):
def manage_config(manage_config_settings, cursor, check_mode):

query_string = "%s" % ' '.join(manage_config_settings)
if not check_mode:
query_string = "%s" % ' '.join(manage_config_settings)
cursor.execute(query_string)

cursor.execute(query_string)
return True

# ===========================================
Expand Down Expand Up @@ -198,7 +199,7 @@ def main():

try:
result['changed'] = manage_config(manage_config_settings,
cursor)
cursor, module.check_mode)
except mysql_driver.Error as e:
module.fail_json(
msg="unable to manage config.. %s" % to_native(e)
Expand Down

0 comments on commit dd55da4

Please sign in to comment.