Commits

Arthur Clune  committed a9ccc58

first stab; use template for targetuser. still need to move all files to /root

  • Participants
  • Parent commits a77ecce

Comments (0)

Files changed (7)

File vagrant/backend/Vagrantfile

    config.vm.provision :puppet do |puppet|
      puppet.manifests_path = "../puppet/manifests"   
      puppet.module_path    = "../puppet/modules"
-     puppet.manifest_file = "backend.pp"        
+     puppet.manifest_file = "init.pp"        
    end 
 
 

File vagrant/puppet/manifests/backend.pp

-# don't do anything here, just include the modules
-# we keep front end (webserver etc) separate from the backend to allow easy splitting across two servers later
-
-include backend

File vagrant/puppet/manifests/init.pp

 # this file blank for now
+
+require backend
+require frontend

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

-#!/bin/sh -e
-
-TARGETUSER=vagrant
-
-PATH="/opt/glassfish3/bin:$PATH"
-export PATH
-
-if [ ! -f ~/_hbbackend_domain_created ]
-then
-
-asadmin create-domain --nopassword=true --portbase 9900 hbbackend
-chown -R $TARGETUSER: /opt/glassfish3/glassfish/domains/hbbackend
-
-touch ~/_hbbackend_domain_created
-
-fi
-

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

 #!/bin/sh -e
 
-
 if [ ! -f ~/_hbbackend_domain_set_up ]
 then
 

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

 class backend::tuning {
 
     exec { "sysctl":
-        command => "/sbin/sysctl -w kernel.shmmax=46088192 && touch ~/_first_boot",
+        command => "/sbin/sysctl -w kernel.shmmax=46088192 && touch /root/_first_boot",
         creates => "/root/_first_boot"
     }
 
 #
 class backend::files {
 
+    $targetuser=$backend::targetuser
+
     file { "/opt/hbbackend":
         ensure  => present,
-        owner   => $::targetuser,
-        group   => $::targetuser,
+        owner   => $targetuser,
+        group   => $targetuser,
         recurse => true,
         source  => "puppet:///modules/backend/opt/hbbackend"
     }
 
     file { "/opt/hbbackend/conf/local.conf":
-       ensure => file,
-       owner   => $::targetuser,
-       group   => $::targetuser,
-       source => "puppet:///modules/backend/opt/hbbackend/conf/local.conf"
+        ensure => file,
+        owner   => $targetuser,
+        group   => $targetuser,
+        source => "puppet:///modules/backend/opt/hbbackend/conf/local.conf"
     }   
 
     file { "/opt/honeynet":
-       ensure => present,
-       source => "puppet:///modules/backend/opt/honeynet",
-       recurse => true,
-       owner   => "root",
-       group   => "root"
+        ensure => present,
+        source => "puppet:///modules/backend/opt/honeynet",
+        recurse => true,
+        owner   => "root",
+        group   => "root"
     }   
    
     file { "/etc/environment":
         require => File["/etc/init.d/hbbackend"]
     }
 
+    file { "/opt/honeynet/bin/create-hbbackend-domain.sh":
+        ensure => file,
+        mode   => 755,
+        owner  => root,
+        group  => root,
+        content => template("backend/create-hbbackend-domain.erb")
+    }
+
 }
 
 # Class: postgres
 #
 class backend::packages {
 
-    exec { "/usr/bin/aptitude -y install --without-recommends openjdk-7-jdk ant ivy maven": creates => "/root/_java_packages_installed" }
+    exec { "/usr/bin/aptitude -y install --without-recommends openjdk-7-jdk ant ivy maven && touch /root/_java_packages_installed": 
+        creates => "/root/_java_packages_installed" 
+    }
 
     package { "unzip": ensure => present }
 }
 
     exec { "/opt/honeynet/bin/install-glassfish.sh":
         timeout => 20000,
-	user => "root",
-	group => "root"
+    	user => "root",
+    	group => "root",
+        creates => "/root/_glassfish_installed"
     }
 
 }
 
 class backend {
+    # user to run the services as
+    #
     $targetuser="vagrant"
 
     require backend::files
 
     exec { "create-hbbackend-db.sh":
     	command => "/opt/honeynet/bin/create-hbbackend-db.sh", 
-        require => Package["postgresql"],
     	user => "root",
-    	group => "root"
+    	group => "root",
+        creates => "/root/_hbbackend_db_created"
     }
 
     exec { "create-hbbackend-domain.sh":
     	command => "/opt/honeynet/bin/create-hbbackend-domain.sh",
         user => "root",
-    	group => "root"
+    	group => "root",
+        creates => "/root/_hbbackend_domain_created"
     }
 
     exec { "install-geoip.sh":
     	command => "/usr/bin/sudo -u ${targetuser} /opt/honeynet/bin/install-geoip.sh",
         timeout => 20000,
+        creates => "/opt/hbbackend/geoip/GeoLiteCity.dat"
     }
 
     exec { "download-hbbackend-deps.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"
     }
 
     exec { "build-hbbackend.sh":

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

+# install all the stuff for the web ui
+#
+# for now, assume that the hbackend and hbwebui dbs are
+# on the same instance
+
 class frontend {
    # install django
-  package { "python-django": ensure => present }
-  package { "python-django-nose": ensure => present }
-   
+  package { "python-django": ensure => present }   
 }