Puppet setup database

Puppet is failing to install mariadb-server on the db server,

my .pp file is looking like this:

node ‘stdb01.stratos.xfusioncorp.com’ {
include mysql_database
}
class mysql_database {
package { ‘Mariadb-server’:
ensure => installed,
}
service { ‘mysql’:
ensure => running,
enable => true,
subscribe => File[‘/etc/my.cnf.d/server.cnf’],
}
file { ‘/etc/my.cnf.d/server.cnf’:
ensure => file,
mode => 644,
source => ‘puppet:///conf_files/mariadb/server.cnf’,
}
mysql::db { ‘kodekloud_db4’:
user => ‘kodekloud_pop’,
password => ‘YchZHRcLkL’,
host => ‘localhost’,
grant => [‘FULL’],
}
}

here is the error log:

[root@stdb01 manifests]# puppet agent -tv
Info: Using configured environment ‘production’
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for stdb01.stratos.xfusioncorp.com
Info: Applying configuration version ‘1593521499’
Error: Execution of ‘/bin/yum -d 0 -e 0 -y install Mariadb-server’ returned 1: Error: Nothing to do
Error: /Stage[main]/Mysql_database/Package[Mariadb-server]/ensure: change from ‘purged’ to ‘present’ failed: Execution of ‘/bin/yum -d 0 -e 0 -y install Mariadb-server’ returned 1: Error: Nothing to do
Error: Systemd start for mysql failed!
journalctl log for mysql:
– Logs begin at Tue 2020-06-30 12:43:55 UTC, end at Tue 2020-06-30 12:51:47 UTC. –
Jun 30 12:51:47 stdb01 systemd[1]: Failed to load configuration for mysql.service: No such file or directory
Jun 30 12:51:47 stdb01 systemd[1]: Collecting mysql.service
Jun 30 12:51:47 stdb01 systemd[1]: Failed to load configuration for mysql.service: No such file or directory
Jun 30 12:51:47 stdb01 systemd[1]: Collecting mysql.service

Error: /Stage[main]/Mysql_database/Service[mysql]/ensure: change from ‘stopped’ to ‘running’ failed: Systemd start for mysql failed!
journalctl log for mysql:
– Logs begin at Tue 2020-06-30 12:43:55 UTC, end at Tue 2020-06-30 12:51:47 UTC. –
Jun 30 12:51:47 stdb01 systemd[1]: Failed to load configuration for mysql.service: No such file or directory
Jun 30 12:51:47 stdb01 systemd[1]: Collecting mysql.service
Jun 30 12:51:47 stdb01 systemd[1]: Failed to load configuration for mysql.service: No such file or directory
Jun 30 12:51:47 stdb01 systemd[1]: Collecting mysql.service

Notice: /Stage[main]/Mysql::Client::Install/Package[mysql_client]/ensure: created
Error: Could not prefetch mysql_database provider ‘mysql’: Execution of ‘/bin/mysql -NBe show databases’ returned 1: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
Error: Failed to apply catalog: Execution of ‘/bin/mysql -NBe show databases’ returned 1: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)

any idea what am I missing?
Thanks

Hi,
Currently I have this task and Iam stuck at the same issue. What am I doing wrong?

Hi @faisalbasha1982 unfortunately I couldnt resolve this tasks. and honestly I am curious to know what I am doing wrong there as well.

The package you’re trying to install has a uppercase M. And the MariaDB service name is mariadb

U are closer but still one thing is missing to use mysql::db

1 Like
  1. Mariadb-server should be small letters.
  2. To use your own cnf file you must configure puppet same way. Since the task did not instruct that, you can ignore that.
  3. grant ==> [‘ALL’],
  4. Ensure the mysql module also installed on the puppet master server to use mysql::db.

@ASAAC I am using below pp file:

[root@jump_host manifests]# cat beta.pp

node 'stdb01.stratos.xfusioncorp.com' {
include mysql_database
}

class mysql_database {
    package {'mariadb-server':
        ensure => installed,
    }
    service { 'mysql':
        ensure => running,
        enable => true,
        subscribe => File['/etc/my.cnf.d/server.cnf'],
    }
    mysql::db { 'kodekloud_db4':
    user => 'kodekloud_pop',
    password => 'TmPcZjtRQx',
    host => 'localhost',
    grant => ['ALL'],
    }
}
[root@jump_host manifests]# 

Can you please guide, how to include mysql::db in this pp file?

Do we need to create a separate pp file for master node (Jump_host)?

mysql::db is a puppet module mysql on master.
puppet module install puppetlabs/mysql to install that module. Which I think it’s already installed on master(jump server).
Also, the question was mariadb not mysqld, hence the service should be mariadb. Remove the subscribe==> line, since the question did not state to use our own cnf file.

1 Like

Thanks so much @ASAAC Its really helped. Just now succeeded in this task.

Thanks once again for your help.

1 Like

you’re welcome @balu.networks7.