deprec 2.1.8 → 2.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,19 @@
1
1
  # deprec changelog
2
2
 
3
+ = 2.1.10 (Sep 4, 2010)
4
+
5
+ * Get all user input at start (deprec:users:add)
6
+
7
+ = 2.1.9 (Sep 4, 2010)
8
+
9
+ * Added syslog-ng
10
+ * Added stunnel
11
+ * Added external config options for deprec:users:add
12
+ * Added config variables to sshd_config template
13
+ * Added recipe to push out file with bash options I want everywhere
14
+ * deprec:users:add looks harder for your public ssh keys
15
+ * current_user now contains the output from `whois`
16
+
3
17
  = 2.1.8 (Aug 26, 2010)
4
18
 
5
19
  * nagios-3.2.1
@@ -0,0 +1,28 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :bash do
5
+
6
+ SYSTEM_CONFIG_FILES[:bash] = [
7
+
8
+ {:template => "bash_global",
9
+ :path => '.bash_global',
10
+ :mode => 0644,
11
+ :owner => 'root:root'}
12
+ ]
13
+
14
+ task :config_gen do
15
+ SYSTEM_CONFIG_FILES[:bash].each do |file|
16
+ deprec2.render_template(:bash, file)
17
+ end
18
+ end
19
+
20
+ desc "Push bash config files to server"
21
+ task :config do
22
+ deprec2.push_configs(:bash, SYSTEM_CONFIG_FILES[:bash].collect{|file| file.merge(:owner => user)})
23
+ deprec2.append_to_file_if_missing('.bashrc', '. ~/.bash_global')
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -105,6 +105,10 @@ Capistrano::Configuration.instance(:must_exist).load do
105
105
  # XXX for some reason this is causing "before deprec:rails:install" to be executed twice
106
106
  on :load, 'deprec:connect_canonical_tasks'
107
107
 
108
+ # It can be useful to know the user running this command
109
+ # even when USER is set to someone else. Sorry windows!
110
+ set :current_user, `whoami`.chomp
111
+
108
112
  namespace :deprec do
109
113
 
110
114
  task :connect_canonical_tasks do
@@ -94,9 +94,10 @@ Capistrano::Configuration.instance(:must_exist).load do
94
94
  desc "Generate and push #{details[:path]}"
95
95
  task file.to_sym do
96
96
  deprec2.render_template(:network, details)
97
+ run "#{sudo} hostname #{network_hostname}" if file == :hostname
97
98
  end
98
99
  end
99
-
100
+
100
101
  # XXX need to set the order for these as it breaks sudo currently
101
102
  desc "Update system networking configuration"
102
103
  task :config do
@@ -2,6 +2,10 @@
2
2
  Capistrano::Configuration.instance(:must_exist).load do
3
3
  namespace :deprec do
4
4
  namespace :ssh do
5
+
6
+ set :ssh_permit_root_login, 'no'
7
+ set :ssh_use_pam, 'no'
8
+ set :ssh_use_dns, 'no'
5
9
 
6
10
  SYSTEM_CONFIG_FILES[:ssh] = [
7
11
 
@@ -55,32 +59,23 @@ Capistrano::Configuration.instance(:must_exist).load do
55
59
 
56
60
  desc "Sets up authorized_keys file on remote server"
57
61
  task :setup_keys do
58
-
59
62
  default(:target_user) {
60
63
  Capistrano::CLI.ui.ask "Setup keys for which user?" do |q|
61
- q.default = user
64
+ q.default = current_user
62
65
  end
63
66
  }
64
67
 
65
68
  # If we have an authorized keys file for this user
66
69
  # then copy that out
67
70
  if File.exists?("config/ssh/authorized_keys/#{target_user}")
68
- deprec2.mkdir "/home/#{target_user}/.ssh", :mode => 0700, :owner => "#{target_user}.users", :via => :sudo
69
- std.su_put File.read("config/ssh/authorized_keys/#{target_user}"), "/home/#{target_user}/.ssh/authorized_keys", '/tmp/', :mode => 0600
70
- sudo "chown #{target_user}.users /home/#{target_user}/.ssh/authorized_keys"
71
-
72
- elsif target_user == user
73
-
71
+ keys = File.read("config/ssh/authorized_keys/#{target_user}")
72
+ elsif target_user == current_user
74
73
  # If the user has specified a key Capistrano should use
75
74
  if ssh_options[:keys]
76
- deprec2.mkdir '.ssh', :mode => 0700
77
- put(ssh_options[:keys].collect{|key| File.read("#{key}.pub")}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
78
-
75
+ keys = ssh_options[:keys].collect{|key| File.read("#{key}.pub")}.join("\n")
79
76
  # Try to find the current users public key
80
- elsif keys = %w[id_rsa id_dsa identity].collect { |f| "#{ENV['HOME']}/.ssh/#{f}.pub" if File.exists?("#{ENV['HOME']}/.ssh/#{f}.pub") }.compact
81
- deprec2.mkdir '.ssh', :mode => 0700
82
- put(keys.collect{|key| File.read(key)}.join("\n"), '.ssh/authorized_keys', :mode => 0600 )
83
-
77
+ elsif key_files = %w[id_rsa id_dsa identity].collect { |f| "#{ENV['HOME']}/.ssh/#{f}.pub" if File.exists?("#{ENV['HOME']}/.ssh/#{f}.pub") }.compact
78
+ keys = key_files.collect{|key| File.read(key)}.join("\n")
84
79
  else
85
80
  puts <<-ERROR
86
81
 
@@ -95,17 +90,22 @@ Capistrano::Configuration.instance(:must_exist).load do
95
90
  else
96
91
  puts <<-ERROR
97
92
 
98
- Could not find ssh public key(s) for user #{user}
99
-
93
+ Could not find ssh public key(s) for user #{target_user}
94
+
100
95
  Please create file containing ssh public keys in:
101
96
 
102
- config/ssh/authorized_keys/#{target_user}
97
+ config/ssh/authorized_keys/#{target_user}
103
98
 
104
99
  ERROR
100
+ exit
105
101
  end
106
102
 
103
+ # copy keys to remote server
104
+ deprec2.mkdir "/home/#{target_user}/.ssh", :mode => 0700, :owner => "#{target_user}.users", :via => :sudo
105
+ std.su_put keys, "/home/#{target_user}/.ssh/authorized_keys", '/tmp/', :mode => 0600
106
+ sudo "chown #{target_user}.users /home/#{target_user}/.ssh/authorized_keys"
107
107
  end
108
-
108
+
109
109
  end
110
110
  end
111
- end
111
+ end
@@ -0,0 +1,50 @@
1
+ # Copyright 2006-2010 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :stunnel do
5
+
6
+ desc "Install stunnel"
7
+ task :install do
8
+ install_deps
9
+ config
10
+ end
11
+
12
+ task :install_deps do
13
+ apt.install( {:base => %w(stunnel ssl-cert)}, :stable )
14
+ end
15
+
16
+ SYSTEM_CONFIG_FILES[:stunnel] = [
17
+
18
+ {:template => 'stunnel.conf-client',
19
+ :path => '/etc/stunnel/stunnel.conf',
20
+ :mode => 0644,
21
+ :owner => 'root:root'},
22
+
23
+ {:template => 'stunnel4',
24
+ :path => '/etc/defaults/stunnel4',
25
+ :mode => 0644,
26
+ :owner => 'root:root'}
27
+
28
+ ]
29
+
30
+ task :config_gen do
31
+ SYSTEM_CONFIG_FILES[:stunnel].each do |file|
32
+ deprec2.render_template(:stunnel, file)
33
+ end
34
+ end
35
+
36
+ desc "Push stunnel config files to server"
37
+ task :config do
38
+ deprec2.push_configs(:stunnel, SYSTEM_CONFIG_FILES[:stunnel])
39
+ restart
40
+ end
41
+
42
+ desc "Restart stunnel"
43
+ task :restart do
44
+ run "#{sudo} /etc/init.d/stunnel4 reload"
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,53 @@
1
+ # Copyright 2006-2010 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :syslog_ng do
5
+
6
+ set(:syslog_ng_loghost_name) {
7
+ Capistrano::CLI.ui.ask "Loghost address" do |q|
8
+ q.default = ''
9
+ end
10
+ }
11
+ set :syslog_ng_loghost_port, 514
12
+
13
+ desc "Install syslog-ng"
14
+ task :install do
15
+ syslog_ng_loghost_name
16
+ install_deps
17
+ config
18
+ end
19
+
20
+ task :install_deps do
21
+ apt.install( {:base => %w(syslog-ng)}, :stable )
22
+ end
23
+
24
+ SYSTEM_CONFIG_FILES[:syslog_ng] = [
25
+
26
+ {:template => 'syslog-ng.conf-client',
27
+ :path => '/etc/syslog-ng/syslog-ng.conf',
28
+ :mode => 0644,
29
+ :owner => 'root:root'}
30
+
31
+ ]
32
+
33
+ task :config_gen do
34
+ SYSTEM_CONFIG_FILES[:syslog_ng].each do |file|
35
+ deprec2.render_template(:syslog_ng, file)
36
+ end
37
+ end
38
+
39
+ desc "Push ssh config files to server"
40
+ task :config do
41
+ deprec2.push_configs(:syslog_ng, SYSTEM_CONFIG_FILES[:syslog_ng])
42
+ restart
43
+ end
44
+
45
+ desc "Restart syslog-ng"
46
+ task :restart do
47
+ run "#{sudo} /etc/init.d/syslog-ng restart"
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
@@ -2,89 +2,60 @@
2
2
  Capistrano::Configuration.instance(:must_exist).load do
3
3
  namespace :deprec do
4
4
  namespace :users do
5
-
6
- # desc "Create user account"
7
- # task :add do
8
- # target_user = Capistrano::CLI.ui.ask "Enter userid for new user" do |q|
9
- # q.default = user
10
- # end
11
- # deprec2.useradd(target_user, :shell => '/bin/bash')
12
- # puts "Setting password for new account"
13
- # deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/)
14
- # end
5
+
6
+ set(:users_target_user) { Capistrano::CLI.ui.ask "Enter userid for new user" do |q| q.default = current_user; end }
7
+ set(:users_target_group) { Capistrano::CLI.ui.ask "Enter group name for new user" do |q| q.default = 'deploy'; end }
8
+ set(:users_make_admin) { Capistrano::CLI.ui.ask "Should this be an admin account?" do |q| q.default = 'no'; end }
15
9
 
16
10
  desc "Create account"
17
11
  task :add do
18
- target_user = Capistrano::CLI.ui.ask "Enter userid for new user" do |q|
19
- q.default = user
20
- end
21
- make_admin = Capistrano::CLI.ui.ask "Should this be an admin account?" do |q|
22
- q.default = 'no'
23
- end
24
- copy_keys = false
25
- if File.readable?("config/ssh/authorized_keys/#{target_user}")
26
- copy_keys = Capistrano::CLI.ui.ask "I've found an authorized_keys file for #{target_user}. Should I copy it out?" do |q|
27
- q.default = 'yes'
28
- end
29
- end
12
+ [users_target_user, users_target_group, users_make_admin] # get input
30
13
 
31
- new_password = Capistrano::CLI.ui.ask("Enter new password for #{target_user}") { |q| q.echo = false }
14
+ while true do
15
+ new_password = Capistrano::CLI.ui.ask("Enter new password for #{users_target_user}") { |q| q.echo = false }
16
+ password_conf = Capistrano::CLI.ui.ask("Re-enter new password for #{users_target_user}") { |q| q.echo = false }
17
+ if new_password != password_conf
18
+ puts "Fail. Passwords do not match.\n\n"
19
+ elsif new_password.chomp == ""
20
+ puts "Fail. Passwords cannot be empty.\n\n"
21
+ else
22
+ break
23
+ end
24
+ end
32
25
 
33
- deprec2.useradd(target_user, :shell => '/bin/bash')
26
+ deprec2.useradd(users_target_user, :shell => '/bin/bash')
34
27
 
35
- deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/, new_password)
28
+ deprec2.invoke_with_input("passwd #{users_target_user}", /UNIX password/, new_password)
36
29
 
37
- if make_admin.match(/y/i)
30
+ if users_make_admin.match(/y/i)
38
31
  deprec2.groupadd('admin')
39
- deprec2.add_user_to_group(target_user, 'admin')
32
+ deprec2.add_user_to_group(users_target_user, 'admin')
40
33
  deprec2.append_to_file_if_missing('/etc/sudoers', '%admin ALL=(ALL) ALL')
41
34
  end
42
35
 
43
- if copy_keys && copy_keys.grep(/y/i)
44
- set :target_user, target_user
45
- top.deprec.ssh.setup_keys
46
- end
36
+ set :target_user, users_target_user
37
+ top.deprec.ssh.setup_keys
47
38
 
48
39
  end
49
-
50
- desc "Create account"
51
- task :add_admin do
52
- puts 'deprecated! use deprec:users:add'
53
- add
54
- end
55
40
 
56
41
  desc "Change user password"
57
42
  task :passwd do
58
- target_user = Capistrano::CLI.ui.ask "Enter user to change password for" do |q|
59
- q.default = user if user.is_a?(String)
60
- end
61
- new_password = Capistrano::CLI.ui.ask("Enter new password for #{target_user}") { |q| q.echo = false }
43
+ new_password = Capistrano::CLI.ui.ask("Enter new password for #{users_target_user}") { |q| q.echo = false }
62
44
 
63
- deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/, new_password)
45
+ deprec2.invoke_with_input("passwd #{users_target_user}", /UNIX password/, new_password)
64
46
  end
