From b14ca9f272cfe4a658a4c3e33261ee20a0323a9d Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Tue, 10 Jan 2023 12:54:13 +0100 Subject: [PATCH] fix missing check_mode (#138) * fix missing check_mode * #131 add --changed * rework * try to fix path * remove debug output --- .github/workflows/ansible-test-plugins.yml | 73 ++++++------------- .../fragments/137-missing_check_mode.yml | 2 + plugins/modules/proxysql_manage_config.py | 9 ++- 3 files changed, 30 insertions(+), 54 deletions(-) create mode 100644 changelogs/fragments/137-missing_check_mode.yml diff --git a/.github/workflows/ansible-test-plugins.yml b/.github/workflows/ansible-test-plugins.yml index d306289..375b7aa 100644 --- a/.github/workflows/ansible-test-plugins.yml +++ b/.github/workflows/ansible-test-plugins.yml @@ -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: @@ -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 }})" @@ -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 diff --git a/changelogs/fragments/137-missing_check_mode.yml b/changelogs/fragments/137-missing_check_mode.yml new file mode 100644 index 0000000..42681f6 --- /dev/null +++ b/changelogs/fragments/137-missing_check_mode.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxysql_manage_config - Fix ``check_mode`` (https://github.com/ansible-collections/community.proxysql/pull/138). diff --git a/plugins/modules/proxysql_manage_config.py b/plugins/modules/proxysql_manage_config.py index 6c9763d..ead810e 100644 --- a/plugins/modules/proxysql_manage_config.py +++ b/plugins/modules/proxysql_manage_config.py @@ -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 # =========================================== @@ -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)