orats 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/README.md +55 -80
- data/lib/orats/cli.rb +11 -11
- data/lib/orats/command.rb +20 -10
- data/lib/orats/shell.rb +91 -22
- data/lib/orats/templates/auth.rb +2 -2
- data/lib/orats/templates/base.rb +31 -12
- data/lib/orats/templates/includes/Gemfile +21 -20
- data/lib/orats/templates/includes/inventory/group_vars/all.yml +95 -0
- data/lib/orats/templates/includes/inventory/hosts +8 -0
- data/lib/orats/templates/includes/secrets/sslcert.crt +21 -0
- data/lib/orats/templates/includes/secrets/sslkey.key +28 -0
- data/lib/orats/templates/play.rb +172 -0
- data/lib/orats/version.rb +1 -1
- data/orats.gemspec +1 -1
- data/test/integration/cli_test.rb +12 -26
- metadata +10 -6
- data/lib/orats/templates/cook.rb +0 -632
data/lib/orats/templates/auth.rb
CHANGED
@@ -38,9 +38,9 @@ puts '-'*80, ''; sleep 0.25
|
|
38
38
|
|
39
39
|
inject_into_file 'Gemfile', before: "\ngem 'kaminari'" do <<-CODE
|
40
40
|
|
41
|
-
gem 'devise', '~> 3.2.
|
41
|
+
gem 'devise', '~> 3.2.4'
|
42
42
|
gem 'devise-async', '~> 0.9.0'
|
43
|
-
gem 'pundit', '~> 0.2.
|
43
|
+
gem 'pundit', '~> 0.2.3'
|
44
44
|
CODE
|
45
45
|
end
|
46
46
|
|
data/lib/orats/templates/base.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# =====================================================================================================
|
2
|
-
# Template for generating an opinionated base Rails 4.0
|
2
|
+
# Template for generating an opinionated base Rails 4.1.0 project using Ruby 2.1.0
|
3
3
|
# =====================================================================================================
|
4
4
|
|
5
5
|
# ----- Helper functions and variables ----------------------------------------------------------------
|
@@ -54,6 +54,10 @@ append_to_file '.gitignore' do <<-TEXT
|
|
54
54
|
|
55
55
|
# Ignore the main environment file.
|
56
56
|
.env
|
57
|
+
|
58
|
+
# Ignore app specific folders.
|
59
|
+
/vendor/bundle
|
60
|
+
/public/assets/*
|
57
61
|
TEXT
|
58
62
|
end
|
59
63
|
|
@@ -66,7 +70,7 @@ puts
|
|
66
70
|
say_status 'root', 'Creating root files...', :yellow
|
67
71
|
puts '-'*80, ''; sleep 0.25
|
68
72
|
|
69
|
-
file '.ruby-version', '2.1.
|
73
|
+
file '.ruby-version', '2.1.1'
|
70
74
|
|
71
75
|
git add: '.'
|
72
76
|
git commit: "-m 'Add .ruby-version file for common ruby version managers'"
|
@@ -87,6 +91,10 @@ say_status 'root', 'Creating .env file...', :yellow
|
|
87
91
|
puts '-'*80, ''; sleep 0.25
|
88
92
|
|
89
93
|
file '.env' do <<-CODE
|
94
|
+
RAILS_ENV: development
|
95
|
+
|
96
|
+
#{app_name_upper}_PROJECT_PATH: /full/path/to/your/project
|
97
|
+
|
90
98
|
#{app_name_upper}_TOKEN_RAILS_SECRET: #{generate_token}
|
91
99
|
|
92
100
|
#{app_name_upper}_SMTP_ADDRESS: smtp.gmail.com
|
@@ -110,6 +118,7 @@ file '.env' do <<-CODE
|
|
110
118
|
#{app_name_upper}_CACHE_HOST: localhost
|
111
119
|
#{app_name_upper}_CACHE_PORT: 6379
|
112
120
|
#{app_name_upper}_CACHE_DATABASE: 0
|
121
|
+
#{app_name_upper}_CACHE_PASSWORD: greatsecurity
|
113
122
|
|
114
123
|
#{app_name_upper}_PUMA_THREADS_MIN: 0
|
115
124
|
#{app_name_upper}_PUMA_THREADS_MAX: 1
|
@@ -119,10 +128,12 @@ file '.env' do <<-CODE
|
|
119
128
|
CODE
|
120
129
|
end
|
121
130
|
|
122
|
-
# ----- Modify the
|
131
|
+
# ----- Modify the secrets yaml file -----------------------------------------------------------------------
|
123
132
|
|
124
|
-
|
133
|
+
env_rails_secret_token = "<%= ENV['#{app_name_upper}_TOKEN_RAILS_SECRET'] %>"
|
125
134
|
|
135
|
+
gsub_file 'config/secrets.yml', /\w{128}/, env_rails_secret_token
|
136
|
+
gsub_file 'config/secrets.yml', '<%= ENV["SECRET_KEY_BASE"] %>', env_rails_secret_token
|
126
137
|
|
127
138
|
# ----- Modify the application file -------------------------------------------------------------------
|
128
139
|
|
@@ -142,7 +153,7 @@ inject_into_file 'config/application.rb', after: "automatically loaded.\n" do <<
|
|
142
153
|
:domain => ENV['#{app_name_upper}_SMTP_DOMAIN'],
|
143
154
|
:user_name => ENV['#{app_name_upper}_SMTP_USERNAME'],
|
144
155
|
:password => ENV['#{app_name_upper}_SMTP_PASSWORD'],
|
145
|
-
:authentication => ENV['#{app_name_upper}_SMTP_AUTH']
|
156
|
+
:authentication => ENV['#{app_name_upper}_SMTP_AUTH'],
|
146
157
|
:enable_starttls_auto => ENV['#{app_name_upper}_SMTP_STARTTTLS_AUTO'] == 'true'
|
147
158
|
}
|
148
159
|
|
@@ -151,6 +162,7 @@ inject_into_file 'config/application.rb', after: "automatically loaded.\n" do <<
|
|
151
162
|
config.cache_store = :redis_store, { host: ENV['#{app_name_upper}_CACHE_HOST'],
|
152
163
|
port: ENV['#{app_name_upper}_CACHE_PORT'].to_i,
|
153
164
|
db: ENV['#{app_name_upper}_CACHE_DATABASE'].to_i,
|
165
|
+
password: ENV['#{app_name_upper}_CACHE_PASSWORD'],
|
154
166
|
namespace: '#{app_name}::cache'
|
155
167
|
}
|
156
168
|
CODE
|
@@ -206,19 +218,24 @@ end
|
|
206
218
|
git add: '.'
|
207
219
|
git commit: "-m 'Dry up the database settings'"
|
208
220
|
|
209
|
-
file 'config/puma.rb', <<-CODE
|
210
|
-
|
211
|
-
workers ENV['#{app_name_upper}_PUMA_WORKERS'].to_i
|
221
|
+
file 'config/puma.rb', <<-'CODE'
|
222
|
+
environment ENV['RAILS_ENV']
|
212
223
|
|
213
|
-
|
224
|
+
threads ENV['app_name_upper_PUMA_THREADS_MIN'].to_i,ENV['app_name_upper_PUMA_THREADS_MAX'].to_i
|
225
|
+
workers ENV['app_name_upper_PUMA_WORKERS'].to_i
|
226
|
+
|
227
|
+
pidfile "#{ENV['app_name_upper_PROJECT_PATH']}/tmp/puma.pid"
|
214
228
|
|
215
229
|
if ENV['RAILS_ENV'] == 'production'
|
216
|
-
bind '
|
230
|
+
bind "unix://#{ENV['app_name_upper_PROJECT_PATH']}/tmp/puma.sock"
|
217
231
|
else
|
218
232
|
port '3000'
|
219
233
|
end
|
220
234
|
|
221
|
-
|
235
|
+
# https://github.com/puma/puma/blob/master/examples/config.rb#L125
|
236
|
+
prune_bundler
|
237
|
+
|
238
|
+
restart_command 'bundle exec bin/puma'
|
222
239
|
|
223
240
|
on_worker_boot do
|
224
241
|
require 'active_record'
|
@@ -229,12 +246,14 @@ on_worker_boot do
|
|
229
246
|
end
|
230
247
|
CODE
|
231
248
|
|
249
|
+
gsub_file 'config/puma.rb', 'app_name_upper', app_name_upper
|
250
|
+
|
232
251
|
git add: '.'
|
233
252
|
git commit: "-m 'Add the puma config'"
|
234
253
|
|
235
254
|
file 'config/sidekiq.yml', <<-CODE
|
236
255
|
---
|
237
|
-
:pidfile:
|
256
|
+
:pidfile: <%= ENV['#{app_name_upper}_PROJECT_PATH'] %>/tmp/sidekiq.pid
|
238
257
|
:concurrency: <%= ENV['#{app_name_upper}_SIDEKIQ_CONCURRENCY'].to_i %>
|
239
258
|
:queues:
|
240
259
|
- default
|
@@ -1,44 +1,45 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'rails', '4.
|
4
|
-
gem 'turbolinks', '~>
|
5
|
-
gem 'jquery-rails', '~> 3.0
|
6
|
-
gem 'jquery-turbolinks', '~> 2.0.
|
7
|
-
gem 'bootstrap-sass', '~> 3.
|
8
|
-
gem 'font-awesome-rails', '~> 4.0.3
|
3
|
+
gem 'rails', '~> 4.1.1'
|
4
|
+
gem 'turbolinks', '~> 2.2.2'
|
5
|
+
gem 'jquery-rails', '~> 3.1.0'
|
6
|
+
gem 'jquery-turbolinks', '~> 2.0.2'
|
7
|
+
gem 'bootstrap-sass', '~> 3.1.1'
|
8
|
+
gem 'font-awesome-rails', '~> 4.0.3'
|
9
9
|
|
10
|
-
gem 'custom_configuration'
|
10
|
+
gem 'custom_configuration', '~> 0.0.2'
|
11
11
|
|
12
|
-
gem 'pg'
|
12
|
+
gem 'pg', '~> 0.17.1'
|
13
13
|
gem 'redis-rails', '~> 4.0.0'
|
14
14
|
|
15
|
-
gem 'puma', '~> 2.
|
16
|
-
gem 'sidekiq', '~>
|
17
|
-
gem 'sinatra', '>= 1.
|
18
|
-
gem 'whenever', require: false
|
15
|
+
gem 'puma', '~> 2.8.2'
|
16
|
+
gem 'sidekiq', '~> 3.0.0'
|
17
|
+
gem 'sinatra', '>= 1.4.5', require: false
|
18
|
+
gem 'whenever', '~> 0.9.2', require: false
|
19
19
|
#gem 'jbuilder'
|
20
20
|
|
21
21
|
gem 'kaminari', '~> 0.15.1'
|
22
22
|
|
23
|
-
gem 'sitemap_generator', '~>
|
24
|
-
gem 'favicon_maker', '~> 1.1.
|
23
|
+
gem 'sitemap_generator', '~> 5.0.2'
|
24
|
+
gem 'favicon_maker', '~> 1.1.2'
|
25
25
|
|
26
26
|
group :development do
|
27
|
-
gem '
|
28
|
-
gem '
|
29
|
-
gem '
|
30
|
-
gem '
|
27
|
+
gem 'spring', '~> 1.1.2'
|
28
|
+
gem 'foreman', require: false
|
29
|
+
gem 'rack-mini-profiler', '~> 0.9.1'
|
30
|
+
gem 'bullet', '~> 4.8.0'
|
31
|
+
gem 'meta_request', '~> 0.3.0'
|
31
32
|
gem 'railroady', '~> 1.1.1', require: false
|
32
33
|
end
|
33
34
|
|
34
35
|
group :development, :test do
|
35
|
-
gem 'dotenv-rails', '~> 0.
|
36
|
+
gem 'dotenv-rails', '~> 0.7.0'
|
36
37
|
end
|
37
38
|
|
38
39
|
group :assets do
|
39
40
|
gem 'sass-rails', '~> 4.0.1'
|
40
41
|
gem 'coffee-rails', '~> 4.0.1'
|
41
|
-
gem 'uglifier', '~> 2.
|
42
|
+
gem 'uglifier', '~> 2.5.0'
|
42
43
|
end
|
43
44
|
|
44
45
|
group :doc do
|
@@ -0,0 +1,95 @@
|
|
1
|
+
---
|
2
|
+
# the user name used to make a connection to the server
|
3
|
+
ansible_ssh_user: deploy
|
4
|
+
|
5
|
+
# the user created on the system
|
6
|
+
user_name: "{{ ansible_ssh_user }}"
|
7
|
+
|
8
|
+
# load all passwords from a local location outside of version control
|
9
|
+
secrets_load_path: ~/tmp/testproj/secrets/
|
10
|
+
|
11
|
+
secrets_postgres_password: "{{ lookup('password', secrets_load_path + 'postgres_password') }}"
|
12
|
+
secrets_redis_password: "{{ lookup('password', secrets_load_path + 'redis_password') }}"
|
13
|
+
secrets_mail_password: "{{ lookup('password', secrets_load_path + 'mail_password') }}"
|
14
|
+
secrets_rails_token: "{{ lookup('password', secrets_load_path + 'rails_token') }}"
|
15
|
+
secrets_devise_token: "{{ lookup('password', secrets_load_path + 'devise_token') }}"
|
16
|
+
secrets_devise_pepper_token: "{{ lookup('password', secrets_load_path + 'devise_pepper_token') }}"
|
17
|
+
|
18
|
+
|
19
|
+
# postgres login credentials
|
20
|
+
postgres_user: "{{ user_name }}"
|
21
|
+
postgres_password: "{{ secrets_postgres_password }}"
|
22
|
+
|
23
|
+
# redis configuration
|
24
|
+
redis_bind: 0.0.0.0
|
25
|
+
redis_port: 6379
|
26
|
+
redis_version: 2.8.9
|
27
|
+
redis_install_dir: /usr/local
|
28
|
+
redis_dir: /usr/local/redis
|
29
|
+
redis_password: false # must be set to true if you want to use a password
|
30
|
+
|
31
|
+
# rails application configuration
|
32
|
+
rails_deploy_app_name: testproj
|
33
|
+
rails_deploy_user: "{{ user_name }}"
|
34
|
+
|
35
|
+
rails_deploy_ssh_keypair_local_path: "{{ secrets_load_path }}"
|
36
|
+
|
37
|
+
rails_deploy_git_url: "git@bitbucket.org:yourname/testproj.git"
|
38
|
+
|
39
|
+
# you may have 1 or 100 app servers but you only want the migration
|
40
|
+
# to be ran on a single app server. The server you specify as the
|
41
|
+
# rails_deploy_migrate_master_host will be the server that the
|
42
|
+
# migration gets ran on
|
43
|
+
|
44
|
+
# the default value is the first server listed under your [app] group
|
45
|
+
rails_deploy_migrate_master_host: "{{ groups['app'][0] }}"
|
46
|
+
|
47
|
+
# environment variables for the rails application
|
48
|
+
# edit this list to account for any variables your app needs
|
49
|
+
rails_deploy_env:
|
50
|
+
RAILS_ENV: production
|
51
|
+
|
52
|
+
TESTPROJ_PROJECT_PATH: "{{ rails_deploy_path }}"
|
53
|
+
|
54
|
+
TESTPROJ_DATABASE_HOST: localhost
|
55
|
+
TESTPROJ_DATABASE_NAME: "{{ rails_deploy_app_name }}"
|
56
|
+
TESTPROJ_DATABASE_USERNAME: "{{ postgres_user }}"
|
57
|
+
TESTPROJ_DATABASE_PASSWORD: "{{ postgres_password }}"
|
58
|
+
TESTPROJ_DATABASE_POOL: 25
|
59
|
+
TESTPROJ_DATABASE_TIMEOUT: 5000
|
60
|
+
|
61
|
+
TESTPROJ_CACHE_HOST: "{{ redis_bind }}"
|
62
|
+
TESTPROJ_CACHE_PORT: "{{ redis_port }}"
|
63
|
+
TESTPROJ_CACHE_DATABASE: 0
|
64
|
+
TESTPROJ_CACHE_PASSWORD: "{{ secrets_redis_password }}"
|
65
|
+
|
66
|
+
TESTPROJ_TOKEN_RAILS_SECRET: "{{ secrets_rails_token }}"
|
67
|
+
TESTPROJ_TOKEN_DEVISE_SECRET: "{{ secrets_devise_token }}"
|
68
|
+
TESTPROJ_TOKEN_DEVISE_PEPPER: "{{ secrets_devise_pepper_token }}"
|
69
|
+
|
70
|
+
TESTPROJ_SMTP_ADDRESS: smtp.testproj.com
|
71
|
+
TESTPROJ_SMTP_PORT: 25
|
72
|
+
TESTPROJ_SMTP_DOMAIN: testproj.com
|
73
|
+
TESTPROJ_SMTP_USERNAME: info@testproj.com
|
74
|
+
TESTPROJ_SMTP_PASSWORD: "{{ secrets_mail_password }}"
|
75
|
+
TESTPROJ_SMTP_AUTH: plain
|
76
|
+
TESTPROJ_SMTP_STARTTTLS_AUTO: true
|
77
|
+
|
78
|
+
TESTPROJ_ACTION_MAILER_HOST: www.testproj.com
|
79
|
+
TESTPROJ_ACTION_MAILER_DEFAULT_EMAIL: info@testproj.com
|
80
|
+
TESTPROJ_ACTION_MAILER_DEVISE_DEFAULT_EMAIL: info@testproj.com
|
81
|
+
|
82
|
+
TESTPROJ_PUMA_THREADS_MIN: 0
|
83
|
+
TESTPROJ_PUMA_THREADS_MAX: 16
|
84
|
+
|
85
|
+
# ensure there are always at least 2 workers so puma can properly do phased restarts
|
86
|
+
TESTPROJ_PUMA_WORKERS: "{{ ansible_processor_cores if ansible_processor_cores > 1 else 2 }}"
|
87
|
+
|
88
|
+
TESTPROJ_SIDEKIQ_CONCURRENCY: 25
|
89
|
+
|
90
|
+
# nginx configuration
|
91
|
+
nginx_base_domain: 0.0.0.0
|
92
|
+
nginx_upstream_name: "{{ rails_deploy_app_name }}"
|
93
|
+
nginx_upstream_server: unix://{{ rails_deploy_path }}/tmp/puma.sock
|
94
|
+
nginx_root_path: /home/{{ rails_deploy_user }}/{{ rails_deploy_app_name }}.git/public
|
95
|
+
nginx_ssl_local_path: "{{ secrets_load_path }}"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDXTCCAkWgAwIBAgIJAPCgQS0/2Zn7MA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
|
3
|
+
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
4
|
+
aWRnaXRzIFB0eSBMdGQwHhcNMTQwNTA5MTIzNzQzWhcNMTUwNTA5MTIzNzQzWjBF
|
5
|
+
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
6
|
+
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
7
|
+
CgKCAQEAtUpfGtyeca1AgIXxINrO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XeeqjHPC7GcAg08FixG3v1C4VjR
|
18
|
+
9iybWBERLQHr6wPD7l7VwndlovEcnCj4KLvHuGO16r4+d+qTkSkJ/7TjKe9GxyEO
|
19
|
+
LUileGhTTwKBgQDTd9qpO+IyMlU6wTDfWedDn1oVz+AzimCON0rqTVrX8VM+kcfs
|
20
|
+
eSFREIOcpxEG55EAAcpr+DQ1TNabJ/sF30R35cpRyNndebbdwoH+jL2n4pKQcuK2
|
21
|
+
71r2qBLl/8C4bg96JghtoJeE/PSijcEI/28iPfxcEWnOkCXZeiQ0HcSftQKBgF65
|
22
|
+
a0dRL3hsQJ+0mEvDf+7KGBUBKTt2ewHO+z4Py1XR4NdsV7Vcqqs7ineY+VQeHM+f
|
23
|
+
IRW8gYLQrM1M20JfIN4cj2Bck2kSMZ25DopXa7ayFGz76AQnoCSnZjDyLfbFHlgi
|
24
|
+
XZ3T2/7xhGP5xOwgM1wtj5vk7usDKohFkhBkrsg7AoGBAIzEAXqTaLReuvvOhttV
|
25
|
+
5koMN4Gnt6bZOxT8fBSpeeOeiO6rs0qsKL4NR9qN8++ud9AkfyRSB3hPqyMbvEjA
|
26
|
+
t2VP39Q3PN5WK0cQwBOaHry4/A0c09vj7ORlK4Uu+zUNeiv3hDGw540IQ+KY7PZR
|
27
|
+
gkSekCx23K9H7NFGtDamczSi
|
28
|
+
-----END PRIVATE KEY-----
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# =====================================================================================================
|
2
|
+
# Template for generating an ansible playbook
|
3
|
+
# =====================================================================================================
|
4
|
+
|
5
|
+
# ----- Helper functions and variables ----------------------------------------------------------------
|
6
|
+
|
7
|
+
require 'securerandom'
|
8
|
+
|
9
|
+
def generate_token
|
10
|
+
SecureRandom.hex(64)
|
11
|
+
end
|
12
|
+
|
13
|
+
def git_config(field)
|
14
|
+
command = "git config --global user.#{field}"
|
15
|
+
git_field_value = run(command, capture: true).gsub("\n", '')
|
16
|
+
default_value = "YOUR_#{field.upcase}"
|
17
|
+
|
18
|
+
git_field_value.to_s.empty? ? default_value : git_field_value
|
19
|
+
end
|
20
|
+
|
21
|
+
app_name_upper = app_name.upcase
|
22
|
+
app_name_class = app_name.humanize
|
23
|
+
|
24
|
+
author_name = git_config 'name'
|
25
|
+
author_email = git_config 'email'
|
26
|
+
|
27
|
+
# ----- Nuke all of the rails code --------------------------------------------------------------------
|
28
|
+
|
29
|
+
puts
|
30
|
+
say_status 'shell', 'Removing all of the generated rails code...', :yellow
|
31
|
+
puts '-'*80, ''; sleep 0.25
|
32
|
+
|
33
|
+
run 'rm -rf * .git .gitignore'
|
34
|
+
|
35
|
+
# ----- Create playbook -------------------------------------------------------------------------------
|
36
|
+
|
37
|
+
puts
|
38
|
+
say_status 'init', 'Creating playbook...', :yellow
|
39
|
+
puts '-'*80, ''; sleep 0.25
|
40
|
+
|
41
|
+
run "mkdir -p #{app_name}"
|
42
|
+
|
43
|
+
# ----- Move playbook back one directory --------------------------------------------------------------
|
44
|
+
|
45
|
+
puts
|
46
|
+
say_status 'shell', 'Moving playbook back one directory...', :yellow
|
47
|
+
puts '-'*80, ''; sleep 0.25
|
48
|
+
|
49
|
+
run "mv #{app_name}/* ."
|
50
|
+
run "rm -rf #{app_name}"
|
51
|
+
|
52
|
+
# ----- Create the git repo ---------------------------------------------------------------------------
|
53
|
+
|
54
|
+
puts
|
55
|
+
say_status 'git', 'Creating initial commit...', :yellow
|
56
|
+
puts '-'*80, ''; sleep 0.25
|
57
|
+
|
58
|
+
git :init
|
59
|
+
git add: '.'
|
60
|
+
git commit: "-m 'Initial commit'"
|
61
|
+
|
62
|
+
# ----- Create the license ----------------------------------------------------------------------------
|
63
|
+
|
64
|
+
puts
|
65
|
+
say_status 'root', 'Creating the license', :yellow
|
66
|
+
puts '-'*80, ''; sleep 0.25
|
67
|
+
|
68
|
+
run 'rm -rf LICENSE'
|
69
|
+
|
70
|
+
file 'LICENSE' do <<-TEXT
|
71
|
+
The MIT License (MIT)
|
72
|
+
|
73
|
+
Copyright (c) #{Time.now.year} #{author_name} <#{author_email}>
|
74
|
+
|
75
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
76
|
+
a copy of this software and associated documentation files (the
|
77
|
+
'Software'), to deal in the Software without restriction, including
|
78
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
79
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
80
|
+
permit persons to whom the Software is furnished to do so, subject to
|
81
|
+
the following conditions:
|
82
|
+
|
83
|
+
The above copyright notice and this permission notice shall be
|
84
|
+
included in all copies or substantial portions of the Software.
|
85
|
+
|
86
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
87
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
88
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
89
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
90
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
91
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
92
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
93
|
+
TEXT
|
94
|
+
end
|
95
|
+
|
96
|
+
git add: '.'
|
97
|
+
git commit: "-m 'Add MIT license'"
|
98
|
+
|
99
|
+
# ----- Create the site file --------------------------------------------------------------------------
|
100
|
+
|
101
|
+
puts
|
102
|
+
say_status 'root', 'Creating the site yaml file', :yellow
|
103
|
+
puts '-'*80, ''; sleep 0.25
|
104
|
+
|
105
|
+
file 'site.yml' do <<-TEXT
|
106
|
+
---
|
107
|
+
- name: ensure all servers are commonly configured
|
108
|
+
hosts: all
|
109
|
+
sudo: true
|
110
|
+
|
111
|
+
roles:
|
112
|
+
- { role: nickjj.user, tags: [common, user] }
|
113
|
+
|
114
|
+
- name: ensure database servers are configured
|
115
|
+
hosts: database
|
116
|
+
sudo: true
|
117
|
+
|
118
|
+
roles:
|
119
|
+
- role: nickjj.security
|
120
|
+
tags: [database, security]
|
121
|
+
security_ufw_ports:
|
122
|
+
- rule: deny
|
123
|
+
port: 80
|
124
|
+
proto: tcp
|
125
|
+
- { role: nickjj.postgres, tags: [database, postgres] }
|
126
|
+
|
127
|
+
- name: ensure cache servers are configured
|
128
|
+
hosts: cache
|
129
|
+
sudo: true
|
130
|
+
|
131
|
+
roles:
|
132
|
+
- role: nickjj.security
|
133
|
+
tags: [cache, security]
|
134
|
+
security_ufw_ports:
|
135
|
+
- rule: deny
|
136
|
+
port: 80
|
137
|
+
proto: tcp
|
138
|
+
- { role: DavidWittman.redis, tags: [cache, redis] }
|
139
|
+
|
140
|
+
- name: ensure app servers are configured
|
141
|
+
hosts: app
|
142
|
+
sudo: true
|
143
|
+
|
144
|
+
roles:
|
145
|
+
- role: nickjj.security
|
146
|
+
tags: [app, security]
|
147
|
+
security_ufw_ports:
|
148
|
+
- rule: allow
|
149
|
+
port: 80
|
150
|
+
proto: tcp
|
151
|
+
- { role: nickjj.ruby, tags: [app, ruby] }
|
152
|
+
- { role: nickjj.nodejs, tags: [app, nodejs] }
|
153
|
+
- { role: nickjj.nginx, tags: [app, nginx] }
|
154
|
+
- { role: nickjj.rails, tags: [app, rails] }
|
155
|
+
TEXT
|
156
|
+
end
|
157
|
+
|
158
|
+
git add: '.'
|
159
|
+
git commit: "-m 'Add site.yml file'"
|
160
|
+
|
161
|
+
# ----- Installation complete message -----------------------------------------------------------------
|
162
|
+
|
163
|
+
puts
|
164
|
+
say_status 'success', "\e[1m\Everything has been setup successfully\e[0m", :cyan
|
165
|
+
puts
|
166
|
+
say_status 'question', 'Are most of your apps similar?', :yellow
|
167
|
+
say_status 'answer', 'You only need to generate one playbook and you just did', :white
|
168
|
+
say_status 'answer', 'Use the inventory in each project to customize certain things', :white
|
169
|
+
puts
|
170
|
+
say_status 'question', 'Are you new to ansible?', :yellow
|
171
|
+
say_status 'answer', 'http://docs.ansible.com/intro_getting_started.html', :white
|
172
|
+
puts '-'*80
|