server_maint 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +17 -0
  2. data/.gitmodules +6 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/lib/cookbooks/nginx/.gitignore +4 -0
  8. data/lib/cookbooks/nginx/CHANGELOG.md +63 -0
  9. data/lib/cookbooks/nginx/CONTRIBUTING +29 -0
  10. data/lib/cookbooks/nginx/Gemfile +3 -0
  11. data/lib/cookbooks/nginx/LICENSE +201 -0
  12. data/lib/cookbooks/nginx/README.md +211 -0
  13. data/lib/cookbooks/nginx/attributes/default.rb +70 -0
  14. data/lib/cookbooks/nginx/attributes/echo.rb +3 -0
  15. data/lib/cookbooks/nginx/attributes/geoip.rb +30 -0
  16. data/lib/cookbooks/nginx/attributes/naxsi.rb +24 -0
  17. data/lib/cookbooks/nginx/attributes/passenger.rb +7 -0
  18. data/lib/cookbooks/nginx/attributes/source.rb +37 -0
  19. data/lib/cookbooks/nginx/attributes/upload_progress.rb +23 -0
  20. data/lib/cookbooks/nginx/definitions/nginx_site.rb +35 -0
  21. data/lib/cookbooks/nginx/files/default/mime.types +73 -0
  22. data/lib/cookbooks/nginx/files/default/naxsi_core.rules +70 -0
  23. data/lib/cookbooks/nginx/files/default/tests/minitest/default_test.rb +12 -0
  24. data/lib/cookbooks/nginx/files/default/tests/minitest/helpers.rb +7 -0
  25. data/lib/cookbooks/nginx/files/default/tests/minitest/source_test.rb +9 -0
  26. data/lib/cookbooks/nginx/metadata.rb +95 -0
  27. data/lib/cookbooks/nginx/recipes/authorized_ips.rb +41 -0
  28. data/lib/cookbooks/nginx/recipes/commons.rb +23 -0
  29. data/lib/cookbooks/nginx/recipes/commons_conf.rb +39 -0
  30. data/lib/cookbooks/nginx/recipes/commons_dir.rb +39 -0
  31. data/lib/cookbooks/nginx/recipes/commons_script.rb +28 -0
  32. data/lib/cookbooks/nginx/recipes/default.rb +42 -0
  33. data/lib/cookbooks/nginx/recipes/http_echo_module.rb +46 -0
  34. data/lib/cookbooks/nginx/recipes/http_geoip_module.rb +117 -0
  35. data/lib/cookbooks/nginx/recipes/http_gzip_static_module.rb +23 -0
  36. data/lib/cookbooks/nginx/recipes/http_realip_module.rb +46 -0
  37. data/lib/cookbooks/nginx/recipes/http_ssl_module.rb +23 -0
  38. data/lib/cookbooks/nginx/recipes/http_stub_status_module.rb +36 -0
  39. data/lib/cookbooks/nginx/recipes/naxsi_module.rb +53 -0
  40. data/lib/cookbooks/nginx/recipes/ohai_plugin.rb +32 -0
  41. data/lib/cookbooks/nginx/recipes/passenger.rb +51 -0
  42. data/lib/cookbooks/nginx/recipes/source.rb +182 -0
  43. data/lib/cookbooks/nginx/recipes/upload_progress_module.rb +47 -0
  44. data/lib/cookbooks/nginx/templates/debian/nginx.init.erb +97 -0
  45. data/lib/cookbooks/nginx/templates/default/default-site.erb +11 -0
  46. data/lib/cookbooks/nginx/templates/default/modules/authorized_ip.erb +6 -0
  47. data/lib/cookbooks/nginx/templates/default/modules/http_geoip.conf.erb +4 -0
  48. data/lib/cookbooks/nginx/templates/default/modules/http_realip.conf.erb +4 -0
  49. data/lib/cookbooks/nginx/templates/default/modules/nginx_status.erb +14 -0
  50. data/lib/cookbooks/nginx/templates/default/modules/passenger.conf.erb +3 -0
  51. data/lib/cookbooks/nginx/templates/default/nginx.conf.erb +48 -0
  52. data/lib/cookbooks/nginx/templates/default/nginx.init.erb +92 -0
  53. data/lib/cookbooks/nginx/templates/default/nginx.pill.erb +15 -0
  54. data/lib/cookbooks/nginx/templates/default/nginx.sysconfig.erb +1 -0
  55. data/lib/cookbooks/nginx/templates/default/nxdissite.erb +29 -0
  56. data/lib/cookbooks/nginx/templates/default/nxensite.erb +38 -0
  57. data/lib/cookbooks/nginx/templates/default/plugins/nginx.rb.erb +66 -0
  58. data/lib/cookbooks/nginx/templates/default/sv-nginx-log-run.erb +2 -0
  59. data/lib/cookbooks/nginx/templates/default/sv-nginx-run.erb +3 -0
  60. data/lib/cookbooks/nginx/templates/ubuntu/nginx.init.erb +97 -0
  61. data/lib/cookbooks/nginx/test/kitchen/Kitchenfile +5 -0
  62. data/lib/cookbooks/sanitize/.gitignore +1 -0
  63. data/lib/cookbooks/sanitize/CHANGELOG.md +10 -0
  64. data/lib/cookbooks/sanitize/README.md +65 -0
  65. data/lib/cookbooks/sanitize/attributes/default.rb +1 -0
  66. data/lib/cookbooks/sanitize/libraries/default.rb +8 -0
  67. data/lib/cookbooks/sanitize/metadata.rb +12 -0
  68. data/lib/cookbooks/sanitize/recipes/default.rb +113 -0
  69. data/lib/cookbooks/sanitize/templates/default/port_ssh.erb +2 -0
  70. data/lib/server_maint/version.rb +3 -0
  71. data/lib/server_maint.rb +7 -0
  72. data/server_maint.gemspec +33 -0
  73. metadata +155 -0
