1

I have a docker container with jenkins, that uses ansible for some automated commands. One specific commands connects to a database on a different docker container and perform some checks (as cleaning up a database). These commands were working fine for long, but now I am facing an issue when trying to connect to MySQL. The issue is a very well known error:

 "msg": "unable to connect to database, check login_user and login_password are correct or /var/jenkins_home/.my.cnf has the credentials. Exception message: __init__() got an unexpected keyword argument 'password'"

Obviusly, seems a connection error related to credentials. My first approach to solve it, is to check the password to be sure that is correct. I have reviewed and I can connect from jenkins docker container using mysql client with the same credentials provided to the ansible script. Also 'var/jenkins_home/.my.cnf' has the correct credentials now (still I prefer to put these credentials on the script anyways as changes between different scripts, but anyways, I have updated it). But none of them has solved the issue.

I have search any suggestion to fix it, and I have also checked login_unix_socket to see if some updates has change the path of the socket as suggested somewhere, but no luck. Same issue.

Current versions inside the docker container:

Jenkins: 2.291
Ansible: 2.10.9
Python: 2.7

The command executed on ansible is as simple as:

- name: delete existing usmo database
  delegate_to: localhost
  mysql_db:
    login_user={{ jenkins_database_login_user }}
    login_password={{ jenkins_database_login_password }}
    login_host={{ jenkins_database_host }}
    name={{ jenkins_database }}
    state=absent

All variables {{ jenkins_database_login_user }}, {{ jenkins_database_login_password }}, {{ jenkins_database_host }} and {{ jenkins_database }} are checked and have the correct value. Also this script has been working by years. The only thing that can happened is that I have updated the jenkins docker container (new jenkins version, and maybe some new SO package versions) but the used versions posted before seems not to be the problem.

Note that all my ansible scripts that access to a database (different databases with different credentials) are failing. Then I am assuming that can be an update of something, but I have no clue. I have also checked the Ansible official documentation for musql_db but I do not see any changes that affects my script.

This is the complete verbose answer from ansible:

fatal: [XXX]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "ca_cert": null, 
            "check_hostname": null, 
            "check_implicit_admin": false, 
            "client_cert": null, 
            "client_key": null, 
            "collation": "", 
            "config_file": "/var/jenkins_home/.my.cnf", 
            "config_overrides_defaults": false, 
            "connect_timeout": 30, 
            "dump_extra_args": null, 
            "encoding": "", 
            "force": false, 
            "hex_blob": false, 
            "ignore_tables": [], 
            "login_host": "myhost", 
            "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "login_port": 3306, 
            "login_unix_socket": "/var/lib/mysqld/mysqld.sock", 
            "login_user": "myuser", 
            "master_data": 0, 
            "name": [
                "database_name"
            ], 
            "quick": true, 
            "restrict_config_file": false, 
            "single_transaction": false, 
            "skip_lock_tables": false, 
            "state": "absent", 
            "target": null, 
            "unsafe_login_password": false, 
            "use_shell": false
        }
    }, 

Where database_name, myuser and myhost are not the real variables as I have hide them for security.

Any clue or suggestion that can point me out what can be wrong will be highly appreciated.

2
  • Your .yml is incorrectly indendet May 11, 2021 at 10:32
  • Thanks for your comment. But I think that is more a copy paste issue here that a script indentation. Let me update the question to avoid extra confusion.
    – King Midas
    May 11, 2021 at 10:35

1 Answer 1

0

Ok. Today I have seen on Jenkins that there is an update (2.293) and I have updated the docker container with the new version. Now seems that everything is working fine again, and the issue with the mysql connector has disappear. I do not know how the previous version was affecting to my ansible script (maybe some python package versions) but on the new version seems that everything is corrected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .