Commits

Arthur Clune committed bc94fea

BUGFIX: previous version had two modules incorrectly handling /opt/honeynet/bin

Change script marker files back to /etc
Split out postgres setup into a new "base" module

Comments (0)

Files changed (7)

vagrant/puppet/modules/backend/files/opt/honeynet/bin/create-hbbackend-db.sh

 # important note - this setup is only good for development!
 # change these permissions and passwords for production!
 
-if [ ! -f ~/_hbbackend_db_created ]
+if [ ! -f /etc/_hbbackend_db_created ]
 then
     sudo -u postgres psql -c "create user hbbackend with password 'hbbackend';"
     sudo -u postgres psql -c "create user hbstats with password 'hbstats';"
     PGPASSWORD=hbstats psql -h localhost -U hbstats -d hbbackend < /repo/hbbackend/schema/hbstats.sql
     PGPASSWORD=hbstats psql -h localhost -U hbstats -d hbbackend < /repo/hbbackend/schema/hbstats_functions.sql
 
-    touch ~/_hbbackend_db_created
+    touch /etc/_hbbackend_db_created
 fi
 

vagrant/puppet/modules/backend/files/opt/honeynet/bin/install-glassfish.sh

 #!/bin/sh -e
 
-if [ ! -f ~/_glassfish_installed ]
+if [ ! -f /etc/_glassfish_installed ]
 then
     # race condition here. Don't run on shared machine
     mkdir /tmp/$$
     mv glassfish3/* /opt/glassfish3
     chown -R root:root /opt/glassfish3
     # rm -rf /tmp/$$
-    touch ~/_glassfish_installed
+    touch /etc/_glassfish_installed
 fi

vagrant/puppet/modules/backend/files/opt/honeynet/bin/setup-hbbackend-domain.sh

 #!/bin/sh -e
 
-if [ ! -f ~/_hbbackend_domain_set_up ]
+if [ ! -f /etc/_hbbackend_domain_set_up ]
 then
 
 PATH="/opt/glassfish3/bin:$PATH"
 
 
 
-touch ~/_hbbackend_domain_set_up
+sudo touch /etc/_hbbackend_domain_set_up
 
 fi
 

vagrant/puppet/modules/backend/manifests/init.pp

-# Class: backend::tuning
-#
-#
-class backend::tuning {
-
-    exec { "sysctl":
-        command => "/sbin/sysctl -w kernel.shmmax=46088192 && touch /root/_first_boot",
-        creates => "/root/_first_boot"
-    }
-
-    file { "/etc/sysctl.conf":
-        ensure => file,
-        owner  => "root", 
-        group  => "root",
-        source => "puppet:///modules/backend/etc/sysctl.conf" 
-    }
-}
-
 
 # Class: backend::files
 #
 
     $targetuser=$backend::targetuser
 
+    file { "/opt/honeynet/bin":
+        ensure => directory,
+        recurse => true,
+        owner   => "root",
+        group   => "root",
+        source => "puppet:///modules/backend/opt/honeynet/bin"
+    }  
+
     file { "/opt/hbbackend":
         ensure  => present,
         owner   => $targetuser,
 
 }
 
-# Class: postgres
-#
-#
-class backend::postgres {
-    require backend::tuning
-
-    package { "postgresql": 
-        ensure  => present,
-    }
-
-    file { "/etc/postgresql/9.1/main/postgresql.conf":
-        ensure  => "present",
-        owner   => "postgres", 
-        group   => "postgres",
-        recurse => true,
-        source  => "puppet:///modules/backend/etc/postgresql/9.1/main/postgresql.conf",
-        require => Package["postgresql"],
-        notify  => Exec["restart-postgres"]
-    }     
-
-    file { "/etc/postgresql/9.1/main/pg_hba.conf":
-        ensure  => "present",
-        owner   => "postgres", 
-        group   => "postgres",
-        recurse => true,
-        source  => "puppet:///modules/backend/etc/postgresql/9.1/main/pg_hba.conf",
-        require => Package["postgresql"],
-        notify  => Exec["restart-postgres"]
-    }     
-
-    exec { "restart-postgres":
-        command => "/etc/init.d/postgresql restart",
-        refreshonly => true
-    }
-
-}
-
 # Class: backend::packages
 #
 #
 class backend::packages {
 
-    exec { "/usr/bin/aptitude -y install --without-recommends openjdk-7-jdk ant ivy maven && touch /root/_java_packages_installed": 
-        creates => "/root/_java_packages_installed" 
+    exec { "/usr/bin/aptitude -y install --without-recommends openjdk-7-jdk ant ivy maven && touch /etc/_java_packages_installed": 
+        creates => "/etc/_java_packages_installed" 
     }
 
     package { "unzip": ensure => present }
         timeout => 20000,
     	user => "root",
     	group => "root",
-        creates => "/root/_glassfish_installed"
+        creates => "/etc/_glassfish_installed"
     }
 
 }
 
     require backend::files
     require backend::packages
-    require backend::postgres
+    require base::postgres
     require backend::glassfish
 
     exec { "create-hbbackend-db.sh":
     	command => "/opt/honeynet/bin/create-hbbackend-db.sh", 
     	user => "root",
     	group => "root",
-        creates => "/root/_hbbackend_db_created"
+        creates => "/etc/_hbbackend_db_created"
     }
 
     exec { "create-hbbackend-domain.sh":
     	command => "/opt/honeynet/bin/create-hbbackend-domain.sh",
         user => "root",
     	group => "root",
-        creates => "/root/_hbbackend_domain_created"
+        creates => "/etc/_hbbackend_domain_created"
     }
 
     exec { "install-geoip.sh":
         timeout => 600,
         require => [Exec["create-hbbackend-db.sh"], Exec["create-hbbackend-domain.sh"],
 		    Exec["download-hbbackend-deps.sh"], ],
-        creates => "/home/vagrant/_hbbackend_domain_set_up"
+        creates => "/etc/_hbbackend_domain_set_up"
     }
 
     exec { "build-hbbackend.sh":
 
     exec { "deploy-backend.sh":
         command => "/usr/bin/sudo -i -u ${targetuser} /opt/honeynet/bin/deploy-backend.sh",
+        timeout => 600,
         require => [ Exec["setup-hbbackend-domain.sh"], Exec["build-hbbackend.sh"]  ],
         creates => "/etc/_deploy_backend_run"
     }

vagrant/puppet/modules/backend/templates/create-hbbackend-domain.erb

 PATH="/opt/glassfish3/bin:$PATH"
 export PATH
 
-if [ ! -f ~/_hbbackend_domain_created ]
+if [ ! -f /etc/_hbbackend_domain_created ]
 then
 
 asadmin create-domain --nopassword=true --portbase 9900 hbbackend
 chown -R <%= targetuser %> /opt/glassfish3/glassfish/domains/hbbackend
 
-touch ~/_hbbackend_domain_created
+touch /etc/_hbbackend_domain_created
 
 fi
 

vagrant/puppet/modules/base/manifests/init.pp

+
+# Class: base::tuning
+#
+#
+class base::tuning {
+
+    exec { "sysctl":
+        command => "/sbin/sysctl -w kernel.shmmax=46088192 && touch /etc/_sysctl_tuned",
+        creates => "/etc/_sysctl_tuned"
+    }
+
+    file { "/etc/sysctl.conf":
+        ensure => file,
+        owner  => "root", 
+        group  => "root",
+        source => "puppet:///modules/backend/etc/sysctl.conf" 
+    }
+}
+
+
+# Class: base::postgres
+#
+#
+class base::postgres {
+    require base::tuning
+
+    package { "postgresql": 
+        ensure  => present,
+    }
+
+    file { "/etc/postgresql/9.1/main/postgresql.conf":
+        ensure  => "present",
+        owner   => "postgres", 
+        group   => "postgres",
+        recurse => true,
+        source  => "puppet:///modules/backend/etc/postgresql/9.1/main/postgresql.conf",
+        require => Package["postgresql"],
+        notify  => Exec["restart-postgres"]
+    }     
+
+    file { "/etc/postgresql/9.1/main/pg_hba.conf":
+        ensure  => "present",
+        owner   => "postgres", 
+        group   => "postgres",
+        recurse => true,
+        source  => "puppet:///modules/backend/etc/postgresql/9.1/main/pg_hba.conf",
+        require => Package["postgresql"],
+        notify  => Exec["restart-postgres"]
+    }     
+
+    exec { "restart-postgres":
+        command => "/etc/init.d/postgresql restart",
+        refreshonly => true
+    }
+
+}
+

vagrant/puppet/modules/frontend/manifests/init.pp

 # to split this up, just change django config file to point at the backend dbs
 #
 
-require backend::postgres
-
 # Class: frontend::file
 #
 #
 class frontend::files {
 
-  file { "/opt/honeynet/bin/":
-      ensure => present,
-      recurse => true,
-      source => "puppet:///modules/frontend/opt/honeynet/bin"
+  # we can't easily use recuse here as backend already control 
+  # the dir so just drop the files in 
+
+  File {
+    ensure => file,
+    mode => 0755,
+    owner => "root",
+    group => "root",    
+  }
+
+  file { "/opt/honeynet/bin/install-django.sh":
+    source => "puppet:///modules/frontend/opt/honeynet/bin/install-django.sh"
   }
 
+  file { "/opt/honeynet/bin/run-django.sh":
+      source => "puppet:///modules/frontend/opt/honeynet/bin/install-django.sh"
+  }
 }
 
 class frontend {
 
+    require base::postgres
     require frontend::files
 
     package {  ["python-psycopg2", "python-setuptools", "python-dev"]: 
         timeout => 600,
         creates => "/etc/_django_installed"
     }
-
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.