provizioning 0.1.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/README.md +29 -0
  4. data/Rakefile +2 -0
  5. data/bootstrap/bootstrap.sh +71 -0
  6. data/{lib/templates/sources.list → bootstrap/lucid.sources.list} +2 -1
  7. data/bootstrap/natty.sources.list +14 -0
  8. data/lib/provizioning/puppet.rb +94 -0
  9. data/lib/provizioning/version.rb +3 -0
  10. data/lib/provizioning.rb +1 -3
  11. data/provizioning.gemspec +20 -0
  12. data/puppet/classes/apache/centos.conf +978 -0
  13. data/puppet/classes/apache/ssl.conf +75 -0
  14. data/puppet/classes/apache.pp +152 -0
  15. data/puppet/classes/apt.pp +5 -0
  16. data/puppet/classes/base/ntp/ntpd-sysconfig +13 -0
  17. data/puppet/classes/base.pp +79 -0
  18. data/puppet/classes/freerange.pp +53 -0
  19. data/puppet/classes/gemrc/gemrc +9 -0
  20. data/puppet/classes/gemrc.pp +10 -0
  21. data/puppet/classes/imagemagick.pp +19 -0
  22. data/puppet/classes/iptables/load-iptables +3 -0
  23. data/puppet/classes/iptables/post-iptables +2 -0
  24. data/puppet/classes/iptables/pre-iptables +2 -0
  25. data/puppet/classes/iptables.pp +59 -0
  26. data/puppet/classes/logrotate/logrotate.erb +15 -0
  27. data/puppet/classes/logrotate.pp +37 -0
  28. data/puppet/classes/mongo/mongodb.conf +89 -0
  29. data/puppet/classes/mongo.pp +86 -0
  30. data/puppet/classes/monit/monit.conf +242 -0
  31. data/puppet/classes/monit.pp +39 -0
  32. data/puppet/classes/munin/plugins/passenger_memory_stats +123 -0
  33. data/puppet/classes/munin/plugins/passenger_status +130 -0
  34. data/puppet/classes/munin/plugins/rails_database_time +174 -0
  35. data/puppet/classes/munin/plugins/rails_request_duration +173 -0
  36. data/puppet/classes/munin/plugins/rails_request_error +169 -0
  37. data/puppet/classes/munin/plugins/rails_requests +175 -0
  38. data/puppet/classes/munin/plugins/rails_view_render_time +173 -0
  39. data/puppet/classes/munin/rails-plugin-config +4 -0
  40. data/puppet/classes/munin.pp +60 -0
  41. data/puppet/classes/mysql/password.erb +1 -0
  42. data/puppet/classes/mysql.pp +71 -0
  43. data/puppet/classes/openswan/ipsec.conf +17 -0
  44. data/puppet/classes/openswan/ipsec.secrets +1 -0
  45. data/puppet/classes/openswan/patched_ipsec_initd_script +223 -0
  46. data/puppet/classes/openswan/secret.erb +1 -0
  47. data/puppet/classes/openswan.pp +71 -0
  48. data/puppet/classes/post-flight.pp +17 -0
  49. data/puppet/classes/postfix/main.cf +39 -0
  50. data/puppet/classes/postfix.pp +16 -0
  51. data/puppet/classes/rack/centos/passenger.load.erb +5 -0
  52. data/puppet/classes/rack/ubuntu/passenger.conf.erb +6 -0
  53. data/puppet/classes/rack.pp +66 -0
  54. data/puppet/classes/redis/redis.conf.erb +187 -0
  55. data/puppet/classes/redis.pp +20 -0
  56. data/puppet/classes/sudo/sudoers +6 -0
  57. data/puppet/classes/sudo.pp +24 -0
  58. data/puppet/classes/syslogng/CentOS.cnf +61 -0
  59. data/puppet/classes/syslogng/Ubuntu.cnf +347 -0
  60. data/puppet/classes/syslogng.pp +146 -0
  61. data/puppet/classes/xml.pp +23 -0
  62. data/puppet/classes/yum.pp +6 -0
  63. data/puppet/classes/zsh.pp +5 -0
  64. data/puppet/modules/README +74 -0
  65. data/puppet/modules/cron/README +4 -0
  66. data/puppet/modules/cron/manifests/base.pp +26 -0
  67. data/puppet/modules/cron/manifests/crontabs.pp +11 -0
  68. data/puppet/modules/cron/manifests/init.pp +18 -0
  69. data/puppet/modules/drupal/Modulefile +7 -0
  70. data/puppet/modules/drupal/README +110 -0
  71. data/puppet/modules/drupal/manifests/absent.pp +25 -0
  72. data/puppet/modules/drupal/manifests/backup/absent.pp +23 -0
  73. data/puppet/modules/drupal/manifests/backup.pp +49 -0
  74. data/puppet/modules/drupal/manifests/conf.pp +23 -0
  75. data/puppet/modules/drupal/manifests/debug.pp +26 -0
  76. data/puppet/modules/drupal/manifests/disable.pp +22 -0
  77. data/puppet/modules/drupal/manifests/disableboot.pp +13 -0
  78. data/puppet/modules/drupal/manifests/drush.pp +20 -0
  79. data/puppet/modules/drupal/manifests/example42/backup.pp +8 -0
  80. data/puppet/modules/drupal/manifests/example42/monitor.pp +8 -0
  81. data/puppet/modules/drupal/manifests/example42.pp +25 -0
  82. data/puppet/modules/drupal/manifests/extra.pp +30 -0
  83. data/puppet/modules/drupal/manifests/firewall/absent.pp +19 -0
  84. data/puppet/modules/drupal/manifests/firewall.pp +24 -0
  85. data/puppet/modules/drupal/manifests/init.pp +54 -0
  86. data/puppet/modules/drupal/manifests/install.pp +20 -0
  87. data/puppet/modules/drupal/manifests/module.pp +37 -0
  88. data/puppet/modules/drupal/manifests/monitor/absent.pp +42 -0
  89. data/puppet/modules/drupal/manifests/monitor.pp +77 -0
  90. data/puppet/modules/drupal/manifests/package.pp +20 -0
  91. data/puppet/modules/drupal/manifests/params.pp +277 -0
  92. data/puppet/modules/drupal/manifests/site.pp +63 -0
  93. data/puppet/modules/drupal/manifests/theme.pp +33 -0
  94. data/puppet/modules/drupal/templates/variables_drupal.erb +62 -0
  95. data/puppet/modules/drupal/tests/absent.pp +1 -0
  96. data/puppet/modules/drupal/tests/backup.pp +1 -0
  97. data/puppet/modules/drupal/tests/debug.pp +1 -0
  98. data/puppet/modules/drupal/tests/disable.pp +1 -0
  99. data/puppet/modules/drupal/tests/disableboot.pp +1 -0
  100. data/puppet/modules/drupal/tests/firewall.pp +1 -0
  101. data/puppet/modules/drupal/tests/init.pp +1 -0
  102. data/puppet/modules/drupal/tests/monitor.pp +1 -0
  103. data/puppet/modules/hosts/README +0 -0
  104. data/puppet/modules/hosts/manifests/example42.pp +5 -0
  105. data/puppet/modules/hosts/manifests/init.pp +16 -0
  106. data/puppet/modules/hosts/templates/hosts.erb +11 -0
  107. data/puppet/modules/iptables/README +4 -0
  108. data/puppet/modules/iptables/files/iptables +19 -0
  109. data/puppet/modules/iptables/manifests/disable.pp +15 -0
  110. data/puppet/modules/iptables/manifests/init.pp +9 -0
  111. data/puppet/modules/iptables/manifests/redhat.pp +24 -0
  112. data/puppet/modules/mysql/Modulefile +7 -0
  113. data/puppet/modules/mysql/README +56 -0
  114. data/puppet/modules/mysql/manifests/absent.pp +12 -0
  115. data/puppet/modules/mysql/manifests/backup/example42.pp +8 -0
  116. data/puppet/modules/mysql/manifests/backup.pp +49 -0
  117. data/puppet/modules/mysql/manifests/client.pp +18 -0
  118. data/puppet/modules/mysql/manifests/conf.pp +23 -0
  119. data/puppet/modules/mysql/manifests/debug.pp +25 -0
  120. data/puppet/modules/mysql/manifests/disable.pp +13 -0
  121. data/puppet/modules/mysql/manifests/disableboot.pp +13 -0
  122. data/puppet/modules/mysql/manifests/example42.pp +25 -0
  123. data/puppet/modules/mysql/manifests/firewall.pp +23 -0
  124. data/puppet/modules/mysql/manifests/grant.pp +29 -0
  125. data/puppet/modules/mysql/manifests/init.pp +67 -0
  126. data/puppet/modules/mysql/manifests/monitor/example42.pp +8 -0
  127. data/puppet/modules/mysql/manifests/monitor.pp +77 -0
  128. data/puppet/modules/mysql/manifests/params.pp +240 -0
  129. data/puppet/modules/mysql/manifests/query.pp +30 -0
  130. data/puppet/modules/mysql/templates/grant.erb +6 -0
  131. data/puppet/modules/mysql/templates/query.erb +5 -0
  132. data/puppet/modules/mysql/templates/variables_mysql.erb +42 -0
  133. data/puppet/modules/network/README +4 -0
  134. data/puppet/modules/network/manifests/init.pp +13 -0
  135. data/puppet/modules/nginx/manifests/fcgi.pp +87 -0
  136. data/puppet/modules/nginx/manifests/init.pp +205 -0
  137. data/puppet/modules/nginx/templates/fcgi_site.erb +38 -0
  138. data/puppet/modules/nginx/templates/includes/fastcgi_params.erb +23 -0
  139. data/puppet/modules/nginx/templates/nginx.conf.erb +31 -0
  140. data/puppet/modules/passenger/manifests/init.pp +12 -0
  141. data/puppet/modules/passenger/templates/myapp +39 -0
  142. data/puppet/modules/php/README +26 -0
  143. data/puppet/modules/php/manifests/init.pp +42 -0
  144. data/puppet/modules/php/manifests/module.pp +22 -0
  145. data/puppet/modules/php/manifests/pear/module.pp +21 -0
  146. data/puppet/modules/php/manifests/pear.pp +20 -0
  147. data/puppet/modules/php/manifests/pecl/config.pp +19 -0
  148. data/puppet/modules/php/manifests/pecl/module.pp +44 -0
  149. data/puppet/modules/php/manifests/pecl.pp +8 -0
  150. data/puppet/modules/php/manifests/soap.pp +20 -0
  151. data/puppet/modules/postgres/Copyright +13 -0
  152. data/puppet/modules/postgres/manifests/database.pp +40 -0
  153. data/puppet/modules/postgres/manifests/init.pp +25 -0
  154. data/puppet/modules/postgres/manifests/role.pp +40 -0
  155. data/puppet/modules/ruby/files/install-ruby-stow +43 -0
  156. data/puppet/modules/ruby/manifests/init.pp +18 -0
  157. data/puppet/modules/rvm/files/install-system-rvm +2 -0
  158. data/puppet/modules/rvm/manifests/classes/dependencies.pp +24 -0
  159. data/puppet/modules/rvm/manifests/classes/passenger.pp +166 -0
  160. data/puppet/modules/rvm/manifests/classes/system.pp +33 -0
  161. data/puppet/modules/rvm/manifests/definitions/system_user.pp +13 -0
  162. data/puppet/modules/rvm/manifests/init.pp +2 -0
  163. data/puppet/modules/rvm/templates/passenger-apache.conf.erb +9 -0
  164. data/puppet/modules/ssh/README +4 -0
  165. data/puppet/modules/ssh/manifests/auth.pp +39 -0
  166. data/puppet/modules/ssh/manifests/auth.pp.good +340 -0
  167. data/puppet/modules/ssh/manifests/eal4.pp +69 -0
  168. data/puppet/modules/ssh/manifests/init.pp +74 -0
  169. data/puppet/modules/stow/manifests/init.pp +5 -0
  170. data/puppet/modules/sudo/files/sudoers +25 -0
  171. data/puppet/modules/sudo/manifests/init.pp +1 -0
  172. data/puppet/modules/sudo/manifests/install.pp +5 -0
  173. data/puppet/modules/sudo/manifests/sudoers.pp +14 -0
  174. data/puppet/modules/ufw/manifests/init.pp +12 -0
  175. data/puppet/modules/users/README +28 -0
  176. data/puppet/modules/users/manifests/adduser.pp +16 -0
  177. data/puppet/modules/users/manifests/admin.pp +11 -0
  178. data/puppet/modules/users/manifests/automount.pp +34 -0
  179. data/puppet/modules/users/manifests/deluser.pp +8 -0
  180. data/puppet/modules/users/manifests/example42.pp +16 -0
  181. data/puppet/modules/users/manifests/init.pp +31 -0
  182. data/puppet/modules/users/manifests/ldap.pp +114 -0
  183. data/puppet/modules/users/manifests/params.pp +84 -0
  184. data/puppet/modules/users/templates/ldap/ldap.conf.erb +13 -0
  185. data/puppet/modules/users/templates/ldap/nsswitch.conf.erb +23 -0
  186. data/puppet/modules/users/templates/ldap/openldap-ldap.conf.erb +8 -0
  187. data/puppet/modules/webmin/manifests/init.pp +31 -0
  188. data/puppet/roles/blank.pp +1 -0
  189. data/puppet/site.pp +8 -0
  190. metadata +235 -81
  191. data/README +0 -3
  192. data/bin/provizion +0 -52
  193. data/lib/policies/chef-client.rb +0 -37
  194. data/lib/policies/lamp.rb +0 -42
  195. data/lib/policies/passenger.rb +0 -44
  196. data/lib/recipes/apache.rb +0 -70
  197. data/lib/recipes/apache_conf.rb +0 -3
  198. data/lib/recipes/bundler.rb +0 -4
  199. data/lib/recipes/chef_client.rb +0 -11
  200. data/lib/recipes/curl.rb +0 -8
  201. data/lib/recipes/essential.rb +0 -4
  202. data/lib/recipes/git.rb +0 -15
  203. data/lib/recipes/imagemagick.rb +0 -8
  204. data/lib/recipes/mailserver.rb +0 -9
  205. data/lib/recipes/memcached.rb +0 -16
  206. data/lib/recipes/mysql.rb +0 -21
  207. data/lib/recipes/nginx/init.d +0 -63
  208. data/lib/recipes/nginx.rb +0 -25
  209. data/lib/recipes/passenger.rb +0 -67
  210. data/lib/recipes/php.rb +0 -8
  211. data/lib/recipes/postgresql.rb +0 -21
  212. data/lib/recipes/ruby_enterprise.rb +0 -24
  213. data/lib/recipes/rvm.rb +0 -25
  214. data/lib/recipes/sources.rb +0 -5
  215. data/lib/recipes/subversion.rb +0 -8
  216. data/lib/recipes/syslog.rb +0 -7
  217. data/lib/recipes/ufw.rb +0 -12
  218. data/lib/recipes/vim.rb +0 -8
  219. data/lib/recipes/webmin.rb +0 -17
  220. data/lib/templates/apache.conf.erb +0 -12
  221. data/lib/templates/my.cnf +0 -132
  222. data/lib/templates/passenger.conf +0 -11
  223. data/lib/templates/passenger.load +0 -1
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env ruby
2
+ pod=<<-POD
3
+
4
+ =head1 NAME
5
+ rails_view_render_time - Munin plugin to monitor the minimum, average and maximum view render times.
6
+
7
+ =head1 APPLICABLE SYSTEMS
8
+ All systems that have a rails application log.
9
+
10
+ =head1 CONFIGURATION
11
+ The request-log-analyzer gem has to be intalled.
12
+ Also the script has to be able to access the rails log file and tail.
13
+ This configuration section shows the defaults of the plugin:
14
+
15
+ [rails_view_render_time]
16
+ env.log_file '/path/to/production.log'
17
+ user www-data
18
+ command /usr/local/bin/ruby %c
19
+
20
+ Options
21
+ env.lines 50000 # Number of lines to tail
22
+ env.interval 300 # Munin interval in seconds (used for graphs and caching)
23
+ env.request_log_analyzer '/usr/local/bin' # Path to gem. Use this for Debian.
24
+ env.graph_category 'App' # Graph Category. Defaults to App.
25
+
26
+ ln -s /usr/share/munin/plugins/rails_view_render_time /etc/munin/plugins/rails_view_render_time
27
+
28
+ =head1 INTERPRETATION
29
+ Three lines are graphed, showing the minimum, average and maximum view render times.
30
+
31
+ =head1 MAGIC MARKERS
32
+ #%# family=auto
33
+ #%# capabilities=autoconf
34
+
35
+ =head1 VERSION
36
+ 1.5
37
+
38
+ =head1 BUGS
39
+ None known
40
+
41
+ =head1 AUTHOR
42
+ Bart ten Brinke - railsdoctors.com
43
+
44
+ =head1 LICENSE
45
+ MIT
46
+
47
+ POD
48
+
49
+ # Globals
50
+ GRAPH_CATEGORY = ENV['graph_category'] || 'App'
51
+ INTERVAL = ENV['interval'] ? ENV['interval'].to_i : 300
52
+ NUMBER_OF_LINES = ENV['lines'] || 50000
53
+ LOG_FILE = ENV['log_file']
54
+ AFTER_TIME = (Time.now - INTERVAL).strftime('%Y%m%d%H%M%S')
55
+ FLOOR_TIME = Time.at((Time.now.to_f / INTERVAL).floor * INTERVAL)
56
+
57
+ TEMP_FOLDER = '/tmp'
58
+ TEMP_PREFIX = GRAPH_CATEGORY == 'App' ? 'rla' : GRAPH_CATEGORY.downcase
59
+ TEMP_FILE = "#{TEMP_PREFIX}_#{FLOOR_TIME.to_i}.yml"
60
+ REQUEST_LOG_ANALYZER = ENV['request_log_analyzer'] || '/usr/bin/request-log-analyzer'
61
+
62
+ # Check if we can run this plugin on this system
63
+ def autoconf
64
+ begin
65
+ require 'rubygems'
66
+ gem "request-log-analyzer", ">=1.1.6"
67
+ require "yaml"
68
+ rescue Exception => e
69
+ puts "no (Gem not found: #{e})"
70
+ exit 1
71
+ end
72
+
73
+ unless `echo "test" | tail 2>/dev/null`.include?("test")
74
+ puts "no (tail command not found)"
75
+ exit 1
76
+ end
77
+
78
+ puts "yes"
79
+ exit 0
80
+ end
81
+
82
+ # Uptput the config
83
+ def config
84
+ puts <<-CONFIG
85
+ graph_category #{GRAPH_CATEGORY}
86
+ graph_title View render times
87
+ graph_vlabel Seconds
88
+ graph_args --base 1000 -l 0
89
+ graph_info The minimum, maximum and average view render times - railsdoctors.com
90
+
91
+ min.label min
92
+ max.label max
93
+ average.label avg
94
+ CONFIG
95
+ exit 0
96
+ end
97
+
98
+ # Fetch or create yaml cache file using request-log-analyzer
99
+ def fetch_or_create_yaml_file(log_file, debug = false)
100
+ # Clean up any old temp files left in de temp folder
101
+ Dir.new(TEMP_FOLDER).entries.each do |file_name|
102
+ if match = file_name.match(/^#{TEMP_PREFIX}_.*\.yml/)
103
+ if match[0] != TEMP_FILE
104
+ puts "Removing old cache file: #{file_name}" if debug
105
+ File.delete(TEMP_FOLDER + "/" + file_name)
106
+ end
107
+ end
108
+ end
109
+
110
+ temp_file = TEMP_FOLDER + "/" + TEMP_FILE
111
+
112
+ # Create temp file rla if needed
113
+ unless File.exists?(temp_file)
114
+ puts "Processing the last #{NUMBER_OF_LINES} lines of #{log_file} which are less then #{INTERVAL} seconds old." if debug
115
+ p "tail -n #{NUMBER_OF_LINES} #{log_file} | #{REQUEST_LOG_ANALYZER} - --format rails3 --after #{AFTER_TIME} -b --dump #{temp_file} 2>/dev/null"
116
+ status = `tail -n #{NUMBER_OF_LINES} #{log_file} | #{REQUEST_LOG_ANALYZER} - --format rails3 --after #{AFTER_TIME} -b --dump #{temp_file} 2>/dev/null`
117
+
118
+ unless $?.success?
119
+ $stderr.puts "failed executing request-log-analyzer. Is the path to the binary correct?"
120
+ exit 1
121
+ end
122
+ else
123
+ puts "Processing cached YAML result #{temp_file}" if debug
124
+ end
125
+
126
+ return temp_file
127
+ end
128
+
129
+ # Gather information
130
+ def run(log_file, debug = false)
131
+
132
+ if log_file == "" || log_file.nil?
133
+ $stderr.puts "Filepath unspecified. Exiting"
134
+ exit 1
135
+ end
136
+
137
+ # Initialize values
138
+ max_value = 0
139
+ min_value = 1.0/0.0
140
+ cumulative = 0
141
+ hits = 0
142
+
143
+ # Walk through the
144
+ require "yaml"
145
+ rla = YAML::load_file( fetch_or_create_yaml_file(log_file, debug) )
146
+
147
+ if rla && rla["View rendering time"]
148
+ rla["View rendering time"].each do |item|
149
+ max_value = item[1][:max] if item[1][:max] > max_value
150
+ min_value = item[1][:min] if item[1][:min] < min_value
151
+ hits += item[1][:hits]
152
+ cumulative += item[1][:sum]
153
+ end
154
+ else
155
+ hits = 1
156
+ min_value = 0
157
+ end
158
+
159
+ puts "max.value #{max_value}"
160
+ puts "min.value #{min_value}"
161
+ puts "average.value #{cumulative / hits.to_f}"
162
+ end
163
+
164
+ # Main
165
+ if ARGV[0] == "config"
166
+ config
167
+ elsif ARGV[0] == "autoconf"
168
+ autoconf
169
+ elsif ARGV[0] == "debug"
170
+ run(LOG_FILE || ARGV[1], true)
171
+ else
172
+ run(LOG_FILE || ARGV[0])
173
+ end
@@ -0,0 +1,4 @@
1
+ env.log_file '<%= log %>'
2
+ env.request_log_analyzer '/usr/local/bin/request-log-analyzer'
3
+ user application
4
+ command /usr/local/bin/ruby %c
@@ -0,0 +1,60 @@
1
+ class munin {
2
+ package {"munin":
3
+ ensure => present
4
+ }
5
+
6
+ package {"munin-node":
7
+ ensure => present,
8
+ require => Package["munin"]
9
+ }
10
+
11
+ service {"munin-node":
12
+ require => Package["munin-node"],
13
+ ensure => running,
14
+ enable => true
15
+ }
16
+
17
+ package {"request-log-analyzer":
18
+ ensure => present,
19
+ provider => gem
20
+ }
21
+
22
+ define rails($log) {
23
+ munin::plugin {"$name-rails-requests":
24
+ config => template("munin/rails-plugin-config"),
25
+ content => template("munin/plugins/rails_requests")
26
+ }
27
+
28
+ munin::plugin {"$name-rails-request-duration":
29
+ config => template("munin/rails-plugin-config"),
30
+ content => template("munin/plugins/rails_request_duration")
31
+ }
32
+
33
+ munin::plugin {"$name-rails-request-error":
34
+ config => template("munin/rails-plugin-config"),
35
+ content => template("munin/plugins/rails_request_error")
36
+ }
37
+
38
+ munin::plugin {"$name-rails-view-render-time":
39
+ config => template("munin/rails-plugin-config"),
40
+ content => template("munin/plugins/rails_view_render_time")
41
+ }
42
+ }
43
+
44
+ define plugin($config, $content) {
45
+ include munin
46
+
47
+ file {"/etc/munin/plugins/$name":
48
+ content => $content,
49
+ mode => 777,
50
+ require => Package["munin-node"],
51
+ notify => Service["munin-node"]
52
+ }
53
+
54
+ file {"/etc/munin/plugin-conf.d/$name":
55
+ content => "[$name]\n$config",
56
+ require => Package["munin-node"],
57
+ notify => Service["munin-node"]
58
+ }
59
+ }
60
+ }
@@ -0,0 +1 @@
1
+ <%= 16.times.collect{('a'..'z').to_a[rand(26)]}.join %>
@@ -0,0 +1,71 @@
1
+ class mysql {
2
+
3
+ class client {
4
+ $package_name = $operatingsystem ? {
5
+ centos => mysql,
6
+ default => mysql-client
7
+ }
8
+
9
+ $development_package_name = $operatingsystem ? {
10
+ centos => mysql-devel,
11
+ default => libmysqlclient-dev
12
+ }
13
+
14
+ package { $package_name:
15
+ ensure => present
16
+ }
17
+
18
+ package { $development_package_name:
19
+ ensure => present
20
+ }
21
+ }
22
+
23
+ class server {
24
+ include mysql::client
25
+
26
+ $mysql_password = template("mysql/password.erb")
27
+
28
+ package {"mysql-server":
29
+ ensure => present
30
+ }
31
+
32
+ $service_name = $operatingsystem ? {
33
+ centos => mysqld,
34
+ default => mysql
35
+ }
36
+
37
+ service {$service_name:
38
+ require => Package["mysql-server"],
39
+ ensure => running,
40
+ alias => mysql-server,
41
+ enable => true
42
+ }
43
+
44
+ exec { "Initialize MySQL server root password":
45
+ unless => "/usr/bin/test -f /root/.my.cnf",
46
+ command => "/usr/bin/mysqladmin -uroot password ${mysql_password}",
47
+ notify => File["/root/.my.cnf"],
48
+ require => [Package["mysql-server"], Service[mysql-server]]
49
+ }
50
+
51
+ file { "/root/.my.cnf":
52
+ content => "[mysql]\nuser=root\npassword=${mysql_password}\n[mysqladmin]\nuser=root\npassword=${mysql_password}\n[mysqldump]\nuser=root\npassword=${mysql_password}\n[mysqlshow]\nuser=root\npassword=${mysql_password}\n",
53
+ mode => 600,
54
+ replace => false
55
+ }
56
+
57
+ define db( $user, $password ) {
58
+ exec { "create-${name}-db":
59
+ unless => "/usr/bin/mysql -uroot ${name}",
60
+ command => "/usr/bin/mysql -uroot -e \"create database ${name};\"",
61
+ require => Service[mysql-server],
62
+ }
63
+
64
+ exec { "grant-${name}-db":
65
+ unless => "/usr/bin/mysql -u${user} -p${password} ${name}",
66
+ command => "/usr/bin/mysql -uroot -e \"grant all on ${name}.* to ${user}@localhost identified by '$password';\"",
67
+ require => [Service[mysql-server], Exec["create-${name}-db"]]
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,17 @@
1
+ # /etc/ipsec.conf - Openswan IPsec configuration file
2
+ #
3
+ # Manual: ipsec.conf.5
4
+ #
5
+ # Please place your own config files in /etc/ipsec.d/ ending in .conf
6
+
7
+ version 2.0 # conforms to second version of ipsec.conf specification
8
+
9
+ # basic configuration
10
+ config setup
11
+ plutodebug="control parsing"
12
+ oe=no
13
+ protostack=auto
14
+ interfaces=%defaultroute
15
+
16
+ include /etc/ipsec.d/*.conf
17
+
@@ -0,0 +1 @@
1
+ include /etc/ipsec.d/*.secret
@@ -0,0 +1,223 @@
1
+ #!/bin/bash
2
+ # IPsec startup and shutdown script
3
+ #
4
+ ### BEGIN INIT INFO
5
+ # Provides: openswan
6
+ # Required-Start: $network $syslog $named
7
+ # Required-Stop: $syslog
8
+ # Default-Start: 2 3 4 5
9
+ # Default-Stop: 0 1 6
10
+ # Short-Description: Start Openswan IPsec at boot time
11
+ # Description: Enable automatic key management for IPsec (KLIPS and NETKEY)
12
+ ### END INIT INFO
13
+ #
14
+ # Copyright (C) 1998, 1999, 2001 Henry Spencer.
15
+ # Copyright (C) 2002 Michael Richardson <mcr@freeswan.org>
16
+ # Copyright (C) 2006 Michael Richardson <mcr@xelerance.com>
17
+ # Copyright (C) 2008 Michael Richardson <mcr@sandelman.ca>
18
+ #
19
+ # This program is free software; you can redistribute it and/or modify it
20
+ # under the terms of the GNU General Public License as published by the
21
+ # Free Software Foundation; either version 2 of the License, or (at your
22
+ # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
23
+ #
24
+ # This program is distributed in the hope that it will be useful, but
25
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26
+ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27
+ # for more details.
28
+ #
29
+ #
30
+ # ipsec init.d script for starting and stopping
31
+ # the IPsec security subsystem (KLIPS and Pluto).
32
+ #
33
+ # This script becomes /etc/rc.d/init.d/ipsec (or possibly /etc/init.d/ipsec)
34
+ # and is also accessible as "ipsec setup" (the preferred route for human
35
+ # invocation).
36
+ #
37
+ # The startup and shutdown times are a difficult compromise (in particular,
38
+ # it is almost impossible to reconcile them with the insanely early/late
39
+ # times of NFS filesystem startup/shutdown). Startup is after startup of
40
+ # syslog and pcmcia support; shutdown is just before shutdown of syslog.
41
+ #
42
+ # chkconfig: 2345 47 76
43
+ # description: IPsec provides encrypted and authenticated communications; \
44
+ # KLIPS is the kernel half of it, Pluto is the user-level management daemon.
45
+
46
+ me='ipsec setup' # for messages
47
+
48
+ # where the private directory and the config files are
49
+ IPSEC_EXECDIR="${IPSEC_EXECDIR-/usr/lib/ipsec}"
50
+ IPSEC_LIBDIR="${IPSEC_LIBDIR-/usr/lib/ipsec}"
51
+ IPSEC_SBINDIR="${IPSEC_SBINDIR-/usr/sbin}"
52
+ IPSEC_CONFS="${IPSEC_CONFS-/etc}"
53
+
54
+ if test " $IPSEC_DIR" = " " # if we were not called by the ipsec command
55
+ then
56
+ # we must establish a suitable PATH ourselves
57
+ PATH="${IPSEC_SBINDIR}":/sbin:/usr/sbin:/usr/bin:/bin:/usr/bin
58
+ export PATH
59
+
60
+ IPSEC_DIR="$IPSEC_LIBDIR"
61
+ export IPSEC_DIR IPSEC_CONFS IPSEC_LIBDIR IPSEC_EXECDIR
62
+ fi
63
+
64
+ # Check that the ipsec command is available.
65
+ found=
66
+ for dir in `echo $PATH | tr ':' ' '`
67
+ do
68
+ if test -f $dir/ipsec -a -x $dir/ipsec
69
+ then
70
+ found=yes
71
+ break # NOTE BREAK OUT
72
+ fi
73
+ done
74
+ if ! test "$found"
75
+ then
76
+ echo "cannot find ipsec command -- \`$1' aborted" |
77
+ logger -s -p daemon.error -t ipsec_setup
78
+ exit 1
79
+ fi
80
+
81
+ # accept a few flags
82
+
83
+ export IPSEC_setupflags
84
+ IPSEC_setupflags=""
85
+
86
+ config=""
87
+
88
+ for dummy
89
+ do
90
+ case "$1" in
91
+ --showonly|--show) IPSEC_setupflags="$1" ;;
92
+ --config) config="--config $2" ; shift ;;
93
+ *) break ;;
94
+ esac
95
+ shift
96
+ done
97
+
98
+
99
+ # Pick up IPsec configuration (until we have done this, successfully, we
100
+ # do not know where errors should go, hence the explicit "daemon.error"s.)
101
+ # Note the "--export", which exports the variables created.
102
+ variables=`ipsec addconn $config --varprefix IPSEC --configsetup`
103
+
104
+ # Free Range / JGA / JM: the provided version of the script didn't return the actual
105
+ # exit code which meant that puppet didn't know that the service failed to start.
106
+ RETVAL=$?
107
+
108
+
109
+ if [ $RETVAL != 0 ]
110
+ then
111
+ echo "Failed to parse config setup portion of ipsec.conf"
112
+ exit $RETVAL
113
+ fi
114
+ eval $variables
115
+
116
+ if test " $IPSEC_confreadstatus" != " "
117
+ then
118
+ case $1 in
119
+ stop|--stop|_autostop)
120
+ echo "$IPSEC_confreadstatus -- \`$1' may not work" |
121
+ logger -s -p daemon.error -t ipsec_setup;;
122
+
123
+ *) echo "$IPSEC_confreadstatus -- \`$1' aborted" |
124
+ logger -s -p daemon.error -t ipsec_setup;
125
+ exit 1;;
126
+ esac
127
+ fi
128
+
129
+ IPSEC_confreadsection=${IPSEC_confreadsection:-setup}
130
+ export IPSEC_confreadsection
131
+
132
+ IPSECsyslog=${IPSECsyslog-daemon.error}
133
+ export IPSECsyslog
134
+
135
+ # misc setup
136
+ umask 022
137
+
138
+ mkdir -p /var/run/pluto
139
+
140
+ RETVAL=0
141
+
142
+ start_stop() {
143
+ # remove for: @cygwin_START@
144
+ # portable way for checking for root
145
+ if test " `id -u`" != " 0"
146
+ then
147
+ echo "permission denied (must be superuser)" |
148
+ logger -s -p $IPSECsyslog -t ipsec_setup 2>&1
149
+ exit 1
150
+ fi
151
+ # remove for: @cygwin_END@
152
+
153
+ # Free Range / KS / CR: _realsetup script from ipsec does not correctly create this directory on reboot
154
+ mkdir -p /var/lock/subsys
155
+
156
+ (
157
+ ipsec _realsetup $1
158
+ RETVAL="$?"
159
+ ) 2>&1 | logger -s -p $IPSECsyslog -t ipsec_setup 2>&1
160
+
161
+ return $RETVAL
162
+ }
163
+
164
+
165
+ restart_reload() {
166
+ $0 $IPSEC_setupflags stop
167
+ $0 $IPSEC_setupflags start
168
+ }
169
+
170
+
171
+ autorestart() {
172
+ $0 $IPSEC_setupflags _autostop
173
+ $0 $IPSEC_setupflags _autostart
174
+ }
175
+
176
+ version() {
177
+ ipsec version
178
+ RETVAL=$?
179
+ return $RETVAL
180
+ }
181
+
182
+
183
+ show_help() {
184
+ echo "Usage: $me [ --showonly ] {--start|--stop|--restart}"
185
+ echo " $me --status"
186
+ RETVAL=0
187
+ return $RETVAL
188
+ }
189
+
190
+ # do it
191
+ case "$1" in
192
+ start|--start|stop|--stop|_autostop|_autostart)
193
+ start_stop $1
194
+ ;;
195
+
196
+ restart|--restart|force-reload)
197
+ restart_reload
198
+ ;;
199
+
200
+ _autorestart) # for internal use only
201
+ autorestart
202
+ ;;
203
+
204
+ status|--status)
205
+ ipsec _realsetup $1
206
+ RETVAL=$?
207
+ ;;
208
+
209
+ version|--version)
210
+ version
211
+ ;;
212
+
213
+ help|--help)
214
+ show_help
215
+ ;;
216
+
217
+ *)
218
+ echo "Usage: $me [ --showonly ] {--start|--stop|--restart}"
219
+ echo " $me --status"
220
+ RETVAL=2
221
+ esac
222
+
223
+ exit $RETVAL
@@ -0,0 +1 @@
1
+ <%= client_ip %> <%= server_ip %>: PSK "<%= pre_shared_key %>"
@@ -0,0 +1,71 @@
1
+ class openswan {
2
+ package { "openswan":
3
+ ensure => "1:2.6.23+dfsg-1ubuntu1"
4
+ }
5
+
6
+ file { "/etc/init.d/ipsec":
7
+ content => template("openswan/patched_ipsec_initd_script"),
8
+ owner => root,
9
+ group => root,
10
+ mode => 755,
11
+ require => Package[openswan]
12
+ }
13
+
14
+ file { "/etc/ipsec.d":
15
+ ensure => directory,
16
+ owner => root,
17
+ group => root,
18
+ require => Package[openswan]
19
+ }
20
+
21
+ file { "/etc/ipsec.conf":
22
+ content => template("openswan/ipsec.conf"),
23
+ owner => root,
24
+ group => root,
25
+ require => File["/etc/ipsec.d"]
26
+ }
27
+
28
+ define connection($content) {
29
+ include openswan
30
+
31
+ file { "/etc/ipsec.d/$name.conf":
32
+ owner => root,
33
+ group => root,
34
+ mode => 644,
35
+ content => $content,
36
+ notify => Service[ipsec]
37
+ }
38
+ }
39
+
40
+ file { "/etc/ipsec.secrets":
41
+ content => template("openswan/ipsec.secrets"),
42
+ owner => root,
43
+ group => root,
44
+ mode => 600,
45
+ require => File["/etc/ipsec.d"]
46
+ }
47
+
48
+ define psk_secret($client_ip, $server_ip, $pre_shared_key) {
49
+ include openswan
50
+
51
+ file { "/etc/ipsec.d/$name.secret":
52
+ owner => root,
53
+ group => root,
54
+ mode => 600,
55
+ content => template("openswan/secret.erb"),
56
+ notify => Service[ipsec]
57
+ }
58
+ }
59
+
60
+ exec {"fix-runlevel":
61
+ command => "update-rc.d -f ipsec remove && update-rc.d ipsec defaults",
62
+ require => Package[openswan]
63
+ }
64
+
65
+ service { "ipsec":
66
+ require => [Package["openswan"], File["/etc/ipsec.conf"], File["/etc/ipsec.secrets"], File["/etc/init.d/ipsec"], Exec["fix-runlevel"]],
67
+ ensure => running,
68
+ subscribe => [File["/etc/ipsec.conf"], File["/etc/ipsec.secrets"], File["/etc/init.d/ipsec"]]
69
+ }
70
+
71
+ }
@@ -0,0 +1,17 @@
1
+ stage { "post-flight": require => Stage[main] }
2
+ class { "post-flight": stage => "post-flight" }
3
+
4
+ class post-flight {
5
+ exec { "application group ownership":
6
+ command => "chgrp -R application /var/apps",
7
+ require => File["/var/apps"]
8
+ }
9
+ exec { "application sticky bit":
10
+ command => "chmod -R g+rwxs /var/apps",
11
+ require => File["/var/apps"]
12
+ }
13
+ exec { "application permissions":
14
+ command => "chmod -R g+rww /var/apps",
15
+ require => File["/var/apps"]
16
+ }
17
+ }
@@ -0,0 +1,39 @@
1
+ # See /usr/share/postfix/main.cf.dist for a commented, more complete version
2
+
3
+
4
+ # Debian specific: Specifying a file name will cause the first
5
+ # line of that file to be used as the name. The Debian default
6
+ # is /etc/mailname.
7
+ #myorigin = /etc/mailname
8
+
9
+ smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
10
+ biff = no
11
+
12
+ # appending .domain is the MUA's job.
13
+ append_dot_mydomain = no
14
+
15
+ # Uncomment the next line to generate "delayed mail" warnings
16
+ #delay_warning_time = 4h
17
+
18
+ readme_directory = no
19
+
20
+ # TLS parameters
21
+ smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
22
+ smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
23
+ smtpd_use_tls=no
24
+ smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
25
+ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
26
+
27
+ # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
28
+ # information on enabling SSL in the smtp client.
29
+
30
+ #myhostname = localhost
31
+ alias_maps = hash:/etc/aliases
32
+ alias_database = hash:/etc/aliases
33
+ mydestination = localdomain, localhost, localhost.localdomain, localhost
34
+ relayhost =
35
+ mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
36
+ mailbox_size_limit = 0
37
+ recipient_delimiter = +
38
+ inet_interfaces = all
39
+