community.mysql icon indicating copy to clipboard operation
community.mysql copied to clipboard

mysql_db: problem with zeroes in database name

Open imThief opened this issue 3 years ago • 2 comments

SUMMARY

mysql_db replaces all zeroes with asterisks in database name when processes it. There is no problems with any other digits. {% raw %} block or literal notation doesn't helps. UPD: all names in paths/dump file names/etc are affected too.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_db

ANSIBLE VERSION
ansible [core 2.12.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/fox/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
community.mysql 2.3.5
CONFIGURATION
ANSIBLE_NOCOWS(/etc/ansible/ansible.cfg) = True
DEFAULT_BECOME(/etc/ansible/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/etc/ansible/ansible.cfg) = False
DEFAULT_BECOME_METHOD(/etc/ansible/ansible.cfg) = sudo
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/inventory']
DEFAULT_PRIVATE_KEY_FILE(/etc/ansible/ansible.cfg) = /home/user/.ssh/id_rsa
DEFAULT_REMOTE_USER(/etc/ansible/ansible.cfg) = user
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = ['/etc/ansible/roles', '/etc/ansible/dev', '/etc/ansible/servers', '/etc/ansible/services']
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = yaml
DEPRECATION_WARNINGS(/etc/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Ubuntu 22.04

STEPS TO REPRODUCE

Use zeroes in database name.

vars:
  data:
    database:
      name: 'dump_000'
      source: 'dump-000.sql'
      host: 172.17.0.1
      login_user: root
      login_pwd: 123
tasks:
  - name: Verifying database
    become: yes
    mysql_db:
      name: "{{ item.database.name }}"
      state: present
      encoding: utf8
      login_unix_socket: "{{ mysql_socket }}"
      login_user: "{{ item.database.login_user }}"
      login_password: "{{ item.database.login_pwd }}"
      config_file: /dev/null
    loop: "{{ data }}"
    loop_control:
      label: "Processing database {{ item.database.name|d('<None>') }}"
EXPECTED RESULTS
changed: [localhost] => (item=Processing database dump_000) => changed=true
  ansible_loop_var: item
  db: dump_000
  db_list:
  - dump_000
ACTUAL RESULTS

All zeroes in db name were replaced by asterisks

changed: [localhost] => (item=Processing database dump_000) => changed=true
  ansible_loop_var: item
  db: dump_************************
  db_list:
  - dump_************************

imThief avatar Jul 16 '22 08:07 imThief

Hi @imThief,

Do you still see this issue? I've noticed you're using an old version of the collection. I tested against 3.6.0 and 2.4.0 and it worked in both cases:

changed: [testhost] => (item=Processing database db_000) => {
    "ansible_loop_var": "item",
    "changed": true,
    "db": "db_000",
    "db_list": [
        "db_000"
    ],
    "executed_commands": [
        "CREATE DATABASE `db_000` CHARACTER SET 'utf8'"
    ],
    "invocation": {
        "module_args": {
            "ca_cert": null,
            "check_hostname": null,
            "check_implicit_admin": false,
            "client_cert": null,
            "client_key": null,
            "collation": "",
            "config_file": "/root/.my.cnf",
            "config_overrides_defaults": false,
            "connect_timeout": 30,
            "dump_extra_args": null,
            "encoding": "utf8",
            "force": false,
            "hex_blob": false,
            "ignore_tables": [],
            "login_host": "127.0.0.1",
            "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "login_port": 3307,
            "login_unix_socket": null,
            "login_user": "root",
            "master_data": 0,
            "name": [
                "db_000"
            ],
            "quick": true,
            "restrict_config_file": false,
            "single_transaction": false,
            "skip_lock_tables": false,
            "state": "present",
            "target": null,
            "unsafe_login_password": false,
            "use_shell": false
        }
    },
    "item": "db_000"
}

laurent-indermuehle avatar Mar 16 '23 16:03 laurent-indermuehle

Hi. That needs to be checked. I'll update and test this asap, will provide feedback here after, thanks.

imThief avatar Mar 16 '23 19:03 imThief