GithubHelp home page GithubHelp logo

vstone / puppet-percona Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arioch/puppet-percona

4.0 5.0 9.0 210 KB

EOL: Please use puppetlabs mysql.

License: Other

Ruby 60.28% Puppet 33.91% HTML 5.81%

puppet-percona's Introduction

Build Status

Puppet Percona

Install a percona (mysql) server and manage users/rights/databases.

Requirements

Debian/Ubuntu

Basic usage

Client only

class { 'apt': }
class { 'percona': }

Class['apt'] ->
Class['percona']

Client and server

class { 'apt': }
class { 'percona': server => true, }

Class['apt'] ->
Class['percona']

Configuration

Using percona hashes

To make sure we allow maximal flexibility while using this module, you can now specify my.cnf options using a hash. You can do so in 2 different places:

You can specify the default_configuration parameter on percona::params and/or you can specify the configuration parameter on percona. Why can you use 2 different places?

You can use percona::params to set options globally over your complete infrastructure and all hosts connected to it. You can do so by defining it outside the scope of your node (a defaults.pp or a class that is included on every node, ...). Then, you could overwrite these global options for each server specifically when you define the percona resource.

Not enough possibilities? Store your configuration in hiera and directly use the hash returned by the hiera function and pass it through. This allows you to specify the configuration of your server on pretty much any level you want.

How do these hashes look like? The (nested) hash you pass to percona::params should look like this:

$hash = {
  '5.1'    => {
    'mysqld/option' => '5.1 specific value',
  },
  '5.5'    => {
    'mysqld/option'  => '5.5 specific value',
    'mysqld/option2' => 'only exists in 5.5'
  },
  'global' => {
    'mysqld/global'     => 'global option that works for any percona version',
    'xtrabackup/global' => 'global option in the xtrabackup section'
  },
}

class {'percona::params':
  default_configuration => $hash,
}

For options that get passed to percona using the configuration parameter, you do not need to nest the parameters since you will have picked the percona version to use at this point.

$configuration = {
  'mysqld/option' => 'something',
  'mysqld/option2' => { 'ensure' => 'absent' },
}

class {'percona':
  percona_version => '5.5',
  configuration   => $configuration,
}

For more information on the structures you can use, please see the docs of the percona_hash_merge() function.

An example hiera.yaml file:

