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

Possible recurrence of issue #151 following latest release of community.mysql? #546

Closed
paulh-rtr opened this issue May 8, 2023 · 16 comments · Fixed by #553
Closed

Possible recurrence of issue #151 following latest release of community.mysql? #546

paulh-rtr opened this issue May 8, 2023 · 16 comments · Fixed by #553

Comments

@paulh-rtr
Copy link

paulh-rtr commented May 8, 2023

SUMMARY

A Github Action which we run on a weekly basis, and which calls an Ansible playbook which in turn calls community.mysql, is failing since this weekend on all calls to community.mysql

Nothing has changed in the codebase; this was confirmed as working last weekend, and so I presume the issue is with the most recent release 3.7.0. Running the playbook by hand, in a different environment with an earlier version of community.mysql, works.

For example see below (with some details redacted):

- name: create heartbeat user
  community.mysql.mysql_user:
<snip>
    state: present
  when: db_role == "{{ master_role }}"

This produces an error like the following:

fatal: [<hostname>]: 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"}

Note: The error message would seem to be the same as in this issue: #151.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

mysql_user, mysql_query, possibly others

ANSIBLE VERSION
ansible.posix:1.5.2
COLLECTION VERSION
community.mysql:3.7.0
OS / ENVIRONMENT

Github Action environment as described below:

Current runner version: '2.304.0'
Runner name: 'infra-runners-default-tr8[2](https://github.com/RentTheRunway/mysql/actions/runs/4904303710/jobs/8757254064#step:1:2)k-cqkkn'
Runner group name: 'infra-runners'
Machine name: 'infra-runners-default-tr82k-cqkkn'
GITHUB_TOKEN Permissions

Starting galaxy role install process
- downloading role 'google_cloud_ops_agents', owned by googlecloudplatform
- downloading role from https://github.com/GoogleCloudPlatform/stackdriver-ansible-role/archive/master.tar.gz
- extracting googlecloudplatform.google_cloud_ops_agents to /home/runner/.ansible/roles/googlecloudplatform.google_cloud_ops_agents
- googlecloudplatform.google_cloud_ops_agents (master) was installed successfully
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/download/ansible-posix-1.5.2.tar.gz to /home/runner/.ansible/tmp/ansible-local-508_auvsywe/tmpfntsf2t8/ansible-posix-1.5.2-zzhqpkox
Installing 'ansible.posix:1.5.2' to '/home/runner/.ansible/collections/ansible_collections/ansible/posix'
ansible.posix:1.5.2 was installed successfully
...
Downloading https://galaxy.ansible.com/download/community-mysql-3.7.0.tar.gz to /home/runner/.ansible/tmp/ansible-local-508_auvsywe/tmpfntsf2t8/community-mysql-3.7.0-bubguzl8
Installing 'community.mysql:3.7.0' to '/home/runner/.ansible/collections/ansible_collections/community/mysql'
community.mysql:3.7.0 was installed successfully
Downloading https://galaxy.ansible.com/download/community-general-6.6.0.tar.gz to /home/runner/.ansible/tmp/ansible-local-508_auvsywe/tmpfntsf2t8/community-general-6.6.0-jbn55ez8
Installing 'community.general:6.6.0' to '/home/runner/.ansible/collections/ansible_collections/community/general'
community.general:6.6.0 was installed successfully
STEPS TO REPRODUCE

Some example code blocks which are failing:

- name: create heartbeat user
  community.mysql.mysql_user:
<snip>
    state: present
  when: db_role == "{{ master_role }}"
- name: Provision <stuff>
  community.mysql.mysql_query:
    login_db: mysql
    query:
      - "SET sql_log_bin = 0"
      - "REPLACE INTO tablename <etc...{{variable1}} {{variable2}}...  etc>"
    named_args:
      variable1: "{{ variable1 }}"
      variable2: "{{ variable2 }}"
    single_transaction: yes
EXPECTED RESULTS

Call to community.mysql.mysql_user, mysql_query etc. completes as requested

ACTUAL RESULTS

Actual results for the 2 examples as above:

TASK [<role name> : create heartbeat user] ***********************
fatal: [<hostname>]: 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 [<role name> : Provision <stuff>] ***
fatal: [<hostname>]: 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"}
@alexgit2k
Copy link

I can confirm this, having the same issue after upgrading from 3.6.0 to 3.7.0.
2 Workarounds:

  1. Downgrading via Shell:
rm -rf .ansible/collections/ansible_collections/community/mysql
ansible-galaxy collection install community.mysql:==3.6.0
  1. Configuration via requirements.yml:
collections:
  - name: community.mysql
    version: "=3.6.0"

@alexgit2k
Copy link

Just found out that the problem occurs only on our CentOS 7 machine:

  • Not working: CentOS 7 with Ansible 2.9.27, Python 2.7.5, MySQLdb (package MySQL-python)
  • Working: AlmaLinux 9 with Ansible 2.13.3, Python 3.9.14, MySQLdb (package python3-mysqlclient)

Maybe it has something to do with Python 2.

