From d602f82db8000e4755d8e866ce2e4bc7dbdf6db0 Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Tue, 2 Sep 2014 13:29:43 +0200 Subject: [PATCH] Puppet style guide: modified MySQL and PgSQL database creation and population resources to fit autoload module layout refs #6842 --- .../modules/mysql/manifests/database/create.pp | 11 +++++++++++ .../{database.pp => database/populate.pp} | 12 ------------ .../manifests/{database.pp => database/create.pp} | 15 --------------- .../modules/pgsql/manifests/database/populate.pp | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 27 deletions(-) create mode 100644 .vagrant-puppet/modules/mysql/manifests/database/create.pp rename .vagrant-puppet/modules/mysql/manifests/{database.pp => database/populate.pp} (57%) rename .vagrant-puppet/modules/pgsql/manifests/{database.pp => database/create.pp} (50%) create mode 100644 .vagrant-puppet/modules/pgsql/manifests/database/populate.pp diff --git a/.vagrant-puppet/modules/mysql/manifests/database/create.pp b/.vagrant-puppet/modules/mysql/manifests/database/create.pp new file mode 100644 index 000000000..a1d242fde --- /dev/null +++ b/.vagrant-puppet/modules/mysql/manifests/database/create.pp @@ -0,0 +1,11 @@ +define mysql::database::create ($username, $password, $privileges) { + include mysql + + exec { "create-mysql-${name}-db": + unless => "mysql -u${username} -p${password} ${name}", + command => "mysql -uroot -e \"CREATE DATABASE ${name}; \ +GRANT ${privileges} ON ${name}.* TO ${username}@localhost \ +IDENTIFIED BY '${password}';\"", + require => Class['mysql'] + } +} diff --git a/.vagrant-puppet/modules/mysql/manifests/database.pp b/.vagrant-puppet/modules/mysql/manifests/database/populate.pp similarity index 57% rename from .vagrant-puppet/modules/mysql/manifests/database.pp rename to .vagrant-puppet/modules/mysql/manifests/database/populate.pp index 81a9956f5..5e3bf2d84 100644 --- a/.vagrant-puppet/modules/mysql/manifests/database.pp +++ b/.vagrant-puppet/modules/mysql/manifests/database/populate.pp @@ -1,15 +1,3 @@ -define mysql::database::create ($username, $password, $privileges) { - include mysql - - exec { "create-mysql-${name}-db": - unless => "mysql -u${username} -p${password} ${name}", - command => "mysql -uroot -e \"CREATE DATABASE ${name}; \ -GRANT ${privileges} ON ${name}.* TO ${username}@localhost \ -IDENTIFIED BY '${password}';\"", - require => Class['mysql'] - } -} - define mysql::database::populate ($username, $password, $privileges, $schemafile) { Exec { path => '/usr/bin' } diff --git a/.vagrant-puppet/modules/pgsql/manifests/database.pp b/.vagrant-puppet/modules/pgsql/manifests/database/create.pp similarity index 50% rename from .vagrant-puppet/modules/pgsql/manifests/database.pp rename to .vagrant-puppet/modules/pgsql/manifests/database/create.pp index b8d1f7e33..09f280aa2 100644 --- a/.vagrant-puppet/modules/pgsql/manifests/database.pp +++ b/.vagrant-puppet/modules/pgsql/manifests/database/create.pp @@ -9,18 +9,3 @@ sudo -u postgres createlang plpgsql ${name}", require => Class['pgsql'] } } - -define pgsql::database::populate ($username, $password, $schemafile) { - Exec { path => '/usr/bin' } - - pgsql::database::create { $name: - username => $username, - password => $password, - } - - exec { "populate-${name}-pgsql-db": - unless => "psql -U ${username} -d ${name} -c \"SELECT * FROM icinga_dbversion;\" &> /dev/null", - command => "sudo -u postgres psql -U ${username} -d ${name} < ${schemafile}", - require => Pgsql::Database::Create[$name], - } -} diff --git a/.vagrant-puppet/modules/pgsql/manifests/database/populate.pp b/.vagrant-puppet/modules/pgsql/manifests/database/populate.pp new file mode 100644 index 000000000..ab25b19ef --- /dev/null +++ b/.vagrant-puppet/modules/pgsql/manifests/database/populate.pp @@ -0,0 +1,14 @@ +define pgsql::database::populate ($username, $password, $schemafile) { + Exec { path => '/usr/bin' } + + pgsql::database::create { $name: + username => $username, + password => $password, + } + + exec { "populate-${name}-pgsql-db": + unless => "psql -U ${username} -d ${name} -c \"SELECT * FROM icinga_dbversion;\" &> /dev/null", + command => "sudo -u postgres psql -U ${username} -d ${name} < ${schemafile}", + require => Pgsql::Database::Create[$name], + } +}