[BUG] mysql_user.present won't work on Debian12 with MariaDB 11.10 OOTB as installation of salt-pip's mysqlclient fails due to missing dependencies
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
I have a Debian12 with salt installed by following this guide (but I also tried with bootstrap and it failed too) and MariaDB 10.11 installed using the following repo (in salt state language):
install MariaDB's 10.11 repo:
pkgrepo.managed:
- humanname: MariaDB 10.11
- name: deb [signed-by=/usr/share/keyrings/mariadb.gpg] http://mirror.mariadb.org/repo/10.11/debian/ bookworm main
- dist: bookworm
- file: /etc/apt/sources.list.d/mariadb.list
- gpgcheck: 1
- key_url: http://mirror.mariadb.org/PublicKey_v2
- aptkey: False
Install MariaDB server and client:
pkg.installed:
- names:
- mariadb-server
- mariadb-client
- require:
- pkgrepo: install MariaDB's 10.11 repo
when I tried to use the mysql_present module like so:
add mysql test user:
mysql_user.present:
- name: test
- host: localhost
it failed with:
# salt 'test2' state.apply states.mysql.test
test2:
----------
ID: add mysql test user
Function: mysql_user.present
Name: test
Result: False
Comment: State 'mysql_user.present' was not found in SLS 'states.mysql.test'
Reason: 'mysql_user' __virtual__ returned False: mysql module could not be loaded
Changes:
After a lot of debugging/googling, I realised that salt minion pip's mysqlclient was missing. I tried to install it manually and got (removed most output to save space):
# salt-pip install mysqlclient
Collecting mysqlclient
...
File "/tmp/pip-build-env-8g8j3ryq/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
File "<string>", line 156, in <module>
File "<string>", line 49, in get_config_posix
File "<string>", line 28, in find_package_name
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
Getting requirements to build wheel did not run successfully.
exit code: 1
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
[notice] A new release of pip is available: 23.3.2 -> 25.0.1
[notice] To update, run: /opt/saltstack/salt/bin/python3.10 -m pip install --upgrade pip
root@test2:~#
After a lot of googling about potential missing dependencies, I had to first install the following:
- libmariadb-dev
- build-essential
- pkg-config
and then everything worked as expected.
Setup
- I've included everything in the description section, what I want to add (without affecting the result) is that the master is running on SmartOS and is running
3006.7nb1. - as explained, both MariaDB and Salt on the minion are installed NOT with the default system's packages
- The minion is running on a Debian12 image within a Bhyve VM on a SmartOS host (image_uuid: 3089fa2a-ee6e-44e5-aeb2-2cb985f9eb61 , version: 20250123).
Please be as specific as possible and give set-up details.
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
Everything is explained in the Description section. To summarise, install MariaDB 10.11 on the minion:
- sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl –y
- curl -fsSL http://mirror.mariadb.org/PublicKey_v2 | gpg --dearmor | tee /usr/share/keyrings/mariadb.gpg > /dev/null
- echo "deb [signed-by=/usr/share/keyrings/mariadb.gpg] http://mirror.mariadb.org/repo/10.11/debian/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/mariadb.list
- apt update
- apt install mariadb-server mariadb-client
- mysql_secure_installation
- mariadb-upgrade
- systemctl enable mariadb
Install salt on the minion (following [salt's guide](https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/linux-deb.html)):
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://packages.broadcom.com/artifactory/api/security/keypair/SaltProjectKey/public | sudo tee /etc/apt/keyrings/salt-archive-keyring.pgp
- curl -fsSL https://github.com/saltstack/salt-install-guide/releases/latest/download/salt.sources | sudo tee /etc/apt/sources.list.d/salt.sources
- apt update
- echo 'Package: salt-*
Pin: version 3006.*
Pin-Priority: 1001' | sudo tee /etc/apt/preferences.d/salt-pin-1001 - apt-get install salt-minion
- apt-mark hold salt-minion # not necessary
- systemctl enable salt-minion && systemctl start salt-minion
Then, configure your minion to communicate with the master and add the following state to the master:
add mysql test user:
mysql_user.present:
- name: test
- host: localhost
and then send that state to the minion, to see this:
# salt 'test2' state.apply states.mysql.test
test2:
----------
ID: add mysql test user
Function: mysql_user.present
Name: test
Result: False
Comment: State 'mysql_user.present' was not found in SLS 'states.mysql.test'
Reason: 'mysql_user' __virtual__ returned False: mysql module could not be loaded
Changes:
Summary for test2
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 0.000 ms
ERROR: Minions returned with non-zero exit code
[root@salt-master /var/salt/file-roots/states/mysql]#
Expected behavior
Ideally I would have expected the mysql_user state to have worked OOTB, but I understand that there's a dependency on MySQL, so I would have expected salt-docs to explain how/what to install as a dependency on some known distros. The docs are mentioning MySQLdb python module, I'm not even sure if I evntually installed that dependency for it to work. And as IIUC salt uses its own python env, some reference to some guide on installing dependencies with salt-pip would help too.
If it was for a less known service, I wouldn't have bothered writing this issue, but this is for MariaDB on a Debian system, so I think people expect this configuration to run smoothly.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions Report
AFTER having installed mysqlclient
salt --versions-report
root@test2:~# salt-minion --versions-report
Salt Version:
Salt: 3006.9
Python Version:
Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]
Dependency Versions:
cffi: 1.14.6
cherrypy: 18.6.1
cryptography: 42.0.5
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.17.0
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: debian 12 bookworm
locale: utf-8
machine: x86_64
release: 6.1.0-30-amd64
system: Linux
version: Debian GNU/Linux 12 bookworm
and on the SmartOS server:
salt-master --versions-report
Salt Version:
Salt: 3006.7
Python Version:
Python: 3.10.16 (main, Dec 25 2024, 03:50:59) [GCC 13.3.0]
Dependency Versions:
cffi: 1.17.1
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.1.0
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.2
pycparser: 2.22
pycrypto: 3.21.0
pycryptodome: 3.21.0
pygit2: Not Installed
python-gnupg: Not Installed
PyYAML: 6.0.2
PyZMQ: 26.2.0
relenv: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.5
System Versions:
dist: pkgsrc 5.11
locale: utf-8
machine: i86pc
release: 5.11
system: SunOS
version: release: 2024Q 5.11
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Python: 3.10.14 (main, Jun 26 2024, 11:44:37) [GCC 11.2.0]
cffi: 1.14.6
cherrypy: 18.6.1
cryptography: 42.0.5
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.17.0
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
dist: debian 12 bookworm
locale: utf-8
machine: x86_64
release: 6.1.0-30-amd64
system: Linux
version: Debian GNU/Linux 12 bookworm
Salt: 3006.7
Python: 3.10.16 (main, Dec 25 2024, 03:50:59) [GCC 13.3.0]
cffi: 1.17.1
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.1.0
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.2
pycparser: 2.22
pycrypto: 3.21.0
pycryptodome: 3.21.0
pygit2: Not Installed
python-gnupg: Not Installed
PyYAML: 6.0.2
PyZMQ: 26.2.0
relenv: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.5
dist: pkgsrc 5.11
locale: utf-8
machine: i86pc
release: 5.11
system: SunOS
version: release: 2024Q 5.11
PASTE HERE
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mysql_user state and its virtual dependency check, then review the salt-pip installation guidance and the salt.states.mysql_grants documentation mentioned in the report. Reproduce the failure on Debian 12 with MariaDB 10.11 using the supplied installation steps. Done means the dependency requirements and supported installation path are documented or the OOTB failure is resolved, with the mysql_user state loading successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- debian, mariadb, python
- Domain
- databases, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100