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

mysql_user module failing with "'database' is an invalid keyword argument for this function" #151

Closed
geerlingguy opened this issue Apr 22, 2021 · 9 comments

Comments

@geerlingguy
Copy link

SUMMARY

I haven't changed anything in my role, and I looked through the changelog for this collection, and I can't find anything that indicates I'm doing something wrong, so I figured I'd open a bug report here; my CI tests just started failing after Ansible 3.3.0 came out and was used for CI runs starting yesterday.

The failure is on this task:

- name: Remove anonymous MySQL users.
  mysql_user:
    name: ""
    host: "{{ item }}"
    state: absent
  with_items: "{{ mysql_anonymous_hosts.stdout_lines|default([]) }}"

And the failure message:

TASK [geerlingguy.mysql : Remove anonymous MySQL users.] ***********************
failed: [instance] (item=instance) => {"ansible_loop_var": "item", "changed": false, "item": "instance", "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: 'database' is an invalid keyword argument for this function"}
failed: [instance] (item=localhost) => {"ansible_loop_var": "item", "changed": false, "item": "localhost", "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: 'database' is an invalid keyword argument for this function"}

I'm not passing database anywhere, so I'm not quite sure what's going wrong...

Related: geerlingguy/ansible-role-mysql#445

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_user

ANSIBLE VERSION
$ ansible --version
ansible 2.10.8
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/Users/jgeerling/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 24 2021, 13:26:09) [Clang 12.0.0 (clang-1200.0.32.29)]

(I have 3.3.0 installed according to Pip... I guess it's just showing the ansible-base version I have installed locally?)

CONFIGURATION
ANSIBLE_NOCOWS(/etc/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/etc/ansible/ansible.cfg) = True
ANSIBLE_SSH_CONTROL_PATH(/etc/ansible/ansible.cfg) = /tmp/ansible-ssh-%%h-%%p-%%r
DEFAULT_FORKS(/etc/ansible/ansible.cfg) = 20
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = ['/etc/ansible/hosts']
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = ['/Users/jgeerling/Dropbox/VMs/roles']
RETRY_FILES_ENABLED(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

macOS (locally)
Ubuntu 20.04 (GitHub Actions CI)

STEPS TO REPRODUCE

See task above in summary.

EXPECTED RESULTS

mysql_user should succeed as it has before.

ACTUAL RESULTS

See error message above in summary.

@Andersson007
Copy link
Collaborator

@geerlingguy hi, thanks for reporting this! #116
could you please update the db driver version on your system to let your tests pass while we're working on this.

@Andersson007
Copy link
Collaborator

@geerlingguy I've just released fixed version 2.1.0 and 1.4.1. Available on galaxy

@mamono210
Copy link

Thanks to this fix, my Playbook is working again!

Thank you very much!

@Andersson007
Copy link
Collaborator

@TomonoriMatsumura you and the community are welcome:)

@Andersson007
Copy link
Collaborator

As it's confirmed that the fix helps, I'll close the issue. Thanks everyone!

@ksarunas
Copy link

ksarunas commented May 8, 2021

I am on ansible 2.10.9 and I am still receiving the same error:

fatal: [host]: FAILED! => {"changed": false, "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: 'database' is an invalid keyword argument for this function"}

task:

- name: Ensure {{ mysql_user }} is present
  mysql_user:
    name: "{{ mysql_user }}"
    password: "{{ mysql_password }}"
    priv: '*.*:ALL'
    state: present

@Andersson007
Copy link
Collaborator

@ksarunas Ansible release is planned tomorrow (on May 11) but I don't know the exact time, so you could try to upgrade, say, on May 12 and give us feedback. Alternatively, you could install the latest version of the collection manually using ansible-galaxy, see the manual here. In any case, please give us the feedback.
Thanks

@ksarunas
Copy link

I can confirm that on 2.11.0 issue is fixed 👍 thank you!

@Andersson007
Copy link
Collaborator

@ksarunas thanks for the feedback!

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

No branches or pull requests

4 participants