65
47
 
66
48
  desc "Add user to group"
67
49
  task :add_user_to_group do
68
- target_user = Capistrano::CLI.ui.ask "Which user?" do |q|
69
- q.default = user if user.is_a?(String)
70
- end
71
- target_group = Capistrano::CLI.ui.ask "Add to which group?" do |q|
72
- q.default = 'deploy'
73
- end
74
- deprec2.add_user_to_group(target_user, target_group)
50
+ deprec2.add_user_to_group(users_target_user, users_target_group)
75
51
  end
76
52
 
77
- # desc "Create group"
78
- # task :add_group do
79
- # target_group = Capistrano::CLI.ui.ask "Enter name for new group"
80
- # deprec2.groupadd(target_group)
81
- # end
82
- #
83
- # desc "Add user to group"
84
- # task :add_user_to_group do
85
- # # XXX not yet implemented
86
- # end
53
+ desc "Create account"
54
+ task :add_admin do
55
+ puts 'deprecated! use deprec:users:add'
56
+ add
57
+ end
87
58
 
88
59
  end
89
60
  end
90
- end
61
+ end
@@ -19,6 +19,7 @@ require "#{File.dirname(__FILE__)}/recipes/ruby/ree"
19
19
  require "#{File.dirname(__FILE__)}/recipes/web/apache"
