]> WPIA git - infra.git/commitdiff
upd: move quiz to postgres
authorFelix Dörre <felix@dogcraft.de>
Fri, 16 Jun 2017 21:36:24 +0000 (23:36 +0200)
committerLucas Werkmeister <mail@lucaswerkmeister.de>
Mon, 16 Oct 2017 18:06:31 +0000 (20:06 +0200)
Note: this change does not migrate the data from the mysql database

Change-Id: I00a85c38054c759a37fde05a5e0b9f32a16d66ec

environments/production/manifests/ip.pp
environments/production/manifests/postgres-primary.pp
environments/production/manifests/quiz.pp
modules/quiz/templates/sq_config.epp

index 8c137330b5f2dc9a2a6cbfb865241023eccdf5cb..b6ad1dd9b4859aa2201e974dd696184e8fec0b68 100644 (file)
@@ -10,12 +10,9 @@ $ips = {
 
 $passwords = {
    postgres => {
 
 $passwords = {
    postgres => {
-     gigi => 'gigi'
-   },
-   quiz-mysql => {
-     root => 'root',
+     gigi => 'gigi',
      quiz => 'quiz'
      quiz => 'quiz'
-   }
+   },
 }
 
 $testServer = 'false'
 }
 
 $testServer = 'false'
index e90109fd9610458fde006a763dc9e947255b49c1..076c4a8323405c4d1665b65c6ae4888adb5bce0f 100644 (file)
@@ -28,4 +28,19 @@ node postgres-primary {
     address     => "$gigi_ip/32",
     auth_method => 'md5',
   }
     address     => "$gigi_ip/32",
     auth_method => 'md5',
   }
+
+  postgresql::server::db { 'quiz':
+    require  => Class['postgresql::server'],
+    user     => 'quiz',
+    password => postgresql_password('quiz', $passwords[postgres][quiz]),
+  }
+  postgresql::server::pg_hba_rule { 'allow quiz to access its database':
+    require  => Package['postgresql'],
+    description => "Open up PostgreSQL for access from quiz to its database",
+    type        => 'host',
+    database    => 'quiz',
+    user        => 'quiz',
+    address     => "${ips[quiz]}/32",
+    auth_method => 'md5',
+  }
 }
 }
index 70577ff640395c20f5ca0e4f28a755a139ec2004..f57615863686c078f65f2037a26ed0fdfaaab851 100644 (file)
@@ -15,12 +15,6 @@ define teracara_quiz (){
   package { 'apache2':
     ensure => 'installed',
   }
   package { 'apache2':
     ensure => 'installed',
   }
-  file {'/etc/apache2/sites-available/000-default.conf':
-      require => Package['apache2'],
-      ensure => 'file',
-      source => 'puppet:///modules/quiz/000-default.conf',
-      notify => Service['apache2'],
-  }
   file {'/etc/teracara-quiz/config.php':
       require => Package['teracara-quiz'],
       ensure => 'file',
   file {'/etc/teracara-quiz/config.php':
       require => Package['teracara-quiz'],
       ensure => 'file',
@@ -49,21 +43,24 @@ define teracara_quiz (){
       source => ['puppet:///modules/nre/config/ca/root.crt'],
       show_diff => 'no'
   }
       source => ['puppet:///modules/nre/config/ca/root.crt'],
       show_diff => 'no'
   }
-  class {'::mysql::client':
-    package_name    => 'mariadb-client'
+  exec { 'import quiz schema':
+    command => "/usr/bin/psql -U quiz -h ${ips[postgres]} < /usr/share/teracara-quiz/sql/db_postgresql.sql",
+    environment => ["PGPASSWORD=${passwords[postgres][quiz]}"],
+    unless  => "/usr/bin/psql -U quiz -h ${ips[postgres]} -tc \"select * from pg_tables where schemaname='public';\" | /bin/grep -q '.'",
+    require => [Package['teracara-quiz']],
+    before => File['/etc/apache2/sites-available/000-default.conf']
+  }
+  file {'/etc/apache2/sites-available/000-default.conf':
+      require => Package['apache2'],
+      ensure => 'file',
+      source => 'puppet:///modules/quiz/000-default.conf',
+      notify => Service['apache2'],
   }
   }
-  class { '::mysql::server':
-    package_name            => 'mariadb-server',
-    root_password           => $passwords[quiz-mysql][root]
+  package{'mariadb-server':
+      ensure => 'purged'
   }
   }
-  mysql::db { 'quiz':
-    require => Package['teracara-quiz'],
-    user     => 'quiz',
-    password => $passwords[quiz-mysql][quiz],
-    host     => 'localhost',
-    grant    => ['SELECT', 'INSERT', 'UPDATE', 'DELETE'],
-    sql      => '/usr/share/teracara-quiz/sql/db.sql',
-    import_timeout => 900,
+  package{'mariadb-client':
+      ensure => 'purged'
   }
 }
 node quiz{
   }
 }
 node quiz{
index 35b0aad4203ae7c917e41f9bc7e841b3b0aec4d7..5d9fb89bf0415bebc8c56655f4f7024ae4fe4525 100644 (file)
@@ -3,4 +3,7 @@
                 $sq_hostname='localhost';
                 $sq_dbname='quiz';
                 $sq_dbusername='quiz';
                 $sq_hostname='localhost';
                 $sq_dbname='quiz';
                 $sq_dbusername='quiz';
-                $sq_dbpassword='<%=$passwords[quiz-mysql][quiz]%>';
+                $sq_dbpassword='<%=$passwords[postgres][quiz]%>';
+                $sq_dbdriver='pdo';
+                $sq_dbport='5432';
+                $sq_dbdsn='pgsql:host=' . $sq_hostname .';port=' .$sq_dbport .';dbname=' . $sq_dbname;