Permalink
Browse files

Refactor copy/pasted apache code into common place

  • Loading branch information...
1 parent 514d334 commit cb5dad304c0c33cec30a1b740ae2ce74bff7168c @e28eta committed Feb 15, 2013
@@ -0,0 +1,32 @@
+define stripectf2::apache2 (
+ $site_name = $title,
+ $proxy_url = undef,
+ $document_root = undef,
+) {
+ service {'apache2':
+ ensure => 'running',
+ enable => true,
+ hasrestart => true,
+ }
+
+ # Disable the default apache2 site
+ stripectf2::apache2_site {'000-default':
+ ensure => 'absent',
+ }
+
+ if $proxy_url {
+ stripectf2::apache2_module {['proxy', 'proxy_http']:
+ ensure => 'present',
+ }
+ }
+
+ file {"/etc/apache2/sites-available/${site_name}":
+ content => template('stripectf2/apache2_site_config.erb'),
+ notify => Service['apache2']
+ }
+
+ stripectf2::apache2_site {$site_name:
+ ensure => 'present',
+ require => File["/etc/apache2/sites-available/${site_name}"],
+ }
+}
@@ -24,29 +24,7 @@
require => [File[$destination], File["${destination}/level00.db"]],
}
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
- stripectf2::apache2_module {['proxy', 'proxy_http']:
- ensure => 'present',
- }
-
- $proxy_url = "http://127.0.0.1:3000/"
- file {'/etc/apache2/sites-available/level00':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2'],
- }
-
- stripectf2::apache2_site {'level00':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level00'],
+ stripectf2::apache2 {'level00':
+ proxy_url => "http://127.0.0.1:3000/",
}
}
@@ -2,17 +2,6 @@
$destination,
$source,
) {
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
file {$destination:
ensure => 'directory',
recurse => true,
@@ -43,14 +32,7 @@
require => Stripectf2::Random_password["${destination}/password.txt"],
}
- $document_root = $destination
- file {'/etc/apache2/sites-available/level02':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2']
- }
-
- stripectf2::apache2_site {'level02':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level02'],
+ stripectf2::apache2 {'level02':
+ $document_root => $destination,
}
}
@@ -30,29 +30,7 @@
user => 'vagrant',
}
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
- stripectf2::apache2_module {['proxy', 'proxy_http']:
- ensure => 'present',
- }
-
- $proxy_url = "http://127.0.0.1:4567/"
- file {'/etc/apache2/sites-available/level04':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2'],
- }
-
- stripectf2::apache2_site {'level04':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level04'],
+ stripectf2::apache2 {'level04':
+ proxy_url => "http://127.0.0.1:4567/",
}
}
@@ -29,29 +29,7 @@
require => [File[$destination], Stripectf2::Random_password["${destination}/password.txt"]],
}
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
- stripectf2::apache2_module {['proxy', 'proxy_http']:
- ensure => 'present',
- }
-
- $proxy_url = "http://127.0.0.1:4567/"
- file {'/etc/apache2/sites-available/level05':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2'],
- }
-
- stripectf2::apache2_site {'level05':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level05'],
+ stripectf2::apache2 {'level05':
+ proxy_url => "http://127.0.0.1:4567/",
}
}
@@ -37,29 +37,7 @@
user => 'vagrant',
}
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
- stripectf2::apache2_module {['proxy', 'proxy_http']:
- ensure => 'present',
- }
-
- $proxy_url = "http://127.0.0.1:4567/"
- file {'/etc/apache2/sites-available/level06':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2'],
- }
-
- stripectf2::apache2_site {'level06':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level06'],
+ stripectf2::apache2 {'level06':
+ proxy_url => "http://127.0.0.1:4567/",
}
}
@@ -34,29 +34,7 @@
subscribe => Exec["initialize_db.py"],
}
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
- stripectf2::apache2_module {['proxy', 'proxy_http']:
- ensure => 'present',
- }
-
- $proxy_url = "http://127.0.0.1:9233/"
- file {'/etc/apache2/sites-available/level07':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2'],
- }
-
- stripectf2::apache2_site {'level07':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level07'],
+ stripectf2::apache2 {'level07':
+ proxy_url => "http://127.0.0.1:9233/",
}
-}
+}
@@ -26,29 +26,7 @@
Stripectf2::Random_password["${destination}/password.txt"]],
}
- service {'apache2':
- ensure => 'running',
- enable => true,
- hasrestart => true,
- }
-
- # Disable the default apache2 site
- stripectf2::apache2_site {'000-default':
- ensure => 'absent',
- }
-
- stripectf2::apache2_module {['proxy', 'proxy_http']:
- ensure => 'present',
- }
-
- $proxy_url = "http://127.0.0.1:3000/"
- file {'/etc/apache2/sites-available/level08':
- content => template('stripectf2/apache2_site_config.erb'),
- notify => Service['apache2'],
- }
-
- stripectf2::apache2_site {'level08':
- ensure => 'present',
- require => File['/etc/apache2/sites-available/level08'],
+ stripectf2::apache2 {'level08':
+ proxy_url => "http://127.0.0.1:3000/",
}
}

0 comments on commit cb5dad3

Please sign in to comment.