20
20
  require "#{File.dirname(__FILE__)}/recipes/web/nginx"
21
21
 
22
+ require "#{File.dirname(__FILE__)}/recipes/bash"
22
23
  require "#{File.dirname(__FILE__)}/recipes/git"
23
24
  # require "#{File.dirname(__FILE__)}/recipes/gitosis"
24
25
  require "#{File.dirname(__FILE__)}/recipes/svn"
@@ -46,6 +47,8 @@ require "#{File.dirname(__FILE__)}/recipes/network"
46
47
  require "#{File.dirname(__FILE__)}/recipes/nagios"
47
48
  require "#{File.dirname(__FILE__)}/recipes/collectd"
48
49
  require "#{File.dirname(__FILE__)}/recipes/syslog"
50
+ require "#{File.dirname(__FILE__)}/recipes/syslog_ng"
51
+ require "#{File.dirname(__FILE__)}/recipes/stunnel"
49
52
  require "#{File.dirname(__FILE__)}/recipes/heartbeat"
50
53
  require "#{File.dirname(__FILE__)}/recipes/haproxy"
51
54
 
@@ -0,0 +1,36 @@
1
+ ###########
2
+ # Functions
3
+ ###########
4
+ # Delete an entry from ~/.ssh/known_hosts
5
+ # Usage: sshdel <line_number>
6
+ function sshdel { perl -i -n -e "print unless (\$. == $1)" ~/.ssh/known_hosts; }
7
+
8
+ #########
9
+ # Aliases
10
+ #########
11
+
12
+ # Show disk usage in current directory
13
+ alias dus='du -sm * | sort -n'
14
+
15
+ # ls
16
+ alias ll='ls -alF'
17
+ alias la='ls -A'
18
+ alias l='ls -CF'
19
+
20
+ # Git aliases for bash
21
+ alias gst='git status'
22
+ alias gl='git pull'
23
+ alias gp='git push'
24
+ alias gd='git diff | mate'
25
+ alias gc='git commit -v'
26
+ alias gca='git commit -v -a'
27
+ alias gb='git branch'
28
+ alias gba='git branch -a'
29
+ alias rr='xargs ps -p < '
30
+ alias gcp='git cherry-pick'
31
+
32
+ # Time http request
33
+ alias tc='time curl -s -o /dev/null'
34
+
35
+ # Load rubygems
36
+ alias irb='irb -rubygems'
@@ -23,7 +23,7 @@ LogLevel INFO
23
23
 
24
24
  # Authentication:
25
25
  LoginGraceTime 120
26
- PermitRootLogin no
26
+ PermitRootLogin <%= ssh_permit_root_login %>
27
27
  StrictModes yes
28
28
 
29
29
  RSAAuthentication yes
@@ -74,5 +74,5 @@ AcceptEnv LANG LC_*
74
74
 
75
75
  Subsystem sftp /usr/lib/openssh/sftp-server
76
76
 
77
- UsePAM no
78
- UseDNS no
77
+ UsePAM <%= ssh_use_pam %>
78
+ UseDNS <%= ssh_use_dns %>