MYSQL - moduli


Mysql - Asentaa Mysql:n ja ylläpitää sitä. Asettaa mysql-root salasanan, jos ei vielä olemassa.


Ladattavissa täältä.

Käyttöjärjestelmät:

Testattu seuraavilla käyttöjärjestelmillä:


Xubuntu 12.10 32-bit

Ubuntu 12.04 LTS 64-bit

Debian 6.0 64-bit


Rakenne:

mysql
├── manifests
│   ├── config.pp
│   ├── init.pp
│   ├── install.pp
│   ├── params.pp
│   └── service.pp
└── README

README

########################
# Puppet module: mysql #
########################

This module installs and manages mysql-server.
It also adds mysql root password.

######################
# TODO before using  #
######################

Check mysql::params for wanted specifications.
Change atleast '$password'.

################
# Sample usage #
################

include mysql

##########
# Author #
##########

Made by Sampo Tyllilä <sampo.tyllila@gmail.com>

###########
# License #
###########

This software is distributed under the GNU General Public License version 2 or any later version.
http://www.gnu.org/licenses/

Manifests kansion sisältö:


init.pp

# == Class: mysql
#
# This module manages mysql-server.
#
# === Parameters
#
# [*package*]  - The name of the package to install.
# [*service*]  - The name of the managed service.
# [*password*] - The password for mysql-root.
#
# === Examples
#
# See README for details.
#
# === Author
#
# Sampo Tyllilä 
#
class mysql (
        $package  = $mysql::params::package,
        $service  = $mysql::params::service,
        $password = $mysql::params::password
)       inherits mysql::params {

        include mysql::params, mysql::install, mysql::service, mysql::config

}

install.pp

# == Class: mysql::install
#
# This module installs mysql-server.
#
# === Parameters
#
# [*package*] - The name of the package to install.
#
# === Author
#
# Sampo Tyllilä 
#
class mysql::install {
        package { $package:
                ensure     => latest,
        }
}

service.pp


# == Class: mysql::service
#
# This class manages mysql-server service.
#
# === Parameters
#
# [*service*] - The name of the managed service.
#
# === Requires
#
# The mysql::install class.
#
# === Author
#
# Sampo Tyllilä 
#
class mysql::service {
        service { $service:
                ensure  => running,
                enable  => true,
                require => Class['mysql::install'],
        }
}

config.pp

# == Class: mysql::config
#
# This class sets mysql-root password if not already set.
#
# === Parameters
#
# [*password*] - The password for mysql-root.
#
# === Subscribes
#
# The mysql::install class
#
# === Author
#
# Sampo Tyllilä 
#
class mysql::config {
        exec { 'set-mysql-password':
                subscribe   => Class['mysql::install'],
                refreshonly => true,
                unless      => "mysqladmin -uroot -p${password} status",
                path        => '/bin:/usr/bin',
                command     => "mysqladmin -uroot password ${password}",
        }
}

params.pp

# == Class: mysql::params
#
# This class manages the parameters of this mysql module.
#
# === Parameters
#
# [*package*]  - The name of the package to install.
# [*service*]  - The name of the managed service.
# [*password*] - The password for mysql-root.
#
# === Author
#
# Sampo Tyllilä 
#
class mysql::params {
        $package  = 'mysql-server'
        $service  = 'mysql'
        $password = 'ToBeChanged'
}