MariaDB Puppet Module - KeegMitch/Operations-Engineering-group-c GitHub Wiki

Module Setup

  1. Create module structure in /etc/puppetlabs/code/modules directory in your mgmt server:
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

image

Structure should look like this:

image

Create a MariaDB install class

  1. Inside your install.pp file, 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,
  }
}

image

Create a MariaDB config class

  1. Inside your config.pp file, 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"],
  }
}

image

Create a MariaDB service class

  1. Inside service.pp put in the following code:
class mariadb::service {
  service { "mysql":
    ensure     => running,
    hasstatus  => true,
    hasrestart => true,
    enable     => true,
    require    => Class["mariadb::config"],
  }
}

image

Combine the classes in init.pp and Apply to DB server

  1. Add this to the init.pp file inside the module:
class mariadb {
  include mariadb::install, mariadb::config, mariadb::service
}

image

  1. Add the module to the site.pp file:

image

  1. Test and connect the puppet agent using our alias, connect_puppet_agent inside the db server

image

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