@paulh-rtr Which versions are you using?

@paulh-rtr
Copy link
Author

@alexgit2k Thanks for looking into the issue. The environment on which we encountered this issue is Github Actions, which is a CI/CD provided by Github, not unlike Jenkins.

I don't have much if any control over that environment, but looks like it is pulling the following:

0s
Current runner version: '2.304.0'
Operating System
  Ubuntu
  22.04.2
  LTS
Runner Image
  Image: ubuntu-22.04

Looks like there is a comprehensive list at https://github.com/actions/runner-images/blob/releases/ubuntu22/20230426/images/linux/Ubuntu2204-Readme.md

Could well be Python 2; there is a note stating that it will be removed from the image on May 15. I'd be more than happy to report back if that effectively fixes the issue. In the meantime, am using the workaround you suggested.

@31239899
Copy link

31239899 commented May 11, 2023

We're hitting the same error. It started suddenly on May 8 UTC (no issues on May 7 or before).

Managed clients: RHEL/CentOS 7, Python 2.7.5, MySQL-python 1.2.5
Source: AWX, Ansible core 2.12.5, community.mysql 3.7.0

I can work around it by removing MySQL-python on the clients and installing python2-PyMySQL.

Our execution environment image has not changed in over a month, so I'm skeptical that this has anything to do with 3.7.0. (EDIT: see my comment here.) Ansible playbooks are also unchanged. No package/configuration changes on the clients.

@alexgit2k
Copy link

Here it worked till last Thursday (4th) and it did not worked again on Monday (8th) unless we forced 3.6.0. And 3.7.0 was released last Friday (5th).

@31239899
Copy link

I stand corrected. It turns out AWX was re-pulling requirements and overriding what was in our execution environment (very unintuitive behavior!). So 3.7.0 is the problem after all. It seems it just took a few days from the tagged release here to make its way into Galaxy and down to our server before we saw problems.

@Andersson007
Copy link
Collaborator

Andersson007 commented May 16, 2023

Hi everyone, thanks for the issue report and the discussion!

@Jorge-Rodriguez i think this thing was introduced by #177, would you like to take a look? Is it what we expected?

@betanummeric
Copy link
Member

@paulh-rtr Can you provide the full call of community.mysql.mysql_user with all arguments? You can censor secret values.

@alexgit2k
Copy link

@betanummeric Here is our configuration:

- name: MariaDB users
  community.mysql.mysql_user:
    login_user: root
    login_password: "{{ mariadb_root_password }}"
    name: "{{ item.name }}"
    host: "{{ item.host | default('localhost') }}"
    password: "{{ item.password }}"
    priv: "{{ item.priv | default('*.*:USAGE') }}"
    state: "{{ item.state | default('present') }}"
    append_privs: "{{ item.append_privs | default('no') }}"
    encrypted: "{{ item.encrypted | default('no') }}"
  with_items: "{{ mariadb_users }}"
  no_log: true

With

mariadb_users:
  - name: "{{ dbuser }}"
    password: "{{ dbpass }}"
    host: localhost
    priv: '*.*:ALL'
  - name: "{{ dbuser_dbmanage }}"
    password: "{{ dbpasse_dbmanage }}"
    host: '%'
    priv: '*.*:ALL'

@Andersson007
Copy link
Collaborator

@Jorge-Rodriguez fyi, we're working on solving this, no worries

@Andersson007
Copy link
Collaborator

Hey everyone! I've just released @betanummeric 's patch in 3.7.1 https://galaxy.ansible.com/community/mysql.

It's already available on Galaxy for manual installation and it'll go to the next minor release of Ansible 7 tomorrow.
Could anyone please check if now everything works as expected?

@alexgit2k
Copy link

Same error with 3.7.1: Exception message: 'database' is an invalid keyword argument for this function

I checked to make sure that 3.7.1 was used:

$ vagrant ssh -c 'grep version .ansible/collections/ansible_collections/community/mysql/MANIFEST.json'
  "version": "3.7.1",

I am using MySQL-Python version 1.2.5. The problem is that the version-check is not valid:

if mysql_driver.version_info[0] < 2 and mysql_driver.version_info[1] < 1:
# for MySQLdb < 2.1.0, use 'db' instead of 'database' and 'passwd' instead of 'password'

Must be replaced by:

if mysql_driver.version_info[0] < 2 or (mysql_driver.version_info[0] == 2 and mysql_driver.version_info[1] < 1):

It worked after applying this.

@betanummeric
Copy link
Member

@alexgit2k Sorry, we will fix that.

@Andersson007
Copy link
Collaborator

@alexgit2k , released 3.7.2, could you please try it? thanks!

@alexgit2k
Copy link

@Andersson007 Tried again with 3.7.1 where it failed and then with 3.7.2 which works now. Thank you very much!

@Andersson007
Copy link
Collaborator

@Andersson007 Tried again with 3.7.1 where it failed and then with 3.7.2 which works now. Thank you very much!

@alexgit2k great, thanks for testing and confirming!

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

Successfully merging a pull request may close this issue.

5 participants