Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add engine option to the mysql_info module? #644

Closed
chriscroome opened this issue Jun 11, 2024 · 5 comments · Fixed by #649
Closed

Feature request: Add engine option to the mysql_info module? #644

chriscroome opened this issue Jun 11, 2024 · 5 comments · Fixed by #649
Labels
enhancement New feature or request

Comments

@chriscroome
Copy link
Contributor

Currently community.mysql.mysql_info doesn't have an output for the database engine that is in use, MariaDB or MySQL, there are times when this is needed, for example the Matomo database schema need to be set to Mysql or Mariadb:

php console config:get --section database --key schema
"Mariadb"

Currently I use this to get the schema from the database:

    - name: "Check the database version using the details from {{ matomo_db_config }}"
      community.mysql.mysql_info:
        config_file: "{{ matomo_db_config }}"
        filter:
          - version
      register: matomo_mysql_info
  
    - name: Debug matomo_mysql_info
      ansible.builtin.debug:
        var: matomo_mysql_info
        verbosity: "{% if ansible_check_mode | bool or ansible_diff_mode | bool %}1{% else %}2{% endif %}"
  
    - name: Set a fact for the database type
      ansible.builtin.set_fact:
        matomo_db_type: "{{ matomo_mysql_info.version.suffix | ansible.builtin.regex_replace('-.*$') | capitalize | trim }}"  

And this to set it:

    - name: Update the Matomo database schema
      ansible.builtin.command: "{{ matomo_php }} console --no-ansi -n config:set '{{ matomo_set_database_schema }}'"
      args:
        chdir: "{{ matomo_html }}"
      vars:
        matomo_set_database_schema: 'database.schema="{{ matomo_db_type }}"'
      become: true
      become_user: "{{ matomo_user }}"
      changed_when: true

It would be nicer if mysql_info returned something like this (engine has been added):

    matomo_mysql_info:
        changed: false
        connector_name: pymysql
        connector_version: 1.0.2
        failed: false
        version:
            full: 10.11.6-MariaDB-0+deb12u1
            major: 10
            minor: 11
            release: 6
            suffix: MariaDB-0+deb12u1
            engine: MariaDB

So I could omit the regex_replace.

@Andersson007
Copy link
Collaborator

@chriscroome SGTM, thanks for reporting the issue!
Would you like to take it yourself or we could add the help wanted label?

@Andersson007 Andersson007 added the enhancement New feature or request label Jun 17, 2024
@chriscroome
Copy link
Contributor Author

chriscroome commented Jun 17, 2024

I'm sorry to say that I'm not a Python programmer @Andersson007 so best add the help wanted label.

@Andersson007
Copy link
Collaborator

@chriscroome sure, will put, thanks!

@Andersson007 Andersson007 added the help wanted Extra attention is needed label Jun 18, 2024
@Andersson007
Copy link
Collaborator

looking myself

@Andersson007
Copy link
Collaborator

@chriscroome i've opened a PR #649 , please take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants