community.mysql
community.mysql copied to clipboard
Unable to set root Password when root starts off with the `auth_socket` plugin
SUMMARY
When first starting with MySQL 5.7, I am trying to set the root password. But it does not work due to root having the auth_socket
plugin. I am new in Ansible, so I might have done something wrong.
ISSUE TYPE
- Bug Report
COMPONENT NAME
mysql_user
ANSIBLE VERSION
ansible 2.10.15
config file = /srv/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0]
COLLECTION VERSION
# /root/.ansible/collections/ansible_collections
Collection Version
--------------- -------
community.mysql 2.3.1
CONFIGURATION
ANSIBLE_NOCOWS(/srv/ansible/ansible.cfg) = True
ANSIBLE_PIPELINING(/srv/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/srv/ansible/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=3600s -o PreferredAuthentications=publickey -o ForwardAgent=yes
CACHE_PLUGIN(/srv/ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/srv/ansible/ansible.cfg) = ~/.ansible/facts
DEFAULT_CALLBACK_WHITELIST(/srv/ansible/ansible.cfg) = ['ansible.posix.profile_tasks']
DEFAULT_FORKS(/srv/ansible/ansible.cfg) = 50
DEFAULT_GATHERING(/srv/ansible/ansible.cfg) = smart
DEFAULT_HOST_LIST(/srv/ansible/ansible.cfg) = ['/srv/ansible/bin/ansible_hosts.php']
DEFAULT_LOG_PATH(/srv/ansible/ansible.cfg) = /root/logs/ansible.log
DEFAULT_REMOTE_USER(/srv/ansible/ansible.cfg) = root
DEFAULT_STDOUT_CALLBACK(/srv/ansible/ansible.cfg) = debug
DEFAULT_SYSLOG_FACILITY(/srv/ansible/ansible.cfg) = LOG_LOCAL2
DEFAULT_VAULT_PASSWORD_FILE(/srv/ansible/ansible.cfg) = /root/.ansible/.vault_pass
DEPRECATION_WARNINGS(/srv/ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/srv/ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/srv/ansible/ansible.cfg) = True
RETRY_FILES_SAVE_PATH(/srv/ansible/ansible.cfg) = /root/.ansible
OS / ENVIRONMENT
Ubuntu 20.04 with the mysql 5.7 repo.
Server version: 5.7.34-log MySQL Community Server (GPL)
STEPS TO REPRODUCE
- name: Set MySQL root Password
community.mysql.mysql_user:
name: root
host: localhost
password: "{{ mysql_password }}"
state: present
debugger: always
when: no_root_password.rc == 0
I have also tried setting plugin: mysql_native_password
with no result.
Switching to a manual query works but is sloppy.
- name: Set MySQL root password
shell: mysql -u root --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY '{{ mysql_password }}';"
EXPECTED RESULTS
Root user gets the mysql_native_password
plugin
and the authentication_string
is filled.
ACTUAL RESULTS
Nothing happens the tasks returns OK.
Hello @toonvd from the actual code in module_utils/user.py (in branch main) I would say the code would exactly try this alter user. (and if it fails because of the empty password it even try update mysql.user directly) can you retry with the newest version of the module?