(Note: we need to put 5.5 and 5.1 between quotes or puppet they are turned into numbers which does not play well with the module.

percona_config_global:
  "5.5":
    character-set-server: utf8

  "5.1":
    default-character-set: utf8

  global:
    thread_concurrency: %{processorcount}
    default-storage-engine: 'InnoDB'

and in your manifests

class {'percona::params':
  default_configuration => hiera('percona_config_global', undef),
}

include percona

Using percona::conf

Before being able to use percona::conf, you should set the config_include_dir parameter. You can do this in percona::params or when calling percona.

For debian users, the config_include_dir has been defaulted to /etc/mysql/conf.d/

# This will create a file in the config_folder for each entry.
percona::conf {
  'innodb_file_per_table': content => "[mysqld]\ninnodb_file_per_table";
  'query_cache_size':      content => "[mysqld]\nquery_cache_size = 32M";
  'table_open_cache':      content => "[mysqld]\ntable_open_cache = 768";

  'foo':
    ensure  => present,
    content => template ("percona/custom1.cnf.erb");
  'bar':
    ensure  => absent,
    content => template ("percona/custom2.cnf.erb");
}

Databases and permissions.

percona::database { 'dbfoo':
  ensure => present;
}

percona::rights {'userbar on dbfoo':
  priv     => 'select_priv',
  host     => 'localhost',
  database => '*',
  password => 'default',
}

# You can ommit the user, host and database parameter if you use this format:
percona::rights {'user@localhost/dbname':
  priv => 'all'
}

Unit testing

Unit testing is done using rspec-puppet:

bundle install && bundle exec rspec

Links

puppet-percona's People

Contributors

abraham1901 avatar arioch avatar bigon avatar eloipoch avatar larsfronius avatar roidelapluie avatar visibilityspots avatar vstone avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

puppet-percona's Issues

Empty 'mysql' database

Hello,
I installed percona-server-server-5.6 using this module but I found the first time I install it, the 'mysql' DB/directory is empty (so there's no mysql.users table) and mysql will fail to start.

if I

apt-get remove percona-server-server-5.6
dpkg -purge percona-server-server-5.6

and apply the manifest again, it works.

Probably I'm doing something wrong, but I'm not sure what.

This is the manifest I'm using:

import "percona-source.pp"
include apt::percona_sources


class { 'apt': }
class { 'percona':
  server => true,
  percona_version => '5.6',
  config_dir_mode => "0755",
  config_file_mode => "0644",

}


include percona

Class['apt'] ->
Class['percona']

percona::database { 'overol_ar':
  ensure => present;
}
percona::database { 'overol_test_ar':
  ensure => present;
}
percona::database { 'overol_br':
  ensure => present;
}
percona::database { 'overol_mx':
  ensure => present;
}

percona::database { 'overol':
  ensure => present;
}

percona::conf {
  'innodb_file_per_table': content => "[mysqld]\ninnodb_file_per_table";
  'query_cache_size':      content => "[mysqld]\nquery_cache_size = 32M";
  'table_open_cache':      content => "[mysqld]\ntable_open_cache = 768";
}

package { 'libmysqlclient18.1':
  ensure => installed,
  require => Package["percona-server-server-5.6"],
}

package{ 'libmysqlclient-dev':
  ensure => installed,
  require => Package["percona-server-server-5.6"],
}

percona::rights {'properati on overol':
  priv => 'all',
  user => 'properati',
       host => 'localhost',
       database => 'X',
       password => 'X',
}


mysqld --help --verbose is deleting the pid file

Hi,

It seems that mysqld --help --verbose is deleting the pid file on disk. This is breaking the initscript status functionality and then makes puppet starting a 2nd instance of mysql...

An alternative would to use --print-defaults or mysqladmin variables instead, but the format is different.

According to lefred, this is fixed in mysql 5.6.

Grant option requires a password hash or plain text password.

The documentation mentions:

Databases and permissions.

percona::database { 'dbfoo':
 ensure => present;
}
percona::rights {'userbar on dbfoo':
 priv     => 'select_priv',
 host     => 'localhost',
 database => '*',
 password => 'default',
}
# You can ommit the user, host and database parameter if you use this format:
percona::rights {'user@localhost/dbname':
 priv => 'all'
}

However when I try this using:

  percona::rights {'[email protected].%/MyMusic%':
    priv => 'all'
  }

I get "Error: Could not retrieve catalog from remote server: Error 400 on SERVER: You must either provide the password hash to use or a plaintext password at /etc/puppet/modules/percona/manifests/rights.pp:97" as per this.

I didn't spend much time looking at this but do you agree this check is better suited after line 129 ?

puppet-percona conflicts with puppetlabs-mysql when both installed (mysql provider issues)

Hello

I have this simple class:

class percona::custom {

        apt::source { 'percona':
                location        => 'http://repo.percona.com/apt',
                release         => 'precise',
                repos           => 'main',
                key             => '1C4CBDCDCD2EFD2A',
                key_server      => 'keys.gnupg.net',
        }


        class { 'apt': }
        class { 'percona':
                server          => true,
                percona_version => '5.6',
        }

        percona::database { 'dbfoo':
                ensure => present;
        }

        percona::rights {'user@localhost/dbfoo':
                priv     => 'select_priv',
                host     => 'localhost',
                database => '*',
                password => 'default',
        }

        Class['apt'] -> Class['percona']

}

The package is installed without issues, but the creation of the DB fails with the following error:

Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter mgmt_cnf on Mysql_database[dbfoo] at /etc/puppet/modules/percona/manifests/database.pp:30 on node test.ish.co.za

I have the full error with debug enabled here:

http://pastebin.com/DXrp4zsp

Let me know if you need any more data. Thanks

Add a way to set root password

Hi,

The module should support a way to set root password. I should also add a /root/.my.cnf file that will allow scripts (including puppet) to transparently get access to the databases

The privileges 'process_priv,repl_client_priv' are not valid.

I am trying to set 2 permissions but I am getting the following error:

percona::rights {'newrelic@localhost':
                database => '*.*',
          priv     => ['process_priv', 'repl_client_priv'],
          password => 'xyz',
        }

puppet output:

/var/lib/puppet/lib/puppet/provider/percona_grant/mysql.rb:27: warning: class variable access from toplevel
/var/lib/puppet/lib/puppet/provider/percona_grant/mysql.rb:28: warning: class variable access from toplevel
/var/lib/puppet/lib/puppet/provider/percona_grant/mysql.rb:30: warning: class variable access from toplevel
Error: The privileges 'process_priv,repl_client_priv' are not valid. 
Error: /Stage[main]/Main/Node[mysqlserver]/Percona::Rights[newrelic@localhost]/Percona_grant[newrelic@localhost/*.*]/privileges: change from  to process_priv, repl_client_priv failed: The privileges 'process_priv,repl_client_priv' are not valid. 

Puppet 5 compatibility issue

Error: no parameter named 'mgmt_cnf' (file: /etc/puppetlabs/code/environments/production/modules/percona/manifests/database.pp, line: 25) on Mysql_database[xx] (file: /etc/puppetlabs/code/environments/production/modules/percona/manifests/database.pp, line: 25) on node xx
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Percona 5.6 at Debian 7

Hello!

I've installed modules:

/etc/puppet/modules
├── puppetlabs-apt (v1.4.2)
├── puppetlabs-stdlib (v4.1.0)
└── vStone-percona (v1.3.1)

created manifest:

node puppet-client {
apt::source { 'percona':
  location          => 'http://repo.percona.com/apt',
  release           => 'wheezy',
  repos             => 'main',
  key               => '1C4CBDCDCD2EFD2A',
  key_server        => 'keys.gnupg.net',
}

class { 'apt': }

class { 'percona':
    server => true,
    percona_version => '5.6',
}

Class['apt'] ->
Class['percona']
}

And got error:

# puppet agent -t 
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/mysql_facts.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/meminbytes.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Caching catalog for puppet-client.local
Info: Applying configuration version '1396942503'
Notice: /Stage[main]/Main/Node[puppet-client]/Apt::Source[percona]/Apt::Key[Add key: 1C4CBDCDCD2EFD2A from Apt::Source percona]/Exec[d862c9101408438167b0ad0d2b8622a9f35e344c]/returns: executed successfully
Notice: /Stage[main]/Main/Node[puppet-client]/Apt::Source[percona]/File[percona.list]/ensure: created
Info: /Stage[main]/Main/Node[puppet-client]/Apt::Source[percona]/File[percona.list]: Scheduling refresh of Exec[apt_update]
Notice: /Stage[main]/Apt::Update/Exec[apt_update]: Triggered 'refresh' from 1 events
Notice: /Stage[main]/Percona::Install/Package[percona-server-common-5.6]/ensure: ensure changed 'purged' to 'present'
Notice: /Stage[main]/Percona::Install/Package[percona-server-client-5.6]/ensure: ensure changed 'purged' to 'present'
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install percona-server-server-5.6' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  libaio1
Suggested packages:
  tinyca
The following NEW packages will be installed:
  libaio1 percona-server-server-5.6
0 upgraded, 2 newly installed, 0 to remove and 10 not upgraded.
Need to get 19.4 MB of archives.
After this operation, 70.9 MB of additional disk space will be used.
Get:1 http://ftp.by.debian.org/debian/ wheezy/main libaio1 amd64 0.3.109-3 [9150 B]
Get:2 http://repo.percona.com/apt/ wheezy/main percona-server-server-5.6 amd64 5.6.16-64.2-569.wheezy [19.4 MB]
Preconfiguring packages ...
Fetched 19.4 MB in 41s (469 kB/s)
Selecting previously unselected package libaio1:amd64.
(Reading database ... 33902 files and directories currently installed.)
Unpacking libaio1:amd64 (from .../libaio1_0.3.109-3_amd64.deb) ...
Selecting previously unselected package percona-server-server-5.6.
Unpacking percona-server-server-5.6 (from .../percona-server-server-5.6_5.6.16-64.2-569.wheezy_amd64.deb) ...
Processing triggers for man-db ...
Setting up libaio1:amd64 (0.3.109-3) ...
Setting up percona-server-server-5.6 (5.6.16-64.2-569.wheezy) ...
Stopping MySQL (Percona Server): mysqld.


 * Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit.
 * Run the following commands to create these functions:

    mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
    mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
    mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"

 * See http://www.percona.com/doc/percona-server/5.6/management/udf_percona_toolkit.html for more details


Starting MySQL (Percona Server) database server: mysqld . . . . . . . . . . . . . . failed!
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing percona-server-server-5.6 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 percona-server-server-5.6
E: Sub-process /usr/bin/dpkg returned an error code (1)

Error: /Stage[main]/Percona::Install/Package[percona-server-server-5.6]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install percona-server-server-5.6' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  libaio1
Suggested packages:
  tinyca
The following NEW packages will be installed:
  libaio1 percona-server-server-5.6
0 upgraded, 2 newly installed, 0 to remove and 10 not upgraded.
Need to get 19.4 MB of archives.
After this operation, 70.9 MB of additional disk space will be used.
Get:1 http://ftp.by.debian.org/debian/ wheezy/main libaio1 amd64 0.3.109-3 [9150 B]
Get:2 http://repo.percona.com/apt/ wheezy/main percona-server-server-5.6 amd64 5.6.16-64.2-569.wheezy [19.4 MB]
Preconfiguring packages ...
Fetched 19.4 MB in 41s (469 kB/s)
Selecting previously unselected package libaio1:amd64.
(Reading database ... 33902 files and directories currently installed.)
Unpacking libaio1:amd64 (from .../libaio1_0.3.109-3_amd64.deb) ...
Selecting previously unselected package percona-server-server-5.6.
Unpacking percona-server-server-5.6 (from .../percona-server-server-5.6_5.6.16-64.2-569.wheezy_amd64.deb) ...
Processing triggers for man-db ...
Setting up libaio1:amd64 (0.3.109-3) ...
Setting up percona-server-server-5.6 (5.6.16-64.2-569.wheezy) ...
Stopping MySQL (Percona Server): mysqld.


 * Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit.
 * Run the following commands to create these functions:

    mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
    mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
    mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"

 * See http://www.percona.com/doc/percona-server/5.6/management/udf_percona_toolkit.html for more details


Starting MySQL (Percona Server) database server: mysqld . . . . . . . . . . . . . . failed!
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing percona-server-server-5.6 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 percona-server-server-5.6
E: Sub-process /usr/bin/dpkg returned an error code (1)

Notice: /Stage[main]/Percona::Config::Server/File[/etc/mysql]: Dependency Package[percona-server-server-5.6] has failures: true
Warning: /Stage[main]/Percona::Config::Server/File[/etc/mysql]: Skipping because of failed dependencies
Notice: /Stage[main]/Percona::Config::Server/File[/var/log/percona]: Dependency Package[percona-server-server-5.6] has failures: true
Warning: /Stage[main]/Percona::Config::Server/File[/var/log/percona]: Skipping because of failed dependencies
Notice: /Stage[main]/Percona::Config::Server/File[/etc/mysql/my.cnf]: Dependency Package[percona-server-server-5.6] has failures: true
Warning: /Stage[main]/Percona::Config::Server/File[/etc/mysql/my.cnf]: Skipping because of failed dependencies
Notice: /Stage[main]/Percona::Config::Server/File[/etc/mysql/conf.d]: Dependency Package[percona-server-server-5.6] has failures: true
Warning: /Stage[main]/Percona::Config::Server/File[/etc/mysql/conf.d]: Skipping because of failed dependencies
Notice: /Stage[main]/Percona::Service/Service[mysql]: Dependency Package[percona-server-server-5.6] has failures: true
Warning: /Stage[main]/Percona::Service/Service[mysql]: Skipping because of failed dependencies
Notice: Finished catalog run in 112.74 seconds

The same situation when I try install percona server without modules via "package", "exec" and even through script.
What am I doing wrong?

can't set the specific package version for percona-server

I'd like to have puppet always install a specific version of percona-server (such as 5.6.21), but I see in percona::install that all packages are set to ensure => 'present'. I see a pkg_version param in the percona class but that doesn't seem to do anything.

Listen to 127.0.0.1 by default

Hello,

It would probably be better to make percona listen to 127.0.0.1 by default and let the administrator choose to which interface he want to bind.

Default= 127.0.0.1
undef= bind to every IP

What do you think?

Do not grant "GRANT OPTION" by default

Hello,

The "percona::rights" definie is creating the grants with the "Grant option" privilege when setting "priv => 'all'"

This is IMHO wrong and not what the user wants. The GRANT option privileges should be explicitly asked and not set by default

Apt key too short

In newer versions of the apt puppet module, a shortened key gives a warning.
This diff should fix it:

diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp
index 308fa9d..7219194 100644
--- a/manifests/repo/apt.pp
+++ b/manifests/repo/apt.pp
@@ -2,7 +2,7 @@
 #
 class percona::repo::apt {

-  apt::key { 'CD2EFD2A':
+  apt::key { '430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A':
     ensure => present,
     notify => Exec['percona::repo::apt-get update'],
   }
@@ -14,7 +14,7 @@ class percona::repo::apt {
       source  => false,
       content => template ("${module_name}/repo/sources.list.erb"),
       notify  => Exec['percona::repo::apt-get update'],
-      require => Apt::Key['CD2EFD2A'],
+      require => Apt::Key['430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A'],
     }
   }

@@ -27,7 +27,7 @@ class percona::repo::apt {
       release     => $::lsbdistcodename,
       repos       => 'main',
       notify      => Exec['percona::repo::apt-get update'],
-      require     => Apt::Key['CD2EFD2A'],
+      require     => Apt::Key['430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A'],
     }
   }

Unknown column 'password' in 'field list'

In Percona 5.7 the password field has been removed and replaced with authentication_string

This fails:

percona::rights {'xx@xx':
          database => 'xx',
          priv     => 'select_priv',
          password => 'xx',
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.