MariaDB Puppet Module - KeegMitch/Operations-Engineering-group-c GitHub Wiki
Module Setup
- Create module structure in
/etc/puppetlabs/code/modulesdirectory in yourmgmtserver:
mariadb
mariadb/files/50-server.cnf
mariadb/manifests/init.pp
mariadb/manifests/install.pp
mariadb/manifests/config.pp
mariadb/manifests/service.pp
mariadb/templates
To get a copy of the 50-server.cnf file, go to the OE2 repository
Structure should look like this:
Create a MariaDB install class
- Inside your
install.ppfile, put in the following code:
class mariadb::install {
package { "mariadb-server":
ensure => present,
require => User["mysql"],
}
user { "mysql":
ensure => present,
comment => "MariaDB user",
gid => "mysql",
shell => "/bin/false",
require => Group["mysql"],
}
group { "mysql":
ensure => present,
}
}
Create a MariaDB config class
- Inside your
config.ppfile, put in the following code:
class mariadb::config {
file { "/etc/mysql/mariadb.conf.d/50-server.cnf":
ensure => present,
source => "puppet:///modules/mariadb/50-server.cnf",
mode => "0444",
owner => "root",
group => "root",
require => Class["mariadb::install"],
notify => Class["mariadb::service"],
}
}
Create a MariaDB service class
- Inside
service.ppput in the following code:
class mariadb::service {
service { "mysql":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["mariadb::config"],
}
}
Combine the classes in init.pp and Apply to DB server
- Add this to the init.pp file inside the module:
class mariadb {
include mariadb::install, mariadb::config, mariadb::service
}
- Add the module to the
site.ppfile:
- Test and connect the puppet agent using our alias,
connect_puppet_agentinside thedbserver
Note: in this screenshot the command used here has the alias connect_puppet_agent
Note: To access the puppet modules directory, I have now added an alias called puppet_modules , which directs us to the directory where we configure our own modules