Gestione di MySQL in Puppet

From RVM Wiki
Revision as of 18:55, 18 March 2015 by Gabriele.vivinetto (talk | contribs) (Created page with "* Installare il modulo sudo puppet module install puppetlabs-mysql Per: * installare un server mysql * impostarne la password di rot * modificarne dei parametri in my.cnf * ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  • Installare il modulo
sudo puppet module install puppetlabs-mysql

Per:

  • installare un server mysql
  • impostarne la password di rot
  • modificarne dei parametri in my.cnf
  • creare dei DB vuoti
  • creare degli utenti
  • assegnare i diritti agli utenti sui DB
node 'myclient.examples.priv' {
	include test_puppet
	include common_packages
	include common_users

	package {'phpmyadmin':
		ensure	=> present,
	}

	class { '::mysql::server':
		root_password		=> 'PasswordSecret',
		restart				=> true,
		override_options	=> { 
			'mysqld' => { 
				'bind-address' => '0.0.0.0',
				'max_allowed_packet' => '32', 
			} 
		},

		databases   => {
			'somedb'  => {
				ensure  => 'present',
			    charset => 'utf8',
  			},

			'dashboard_production'  => {
				ensure  => 'present',
			    charset => 'utf8',
  			},

			'dashboard_testing'  => {
				ensure  => 'present',
			    charset => 'utf8',
  			},

			'dashboard_development'  => {
				ensure  => 'present',
			    charset => 'utf8',
  			},

		},

		users => {

			'someuser@localhost' => {
				ensure					 => 'present',
				password_hash			 => '*0F6188E353012D1D828CFA87047085E28AF17DD1',
  			},

			'dashboard@%' => {
				ensure					 => 'present',
				password_hash			 => '*92852C97A0A9034A439C7091DEC9DE7F79C33FEA',
  			},

		},

		grants => {

			'someuser@localhost/somedb.*' => {
				ensure     => 'present',
				options    => ['GRANT'],
				privileges => ['SELECT', 'INSERT', 'UPDATE', 'DELETE'],
				table      => 'somedb.*',
				user       => 'someuser@localhost',
  			},

			'dashboard@%/dashboard_production.*' => {
				ensure     => 'present',
				options    => ['GRANT'],
				privileges => ['ALL'],
				table      => 'dashboard_production.*',
				user       => 'dashboard@%',
  			},

			'dashboard@%/dashboard_testing.*' => {
				ensure     => 'present',
				options    => ['GRANT'],
				privileges => ['ALL'],
				table      => 'dashboard_testing.*',
				user       => 'dashboard@%',
  			},

			'dashboard@%/dashboard_development.*' => {
				ensure     => 'present',
				options    => ['GRANT'],
				privileges => ['ALL'],
				table      => 'dashboard_development.*',
				user       => 'dashboard@%',
  			},

		},
	}

}
  • Vengono creati 4 DB
  • La password degli utenti si ottiene con
select PASSWORD('laMiaPassword');
  • Per utilizzare delel wildcard sui nomi dei DB, verificare ...

Riferimenti