capistrano-atlas 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +215 -0
- data/Rakefile +5 -0
- data/capistrano-atlas.gemspec +32 -0
- data/lib/capistrano/atlas.rb +27 -0
- data/lib/capistrano/atlas/compatibility.rb +37 -0
- data/lib/capistrano/atlas/dsl.rb +157 -0
- data/lib/capistrano/atlas/recipe.rb +49 -0
- data/lib/capistrano/atlas/templates/crontab.erb +1 -0
- data/lib/capistrano/atlas/templates/csr_config.erb +10 -0
- data/lib/capistrano/atlas/templates/logrotate.erb +9 -0
- data/lib/capistrano/atlas/templates/maintenance.html.erb +26 -0
- data/lib/capistrano/atlas/templates/nginx.erb +64 -0
- data/lib/capistrano/atlas/templates/nginx_site.erb +97 -0
- data/lib/capistrano/atlas/templates/pgpass.erb +1 -0
- data/lib/capistrano/atlas/templates/postgresql-backup-logrotate.erb +11 -0
- data/lib/capistrano/atlas/templates/puma.rb.erb +22 -0
- data/lib/capistrano/atlas/templates/puma_init.erb +43 -0
- data/lib/capistrano/atlas/templates/rbenv_bashrc +4 -0
- data/lib/capistrano/atlas/templates/sidekiq_init.erb +100 -0
- data/lib/capistrano/atlas/templates/ssl_setup +43 -0
- data/lib/capistrano/atlas/templates/version.rb.erb +3 -0
- data/lib/capistrano/atlas/version.rb +5 -0
- data/lib/capistrano/tasks/aptitude.rake +111 -0
- data/lib/capistrano/tasks/bundler.rake +31 -0
- data/lib/capistrano/tasks/crontab.rake +14 -0
- data/lib/capistrano/tasks/defaults.rake +137 -0
- data/lib/capistrano/tasks/dotenv.rake +57 -0
- data/lib/capistrano/tasks/logrotate.rake +16 -0
- data/lib/capistrano/tasks/maintenance.rake +28 -0
- data/lib/capistrano/tasks/migrate.rake +29 -0
- data/lib/capistrano/tasks/nginx.rake +25 -0
- data/lib/capistrano/tasks/postgresql.rake +149 -0
- data/lib/capistrano/tasks/provision.rake +18 -0
- data/lib/capistrano/tasks/puma.rake +67 -0
- data/lib/capistrano/tasks/rake.rake +20 -0
- data/lib/capistrano/tasks/rbenv.rake +104 -0
- data/lib/capistrano/tasks/seed.rake +16 -0
- data/lib/capistrano/tasks/sidekiq.rake +42 -0
- data/lib/capistrano/tasks/ssl.rake +57 -0
- data/lib/capistrano/tasks/ufw.rake +32 -0
- data/lib/capistrano/tasks/user.rake +32 -0
- data/lib/capistrano/tasks/version.rake +34 -0
- metadata +161 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
atlas_recipe :ssl do
|
2
|
+
during :provision, "generate_dh"
|
3
|
+
during :provision, "generate_self_signed_crt"
|
4
|
+
end
|
5
|
+
|
6
|
+
namespace :atlas do
|
7
|
+
namespace :ssl do
|
8
|
+
desc "Generate an SSL key and CSR for Ngnix HTTPS"
|
9
|
+
task :generate_csr do
|
10
|
+
_run_ssl_script
|
11
|
+
_copy_to_all_web_servers(%w(.key .csr))
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Generate an SSL key, CSR, and self-signed cert for Ngnix HTTPS"
|
15
|
+
task :generate_self_signed_crt do
|
16
|
+
_run_ssl_script("--self")
|
17
|
+
_copy_to_all_web_servers(%w(.key .csr .crt))
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate unique DH group"
|
21
|
+
task :generate_dh do
|
22
|
+
privileged_on roles(:web) do
|
23
|
+
unless test("sudo [ -f /etc/ssl/dhparams.pem ]")
|
24
|
+
execute :sudo, "openssl dhparam -out /etc/ssl/dhparams.pem 2048"
|
25
|
+
execute :sudo, "chmod 600 /etc/ssl/dhparams.pem"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def _run_ssl_script(opt="")
|
31
|
+
privileged_on primary(:web) do
|
32
|
+
files_exist = %w(.key .csr .crt).any? do |ext|
|
33
|
+
test("sudo [ -f /etc/ssl/#{application_basename}#{ext} ]")
|
34
|
+
end
|
35
|
+
|
36
|
+
if files_exist
|
37
|
+
info("Files exist; skipping SSL key generation.")
|
38
|
+
else
|
39
|
+
config = "/tmp/csr_config"
|
40
|
+
ssl_script = "/tmp/ssl_script"
|
41
|
+
|
42
|
+
template("csr_config.erb", config, :sudo => true)
|
43
|
+
template("ssl_setup", ssl_script, :mode => "+x", :sudo => true)
|
44
|
+
|
45
|
+
within "/etc/ssl" do
|
46
|
+
execute :sudo, ssl_script, opt, application_basename, config
|
47
|
+
execute :sudo, "rm", ssl_script, config
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def _copy_to_all_web_servers(extensions)
|
54
|
+
# TODO
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
atlas_recipe :ufw do
|
2
|
+
during :provision, "configure"
|
3
|
+
end
|
4
|
+
|
5
|
+
namespace :atlas do
|
6
|
+
namespace :ufw do
|
7
|
+
desc "Configure role-based ufw rules on each server"
|
8
|
+
task :configure do
|
9
|
+
rules = fetch(:atlas_ufw_rules, {})
|
10
|
+
distinct_roles = rules.values.flatten.uniq
|
11
|
+
|
12
|
+
# First reset the firewall on all affected servers
|
13
|
+
privileged_on roles(*distinct_roles) do
|
14
|
+
execute "sudo ufw --force reset"
|
15
|
+
execute "sudo ufw default deny incoming"
|
16
|
+
execute "sudo ufw default allow outgoing"
|
17
|
+
end
|
18
|
+
|
19
|
+
# Then set up all ufw rules according to the atlas_ufw_rules hash
|
20
|
+
rules.each do |command, *role_names|
|
21
|
+
privileged_on roles(*role_names.flatten) do
|
22
|
+
execute "sudo ufw #{command}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Finally, enable the firewall on all affected servers
|
27
|
+
privileged_on roles(*distinct_roles) do
|
28
|
+
execute "sudo ufw --force enable"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
atlas_recipe :user do
|
2
|
+
during :provision, %w(add install_public_key)
|
3
|
+
end
|
4
|
+
|
5
|
+
namespace :atlas do
|
6
|
+
namespace :user do
|
7
|
+
desc "Create the UNIX user if it doesn't already exist"
|
8
|
+
task :add do
|
9
|
+
privileged_on roles(:all) do |host, user|
|
10
|
+
unless test("sudo grep -q #{user}: /etc/passwd")
|
11
|
+
execute :sudo, "adduser", "--disabled-password", user, "</dev/null"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copy root's authorized_keys to the user account if it doesn't "\
|
17
|
+
"already have its own keys"
|
18
|
+
task :install_public_key do
|
19
|
+
root = fetch(:atlas_privileged_user)
|
20
|
+
|
21
|
+
privileged_on roles(:all) do |host, user|
|
22
|
+
unless test("sudo [ -f /home/#{user}/.ssh/authorized_keys ]")
|
23
|
+
execute :sudo, "mkdir", "-p", "/home/#{user}/.ssh"
|
24
|
+
execute :sudo, "cp", "~#{root}/.ssh/authorized_keys",
|
25
|
+
"/home/#{user}/.ssh"
|
26
|
+
execute :sudo, "chown", "-R", "#{user}:#{user}", "/home/#{user}/.ssh"
|
27
|
+
execute :sudo, "chmod", "600", "/home/#{user}/.ssh/authorized_keys"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
atlas_recipe :version do
|
2
|
+
during "deploy:updating", "write_initializer"
|
3
|
+
end
|
4
|
+
|
5
|
+
namespace :atlas do
|
6
|
+
namespace :version do
|
7
|
+
desc "Write initializers/version.rb with git version and date information"
|
8
|
+
task :write_initializer do
|
9
|
+
git_version = {}
|
10
|
+
branch = fetch(:branch)
|
11
|
+
|
12
|
+
on release_roles(:all).first do
|
13
|
+
with fetch(:git_environmental_variables) do
|
14
|
+
within repo_path do
|
15
|
+
git_version[:tag] = \
|
16
|
+
capture(:git, "describe", branch, "--always --tag").chomp
|
17
|
+
git_version[:date] = \
|
18
|
+
capture(:git, "log", branch, '-1 --format="%ad" --date=short')\
|
19
|
+
.chomp
|
20
|
+
git_version[:time] = \
|
21
|
+
capture(:git, "log", branch, '-1 --format="%ad" --date=iso')\
|
22
|
+
.chomp
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
on release_roles(:all) do
|
28
|
+
template "version.rb.erb",
|
29
|
+
"#{release_path}/config/initializers/version.rb",
|
30
|
+
:binding => binding
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-atlas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John McDowall
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sshkit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.6.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.6.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: chandler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: 'Does all the heavy lifting for production-ready provisioning and deployment
|
84
|
+
for the full Rails 5.1 stack. Installs and configures Ruby, Nginx, Puma, PostgreSQL,
|
85
|
+
dotenv, Let''s Encrypt and more onto Ubuntu 14.04 LTS using Capistrano. '
|
86
|
+
email: john@kantan.io
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- CHANGELOG.md
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- capistrano-atlas.gemspec
|
98
|
+
- lib/capistrano/atlas.rb
|
99
|
+
- lib/capistrano/atlas/compatibility.rb
|
100
|
+
- lib/capistrano/atlas/dsl.rb
|
101
|
+
- lib/capistrano/atlas/recipe.rb
|
102
|
+
- lib/capistrano/atlas/templates/crontab.erb
|
103
|
+
- lib/capistrano/atlas/templates/csr_config.erb
|
104
|
+
- lib/capistrano/atlas/templates/logrotate.erb
|
105
|
+
- lib/capistrano/atlas/templates/maintenance.html.erb
|
106
|
+
- lib/capistrano/atlas/templates/nginx.erb
|
107
|
+
- lib/capistrano/atlas/templates/nginx_site.erb
|
108
|
+
- lib/capistrano/atlas/templates/pgpass.erb
|
109
|
+
- lib/capistrano/atlas/templates/postgresql-backup-logrotate.erb
|
110
|
+
- lib/capistrano/atlas/templates/puma.rb.erb
|
111
|
+
- lib/capistrano/atlas/templates/puma_init.erb
|
112
|
+
- lib/capistrano/atlas/templates/rbenv_bashrc
|
113
|
+
- lib/capistrano/atlas/templates/sidekiq_init.erb
|
114
|
+
- lib/capistrano/atlas/templates/ssl_setup
|
115
|
+
- lib/capistrano/atlas/templates/version.rb.erb
|
116
|
+
- lib/capistrano/atlas/version.rb
|
117
|
+
- lib/capistrano/tasks/aptitude.rake
|
118
|
+
- lib/capistrano/tasks/bundler.rake
|
119
|
+
- lib/capistrano/tasks/crontab.rake
|
120
|
+
- lib/capistrano/tasks/defaults.rake
|
121
|
+
- lib/capistrano/tasks/dotenv.rake
|
122
|
+
- lib/capistrano/tasks/logrotate.rake
|
123
|
+
- lib/capistrano/tasks/maintenance.rake
|
124
|
+
- lib/capistrano/tasks/migrate.rake
|
125
|
+
- lib/capistrano/tasks/nginx.rake
|
126
|
+
- lib/capistrano/tasks/postgresql.rake
|
127
|
+
- lib/capistrano/tasks/provision.rake
|
128
|
+
- lib/capistrano/tasks/puma.rake
|
129
|
+
- lib/capistrano/tasks/rake.rake
|
130
|
+
- lib/capistrano/tasks/rbenv.rake
|
131
|
+
- lib/capistrano/tasks/seed.rake
|
132
|
+
- lib/capistrano/tasks/sidekiq.rake
|
133
|
+
- lib/capistrano/tasks/ssl.rake
|
134
|
+
- lib/capistrano/tasks/ufw.rake
|
135
|
+
- lib/capistrano/tasks/user.rake
|
136
|
+
- lib/capistrano/tasks/version.rake
|
137
|
+
homepage: https://github.com/johnmcdowall/capistrano-atlas
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.6.13
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Additional Capistrano 3 recipes
|
161
|
+
test_files: []
|