@@ -0,0 +1 @@
1
+ default['sanitize']['iptables'] = true
@@ -0,0 +1,8 @@
1
+ # Allow setting Gem.user_home attribute to be able to remove the
2
+ # default 'ubuntu' user on the first run.
3
+ module Gem
4
+ def self.user_home=(value)
5
+ @user_home = value
6
+ end
7
+ end
8
+
@@ -0,0 +1,12 @@
1
+ maintainer "Maciej Pasternacki"
2
+ maintainer_email "maciej@pasternacki.net"
3
+ license "MIT"
4
+ description "Sanitizes system by providing a sane default configuration"
5
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
6
+ version "0.1.0"
7
+
8
+ supports 'ubuntu', ">= 10.04"
9
+
10
+ depends 'apt'
11
+ depends 'build-essential'
12
+ depends 'iptables'
@@ -0,0 +1,113 @@
1
+ #
2
+ # Cookbook Name:: sanitize
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2012, Maciej Pasternacki
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to
12
+ # permit persons to whom the Software is furnished to do so, subject to
13
+ # the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be
16
+ # included in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ #
26
+
27
+ ## Prerequisites and system information
28
+
29
+ require 'etc'
30
+
31
+ node['build_essential']['compiletime'] = true
32
+
33
+ include_recipe 'apt'
34
+ include_recipe 'build-essential'
35
+
36
+ ## Delete default 'ubuntu' user if it exists; it's provided by the EC2 image.
37
+
38
+ ubuntu_user = begin
39
+ Etc.getpwnam('ubuntu')
40
+ rescue ArgumentError
41
+ nil
42
+ end
43
+
44
+ # HACK: Forget about ubuntu user we're about to force delete
45
+ Dir.chdir('/root') if Dir.getwd == '/home/ubuntu'
46
+ ENV['HOME'] = '/root' if ENV['HOME'] == '/home/ubuntu'
47
+ Gem.user_home = '/root' if Gem.user_home == '/home/ubuntu'
48
+
49
+ # FIXME: use 'user' resource?
50
+ execute "userdel -r -f ubuntu || true" do
51
+ only_if { ubuntu_user }
52
+ end
53
+
54
+ ## Lock out root account - sudo-only. Make sure this runs AFTER your
55
+ ## users accounts and sudoers file are set up.
56
+
57
+ chef_gem "ruby-shadow"
58
+
59
+ user "root" do
60
+ password '!*'
61
+ end
62
+
63
+ ## Sanitize directory structure
64
+
65
+ directory "/opt"
66
+
67
+ ## Locale
68
+
69
+ execute 'locale-gen en_US.UTF-8'
70
+
71
+ file '/etc/default/locale' do
72
+ content 'LANG=en_US.UTF-8'
73
+ owner 'root'
74
+ group 'root'
75
+ mode '0644'
76
+ end
77
+
78
+ execute "configure time zone" do
79
+ action :nothing
80
+ command "dpkg-reconfigure -fnoninteractive tzdata"
81
+ end
82
+
83
+ file '/etc/timezone' do
84
+ content 'Etc/UTC'
85
+ notifies :run, "execute[configure time zone]", :immediately
86
+ end
87
+
88
+ ## Misc
89
+
90
+ file "/var/log/chef/client.log" do
91
+ mode "0600"
92
+ end
93
+
94
+ link "/usr/local/bin/can-has" do
95
+ to "/usr/bin/apt-get"
96
+ end
97
+
98
+ %w(10-help-text 51_update-motd).each do |fn|
99
+ file "/etc/update-motd.d/#{fn}" do
100
+ action :delete
101
+ end
102
+ end
103
+
104
+ package "vim-nox"
105
+
106
+ execute "update-alternatives --set editor /usr/bin/vim.nox" do
107
+ not_if "update-alternatives --query editor |grep -q '^Value: /usr/bin/vim.nox$'"
108
+ end
109
+
110
+ if node['sanitize']['iptables']
111
+ include_recipe 'iptables'
112
+ iptables_rule "port_ssh"
113
+ end
@@ -0,0 +1,2 @@
1
+ # SSH
2
+ -A FWR -p tcp -m tcp --dport 22 -j ACCEPT
@@ -0,0 +1,3 @@
1
+ module ServerMaint
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require "server_maint/version"
2
+
3
+ module ServerMaint
4
+ def self.get_cookbook_path
5
+ File.expand_path('../cookbooks', __FILE__)
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'server_maint/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "server_maint"
8
+ gem.version = ServerMaint::VERSION
9
+ gem.authors = ["Fritz-Rainer Doebbelin"]
10
+ gem.email = ["frd@doebbelin.net"]
11
+ gem.description = %q{Server maintenance with chef-solo}
12
+ gem.summary = %q{Host usefull chef cookbooks for server maintenance}
13
+ gem.homepage = "http://github.com/fdoebbelin/server_maint"
14
+
15
+ gem.add_development_dependency "rake"
16
+ gem.add_dependency "chef"
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+
23
+ `git submodule --quiet foreach pwd`.split($\).each do |submodule_expand_path|
24
+ submodule_path = submodule_expand_path.gsub("#{File.expand_path('../',__FILE__)}/", '')
25
+ Dir.chdir(submodule_path) do
26
+ submodule_files = `git ls-files`.split($\)
27
+ submodule_file_paths = submodule_files.map do |filename|
28
+ "#{submodule_path}/#{filename}"
29
+ end
30
+ gem.files += submodule_file_paths
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: server_maint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fritz-Rainer Doebbelin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: chef
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Server maintenance with chef-solo
47
+ email:
48
+ - frd@doebbelin.net
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .gitmodules
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/server_maint.rb
60
+ - lib/server_maint/version.rb
61
+ - server_maint.gemspec
62
+ - lib/cookbooks/nginx/.gitignore
63
+ - lib/cookbooks/nginx/CHANGELOG.md
64
+ - lib/cookbooks/nginx/CONTRIBUTING
65
+ - lib/cookbooks/nginx/Gemfile
66
+ - lib/cookbooks/nginx/LICENSE
67
+ - lib/cookbooks/nginx/README.md
68
+ - lib/cookbooks/nginx/attributes/default.rb
69
+ - lib/cookbooks/nginx/attributes/echo.rb
70
+ - lib/cookbooks/nginx/attributes/geoip.rb
71
+ - lib/cookbooks/nginx/attributes/naxsi.rb
72
+ - lib/cookbooks/nginx/attributes/passenger.rb
73
+ - lib/cookbooks/nginx/attributes/source.rb
74
+ - lib/cookbooks/nginx/attributes/upload_progress.rb
75
+ - lib/cookbooks/nginx/definitions/nginx_site.rb
76
+ - lib/cookbooks/nginx/files/default/mime.types
77
+ - lib/cookbooks/nginx/files/default/naxsi_core.rules
78
+ - lib/cookbooks/nginx/files/default/tests/minitest/default_test.rb
79
+ - lib/cookbooks/nginx/files/default/tests/minitest/helpers.rb
80
+ - lib/cookbooks/nginx/files/default/tests/minitest/source_test.rb
81
+ - lib/cookbooks/nginx/metadata.rb
82
+ - lib/cookbooks/nginx/recipes/authorized_ips.rb
83
+ - lib/cookbooks/nginx/recipes/commons.rb
84
+ - lib/cookbooks/nginx/recipes/commons_conf.rb
85
+ - lib/cookbooks/nginx/recipes/commons_dir.rb
86
+ - lib/cookbooks/nginx/recipes/commons_script.rb
87
+ - lib/cookbooks/nginx/recipes/default.rb
88
+ - lib/cookbooks/nginx/recipes/http_echo_module.rb
89
+ - lib/cookbooks/nginx/recipes/http_geoip_module.rb
90
+ - lib/cookbooks/nginx/recipes/http_gzip_static_module.rb
91
+ - lib/cookbooks/nginx/recipes/http_realip_module.rb
92
+ - lib/cookbooks/nginx/recipes/http_ssl_module.rb
93
+ - lib/cookbooks/nginx/recipes/http_stub_status_module.rb
94
+ - lib/cookbooks/nginx/recipes/naxsi_module.rb
95
+ - lib/cookbooks/nginx/recipes/ohai_plugin.rb
96
+ - lib/cookbooks/nginx/recipes/passenger.rb
97
+ - lib/cookbooks/nginx/recipes/source.rb
98
+ - lib/cookbooks/nginx/recipes/upload_progress_module.rb
99
+ - lib/cookbooks/nginx/templates/debian/nginx.init.erb
100
+ - lib/cookbooks/nginx/templates/default/default-site.erb
101
+ - lib/cookbooks/nginx/templates/default/modules/authorized_ip.erb
102
+ - lib/cookbooks/nginx/templates/default/modules/http_geoip.conf.erb
103
+ - lib/cookbooks/nginx/templates/default/modules/http_realip.conf.erb
104
+ - lib/cookbooks/nginx/templates/default/modules/nginx_status.erb
105
+ - lib/cookbooks/nginx/templates/default/modules/passenger.conf.erb
106
+ - lib/cookbooks/nginx/templates/default/nginx.conf.erb
107
+ - lib/cookbooks/nginx/templates/default/nginx.init.erb
108
+ - lib/cookbooks/nginx/templates/default/nginx.pill.erb
109
+ - lib/cookbooks/nginx/templates/default/nginx.sysconfig.erb
110
+ - lib/cookbooks/nginx/templates/default/nxdissite.erb
111
+ - lib/cookbooks/nginx/templates/default/nxensite.erb
112
+ - lib/cookbooks/nginx/templates/default/plugins/nginx.rb.erb
113
+ - lib/cookbooks/nginx/templates/default/sv-nginx-log-run.erb
114
+ - lib/cookbooks/nginx/templates/default/sv-nginx-run.erb
115
+ - lib/cookbooks/nginx/templates/ubuntu/nginx.init.erb
116
+ - lib/cookbooks/nginx/test/kitchen/Kitchenfile
117
+ - lib/cookbooks/sanitize/.gitignore
118
+ - lib/cookbooks/sanitize/CHANGELOG.md
119
+ - lib/cookbooks/sanitize/README.md
120
+ - lib/cookbooks/sanitize/attributes/default.rb
121
+ - lib/cookbooks/sanitize/libraries/default.rb
122
+ - lib/cookbooks/sanitize/metadata.rb
123
+ - lib/cookbooks/sanitize/recipes/default.rb
124
+ - lib/cookbooks/sanitize/templates/default/port_ssh.erb
125
+ homepage: http://github.com/fdoebbelin/server_maint
126
+ licenses: []
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ segments:
138
+ - 0
139
+ hash: 3315387883945095376
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ segments:
147
+ - 0
148
+ hash: 3315387883945095376
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 1.8.23
152
+ signing_key:
153
+ specification_version: 3
154
+ summary: Host usefull chef cookbooks for server maintenance
155
+ test_files: []