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

[BUG] mysql.client state does not work out of the box #267

Open
daks opened this issue Apr 14, 2022 · 2 comments
Open

[BUG] mysql.client state does not work out of the box #267

daks opened this issue Apr 14, 2022 · 2 comments
Labels

Comments

@daks
Copy link
Member

daks commented Apr 14, 2022

Your setup

Formula commit hash / release tag

master version b9b8792

Versions reports (master & minion)

Using Kitchen setup from the formula

Pillar / config used

No pillar (test/salt/pillar/mysql.sls empty)
Kitchen.yml changed to call mysql.client state instead of the meta-state mysql


Bug details

Describe the bug

When running state mysql.client it executes mysql.config which returns an Error if no pillar is provided

                 ID: mysql_config
           Function: file.managed
               Name: /etc/mysql/my.cnf
             Result: False
            Comment: Parent directory not present
            Started: 16:18:55.037018
           Duration: 79.531 ms
            Changes:   

Steps to reproduce the bug

You can see here the code https://github.com/daks/mysql-formula/tree/bug-client and the CI pipeline https://gitlab.com/daks/mysql-formula/-/pipelines/516218792

Expected behaviour

I expect this state to at minima install client packages. I don't necesary expect it to manage configuration but if it needs to be done, it should executed without errors

Attempts to fix the bug

None at the moment. I think the bug comes from one of the "if" in the state mysql.config

Additional context

@daks daks added the bug label Apr 14, 2022
@andrii-suse
Copy link

andrii-suse commented Apr 25, 2023

fyi (not sure why) it happens at least on Debian 11, but not on openSUSE Leap.
Ah, on Leap the error is shown later, when you try to use client:

mariadb -V
mariadb: Can't read dir of '/etc/my.cnf.d' (Errcode: 2 "No such file or directory")

@SkypLabs
Copy link

I just hit this issue and did some work investigating it. It turns out a simple workaround exists:

# Pillar data.
mysql:
  config_directory: /etc/mysql

The configuration directory is only created if the config_directory entry is present in the pillar data:

{%- if "config_directory" in mysql %}
mysql_config_directory:
file.directory:
- name: {{ mysql.config_directory }}
{%- if os_family in ['Debian', 'Gentoo', 'RedHat'] %}
- user: root
- group: root
- mode: 755
{%- endif %}
- makedirs: True

The problem comes from the absence of a default value for Debian:

Debian:
service: mysql

Unlike CentOS and Fedora (lines 19 and 35):

CentOS:
config_directory: /etc/my.cnf.d/
server_config:
file: server.cnf
sections:
mysqld_safe:
log_error: /var/log/mysql/mysqld.log
pid_file: /var/run/mysql/mysqld.pid
mysqld:
socket: /var/lib/mysql/mysql.sock
bind_address: 127.0.0.1
Fedora:
serverpkg: mariadb-server
clientpkg: mariadb
service: mariadb
pythonpkg: python2-mysql
config_directory: /etc/my.cnf.d/

I have only tested this workaround on Debian 11 so far.

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

No branches or pull requests

3 participants