Skip to content

First installation fails when installaing MySQL since 44106d1 #1702

@david-barbion

Description

@david-barbion

Describe the Bug

On the first installation of mysql (no package present) the enforcement of the catalog throws this error:

Error: Command mysql_install_db is missing
Error: /Stage[main]/Mysql::Server::Installdb/Mysql_datadir[/data/mysql]/ensure: change from 'absent' to 'present' failed: Command mysql_install_db is missing (corrective)

On the second run, puppet initializes the MySQL database correctly.

Expected Behavior

MySQL installation should not fail on the first puppet run.

Steps to Reproduce

Steps to reproduce the behavior:

  1. on the agent, make sure mysql packages are removed
  2. run puppet
  3. see the error
  4. run puppet again
  5. see the successful installation

Environment

  • mysql puppet module version 16.3.0 (only that version)
  • rhel9.7

Additional Context

The problem seems linked to this: 44106d1#diff-ee978e1e1ef2dc80b6edfd59ddb57eca6197a69e614519047e83e7f57ee9d628R61-R90

@mysqld_version_string ||= Facter.value(:mysqld_version) || ''

If the mysql server package is not installed at the moment of the run, facter returns nil for the fact mysqld_version so @mysqld_version_string will be '' which gives an error later.
Facter evaluate facts one time and it's done long before the beginning of the catalog enforcement.
The debug trace:

Debug: Facter: value for mysqld_version is still nil
Debug: Facter: Loading all internal facts
Debug: Facter: Executing command: /bin/rpm -q mysql-community-server MariaDB-server mariadb-server rh-mariadb102-mariadb-server
Debug: Facter: value for mysqlpkg is still nil
Debug: Facter: Loading all internal facts
Debug: Facter: resolving fact with user_query: mysqld_version
Debug: Facter: Searching fact: mysqld_version in file: mysqld_version.rb
Debug: Facter: List of resolvable facts: [#<Facter::SearchedFact:0x00007f4f493cab50 @name="mysqld_version", @fact_class=nil, @user_query="mysqld_version", @type=:custom, @file=nil>]
Debug: Facter: value for mysqld_version is still nil
Debug: Facter: Loading all internal facts
Debug: Facter: Searching fact: mysqld_version in core facts and external facts

Before this change, we could read:

@mysqld_version_string ||= Facter.value(:mysqld_version) || mysqld('-V')

See the last part (mysqld('-V')). That goes executed at the right moment, when the package is installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions