orats 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,8 +21,8 @@ end
21
21
 
22
22
  def log_task(message)
23
23
  puts
24
- say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
25
- puts '-'*80, ''; sleep 0.25
24
+ say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
25
+ puts '-'*80, ''; sleep 0.25
26
26
  end
27
27
 
28
28
  def git_commit(message)
@@ -31,7 +31,7 @@ def git_commit(message)
31
31
  end
32
32
 
33
33
  def copy_from_local_gem(source, dest)
34
- base_path = "#{File.expand_path File.dirname(__FILE__)}/includes"
34
+ base_path = "#{File.expand_path File.dirname(__FILE__)}/includes"
35
35
  file_name_of_source = File.basename(source)
36
36
 
37
37
  run "mkdir -p #{File.dirname(dest)}" if dest.present? && file_name_of_source != dest
@@ -50,7 +50,8 @@ end
50
50
  def update_gitignore
51
51
  log_task __method__
52
52
 
53
- append_to_file '.gitignore' do <<-S
53
+ append_to_file '.gitignore' do
54
+ <<-S
54
55
  # OS and editor files
55
56
  .DS_Store
56
57
  */**.DS_Store
@@ -65,7 +66,7 @@ def update_gitignore
65
66
  # app specific folders
66
67
  /vendor/bundle
67
68
  /public/assets/*
68
- S
69
+ S
69
70
  end
70
71
  git_commit 'Add common OS files, editor files and other paths'
71
72
  end
@@ -89,10 +90,13 @@ end
89
90
  def add_dotenv
90
91
  log_task 'add_dotenv'
91
92
 
92
- file '.env' do <<-S
93
+ file '.env' do
94
+ <<-S
93
95
  RAILS_ENV: development
94
96
 
95
97
  PROJECT_PATH: /full/path/to/your/project
98
+ TIME_ZONE: Eastern Time (US & Canada)
99
+ DEFAULT_LOCALE: en
96
100
 
97
101
  GOOGLE_ANALYTICS_UA: ""
98
102
  DISQUS_SHORT_NAME: ""
@@ -131,7 +135,7 @@ PUMA_THREADS_MAX: 1
131
135
  PUMA_WORKERS: 0
132
136
 
133
137
  SIDEKIQ_CONCURRENCY: 25
134
- S
138
+ S
135
139
  end
136
140
  git_commit 'Add development environment file'
137
141
  end
@@ -139,20 +143,36 @@ end
139
143
  def add_procfile
140
144
  log_task __method__
141
145
 
142
- file 'Procfile' do <<-S
143
- web: puma -C config/puma.rb
146
+ file 'Procfile' do
147
+ <<-S
148
+ web: puma -C config/puma.rb | grep -v --line-buffered ' 304 -'
144
149
  worker: sidekiq -C config/sidekiq.yml
145
- log: tail -f log/development.log
146
- S
150
+ log: tail -f log/development.log | grep -xv --line-buffered '^[[:space:]]*' | grep -v --line-buffered '/assets/'
151
+ S
147
152
  end
148
- git_commit 'Add a Procfile'
153
+ git_commit 'Add Procfile'
154
+ end
155
+
156
+ def add_markdown_readme
157
+ log_task __method__
158
+
159
+ run 'rm README.rdoc'
160
+ file 'README.md' do
161
+ <<-S
162
+ ## Project information
163
+
164
+ This project was generated with [orats](https://github.com/nickjj/orats) vVERSION.
165
+ S
166
+ end
167
+ git_commit 'Add markdown readme'
149
168
  end
150
169
 
151
170
  def update_app_secrets
152
171
  log_task __method__
153
172
 
154
173
  gsub_file 'config/secrets.yml', /.*\n/, ''
155
- append_file 'config/secrets.yml' do <<-S
174
+ append_file 'config/secrets.yml' do
175
+ <<-S
156
176
  development: &default
157
177
  secret_key_base: <%= ENV['TOKEN_RAILS_SECRET'] %>
158
178
 
@@ -164,7 +184,7 @@ staging:
164
184
 
165
185
  production:
166
186
  <<: *default
167
- S
187
+ S
168
188
  end
169
189
  git_commit 'DRY out the yaml'
170
190
  end
@@ -172,7 +192,8 @@ end
172
192
  def update_app_config
173
193
  log_task __method__
174
194
 
175
- inject_into_file 'config/application.rb', after: "automatically loaded.\n" do <<-S
195
+ inject_into_file 'config/application.rb', after: "automatically loaded.\n" do
196
+ <<-S
176
197
  config.action_mailer.delivery_method = :smtp
177
198
  config.action_mailer.smtp_settings = {
178
199
  :address => ENV['SMTP_ADDRESS'],
@@ -196,12 +217,17 @@ def update_app_config
196
217
 
197
218
  redis_store_options[:password] = ENV['CACHE_PASSWORD'] if ENV['CACHE_PASSWORD'].present?
198
219
  config.cache_store = :redis_store, redis_store_options
199
- S
220
+
221
+ # run `bundle exec rake time:zones:all` to get a complete list of valid time zone names
222
+ config.time_zone = ENV['TIME_ZONE'] unless ENV['TIME_ZONE'] == 'UTC'
223
+
224
+ # http://www.loc.gov/standards/iso639-2/php/English_list.php
225
+ config.i18n.default_locale = ENV['DEFAULT_LOCALE'] unless ENV['DEFAULT_LOCALE'] == 'en'
226
+ S
200
227
  end
201
228
 
202
- gsub_file 'config/application.rb',
203
- "# config.time_zone = 'Central Time (US & Canada)'","config.time_zone = 'Eastern Time (US & Canada)'"
204
- append_file 'config/application.rb' do <<-'S'
229
+ append_file 'config/application.rb' do
230
+ <<-'S'
205
231
 
206
232
  ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
207
233
  if html_tag =~ /\<label/
@@ -211,7 +237,7 @@ ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
211
237
  %(#{html_tag}<p class="validation-error"> #{errors}</p>).html_safe
212
238
  end
213
239
  end
214
- S
240
+ S
215
241
  end
216
242
  git_commit 'Configure the mailer/redis, update the timezone and adjust the validation output'
217
243
  end
@@ -220,7 +246,8 @@ def update_database_config
220
246
  log_task __method__
221
247
 
222
248
  gsub_file 'config/database.yml', /.*\n/, ''
223
- append_file 'config/database.yml' do <<-S
249
+ append_file 'config/database.yml' do
250
+ <<-S
224
251
  development: &default
225
252
  adapter: postgresql
226
253
  database: <%= ENV['DATABASE_NAME'] %>
@@ -239,7 +266,7 @@ staging:
239
266
 
240
267
  production:
241
268
  <<: *default
242
- S
269
+ S
243
270
  end
244
271
  git_commit 'DRY out the yaml'
245
272
  end
@@ -384,24 +411,44 @@ end
384
411
  git_commit 'Add a staging environment'
385
412
  end
386
413
 
414
+ def update_development_environment
415
+ log_task __method__
416
+
417
+ inject_into_file 'config/environments/development.rb',
418
+ before: "\nend" do
419
+ <<-'S'
420
+ # Set the default generator asset engines
421
+ config.generators.stylesheet_engine = :scss
422
+ config.generators.javascript_engine = :coffee
423
+ S
424
+ end
425
+ git_commit 'Update the default generator asset engines'
426
+ end
427
+
387
428
  def update_production_environment
388
429
  log_task __method__
389
430
 
390
- inject_into_file 'config/environments/production.rb', after: "config.log_level = :info\n" do <<-'S'
391
- config.logger = Logger.new(config.paths['log'].first, 'daily')
392
- S
431
+ inject_into_file 'config/environments/production.rb', after: "config.log_level = :info\n" do
432
+ <<-'S'
433
+ config.logger = Logger.new(config.paths['log'].first, 'daily')
434
+ S
393
435
  end
394
436
  git_commit 'Update the logger to rotate daily'
395
437
 
396
- inject_into_file 'config/environments/production.rb', after: "%w( search.js )\n" do <<-'S'
397
- config.assets.precompile << Proc.new { |path|
398
- if path =~ /\.(eot|svg|ttf|woff|png)\z/
399
- true
400
- end
401
- }
402
- S
438
+ inject_into_file 'config/environments/production.rb', after: "%w( search.js )\n" do
439
+ <<-'S'
440
+ config.assets.precompile << Proc.new { |path|
441
+ if path =~ /\.(eot|svg|ttf|woff|png)\z/
442
+ true
443
+ end
444
+ }
445
+ S
403
446
  end
404
447
  git_commit 'Update the assets precompiler to include common file types'
448
+
449
+ gsub_file 'config/environments/production.rb',
450
+ '# config.assets.css_compressor', 'config.assets.css_compressor'
451
+ git_commit 'Add sass asset compression'
405
452
  end
406
453
 
407
454
  def update_routes
@@ -409,14 +456,15 @@ def update_routes
409
456
 
410
457
  prepend_file 'config/routes.rb', "require 'sidekiq/web'\n\n"
411
458
 
412
- inject_into_file 'config/routes.rb', after: "draw do\n" do <<-S
459
+ inject_into_file 'config/routes.rb', after: "draw do\n" do
460
+ <<-S
413
461
  concern :pageable do
414
462
  get 'page/:page', action: :index, on: :collection
415
463
  end
416
464
 
417
465
  # you may want to protect this behind authentication
418
466
  mount Sidekiq::Web => '/sidekiq'
419
- S
467
+ S
420
468
  end
421
469
  git_commit 'Add a concern for pagination and mount sidekiq'
422
470
  end
@@ -689,7 +737,8 @@ end
689
737
  def add_helpers
690
738
  log_task __method__
691
739
 
692
- inject_into_file 'app/helpers/application_helper.rb', after: "ApplicationHelper\n" do <<-S
740
+ inject_into_file 'app/helpers/application_helper.rb', after: "ApplicationHelper\n" do
741
+ <<-S
693
742
  def title(page_title)
694
743
  content_for(:title) { page_title }
695
744
  end
@@ -741,7 +790,7 @@ def add_helpers
741
790
  'danger'
742
791
  end
743
792
  end
744
- S
793
+ S
745
794
  end
746
795
  git_commit 'Add various helpers'
747
796
  end
@@ -981,7 +1030,8 @@ def update_sass
981
1030
  inject_into_file 'app/assets/stylesheets/application.css.scss',
982
1031
  " *= require font-awesome\n",
983
1032
  before: " *= require_self\n"
984
- append_file 'app/assets/stylesheets/application.css.scss' do <<-S
1033
+ append_file 'app/assets/stylesheets/application.css.scss' do
1034
+ <<-S
985
1035
 
986
1036
  // Core variables and mixins
987
1037
  @import "bootstrap/variables";
@@ -1050,7 +1100,7 @@ img {
1050
1100
  color: $brand-danger;
1051
1101
  font-size: $font-size-small;
1052
1102
  }
1053
- S
1103
+ S
1054
1104
  end
1055
1105
  git_commit 'Add font-awesome, bootstrap and a few default styles'
1056
1106
  end
@@ -1064,7 +1114,8 @@ def update_coffeescript
1064
1114
  inject_into_file 'app/assets/javascripts/application.js',
1065
1115
  "//= require jquery.turbolinks\n",
1066
1116
  before: "//= require_tree .\n"
1067
- inject_into_file 'app/assets/javascripts/application.js', before: "//= require_tree .\n" do <<-S
1117
+ inject_into_file 'app/assets/javascripts/application.js', before: "//= require_tree .\n" do
1118
+ <<-S
1068
1119
  //= require bootstrap/affix
1069
1120
  //= require bootstrap/alert
1070
1121
  //= require bootstrap/button
@@ -1077,7 +1128,7 @@ def update_coffeescript
1077
1128
  //= require bootstrap/scrollspy
1078
1129
  //= require bootstrap/tab
1079
1130
  //= require bootstrap/transition
1080
- S
1131
+ S
1081
1132
  end
1082
1133
  git_commit 'Add jquery.turbolinks and bootstrap'
1083
1134
  end
@@ -1097,6 +1148,7 @@ copy_gemfile
1097
1148
  copy_base_favicon
1098
1149
  add_dotenv
1099
1150
  add_procfile
1151
+ add_markdown_readme
1100
1152
  update_app_secrets
1101
1153
  update_app_config
1102
1154
  update_database_config
@@ -1107,6 +1159,7 @@ add_whenever_config
1107
1159
  add_sidekiq_initializer
1108
1160
  add_mini_profiler_initializer
1109
1161
  add_staging_environment
1162
+ update_development_environment
1110
1163
  update_production_environment
1111
1164
  update_routes
1112
1165
  add_backup_lib
@@ -1,12 +1,12 @@
1
1
  nickjj.user,v0.1.0
2
2
  nickjj.security,v0.1.1
3
- nickjj.postgres,v0.1.2
4
- nickjj.ruby,v0.1.4
3
+ nickjj.postgres,v0.1.3
4
+ nickjj.ruby,v0.1.5
5
5
  nickjj.nodejs,v0.1.1
6
- nickjj.nginx,v0.1.3
6
+ nickjj.nginx,v0.1.4
7
7
  nickjj.rails,v0.1.92
8
8
  nickjj.whenever,v0.1.1
9
9
  nickjj.pumacorn,v0.1.1
10
10
  nickjj.sidekiq,v0.1.1
11
- nickjj.monit,v0.1.2
12
- DavidWittman.redis
11
+ nickjj.monit,v0.1.3
12
+ DavidWittman.redis
@@ -4,6 +4,7 @@ gem 'rails', '~> 4.1.1'
4
4
  gem 'turbolinks', '~> 2.2.2'
5
5
  gem 'jquery-rails', '~> 3.1.0'
6
6
  gem 'jquery-turbolinks', '~> 2.0.2'
7
+ #gem 'jbuilder'
7
8
 
8
9
  gem 'bootstrap-sass', '~> 3.1.1'
9
10
  gem 'font-awesome-rails', '~> 4.1.0'
@@ -15,8 +16,6 @@ gem 'puma', '~> 2.8.2'
15
16
  gem 'sidekiq', '~> 3.1.2'
16
17
  gem 'sinatra', '>= 1.4.5', require: false
17
18
 
18
- #gem 'jbuilder'
19
-
20
19
  gem 'whenever', '~> 0.9.2', require: false
21
20
  gem 'backup', '~> 4.0.1', require: false
22
21
 
@@ -1,11 +1,9 @@
1
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
-
2
+ # -----------------------------------------------------------------------------
3
+ # secrets
8
4
  # load all passwords from a local location outside of version control
5
+ # -----------------------------------------------------------------------------
6
+
9
7
  # do not add a trailing slash to the path
10
8
  secrets_load_path: /home/yourname/dev/testproj/secrets
11
9
 
@@ -16,19 +14,54 @@ secrets_rails_token: "{{ lookup('password', secrets_load_path + '/rails_token')
16
14
  secrets_devise_token: "{{ lookup('password', secrets_load_path + '/devise_token') }}"
17
15
  secrets_devise_pepper_token: "{{ lookup('password', secrets_load_path + '/devise_pepper_token') }}"
18
16
 
19
- # postgres login credentials
17
+ # -----------------------------------------------------------------------------
18
+ # ansible
19
+ # -----------------------------------------------------------------------------
20
+ # default values you can overwrite with documentation:
21
+ # http://docs.ansible.com/intro_inventory.html#list-of-behavioral-inventory-parameters
22
+ # -----------------------------------------------------------------------------
23
+
24
+ ansible_ssh_user: deploy
25
+
26
+ # -----------------------------------------------------------------------------
27
+ # user
28
+ # -----------------------------------------------------------------------------
29
+ # default values you can overwrite with documentation:
30
+ # https://github.com/nickjj/ansible-user/#role-variables
31
+ # -----------------------------------------------------------------------------
32
+
33
+ user_name: "{{ ansible_ssh_user }}"
34
+
35
+ # -----------------------------------------------------------------------------
36
+ # postgres
37
+ # -----------------------------------------------------------------------------
38
+ # default values you can overwrite with documentation:
39
+ # https://github.com/nickjj/ansible-postgres/#role-variables
40
+ # -----------------------------------------------------------------------------
41
+
20
42
  postgres_user: "{{ user_name }}"
21
43
  postgres_password: "{{ secrets_postgres_password }}"
22
44
 
23
- # redis configuration
45
+ # -----------------------------------------------------------------------------
46
+ # redis
47
+ # -----------------------------------------------------------------------------
48
+ # default values you can overwrite with documentation:
49
+ # https://github.com/DavidWittman/ansible-redis/blob/master/defaults/main.yml
50
+ # -----------------------------------------------------------------------------
51
+
24
52
  redis_bind: 0.0.0.0
25
53
  redis_port: 6379
26
- redis_version: 2.8.9
27
54
  redis_install_dir: /usr/local
28
55
  redis_dir: /usr/local/redis
29
56
  redis_password: "{{ secrets_redis_password }}"
30
57
 
31
- # rails application configuration
58
+ # -----------------------------------------------------------------------------
59
+ # rails
60
+ # -----------------------------------------------------------------------------
61
+ # default values you can overwrite with documentation:
62
+ # https://github.com/nickjj/ansible-rails/#role-variables
63
+ # -----------------------------------------------------------------------------
64
+
32
65
  rails_deploy_app_name: testproj
33
66
  rails_deploy_user: "{{ user_name }}"
34
67
 
@@ -36,21 +69,15 @@ rails_deploy_ssh_keypair_local_path: "{{ secrets_load_path }}"
36
69
 
37
70
  rails_deploy_git_url: "git@bitbucket.org:yourname/testproj.git"
38
71
 
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
72
  rails_deploy_migrate_master_host: "{{ groups['app'][0] }}"
46
73
 
47
- # environment variables for the rails application
48
- # edit this list to account for any variables your app needs
49
74
  rails_deploy_env:
50
75
  RAILS_ENV: production
76
+ SOURCE_ENV_PATH: "/etc/default/{{ rails_deploy_app_name }}"
51
77
 
52
78
  PROJECT_PATH: "{{ rails_deploy_path }}"
53
- SOURCE_ENV_PATH: "/etc/default/{{ rails_deploy_app_name }}"
79
+ TIME_ZONE: Eastern Time (US & Canada)
80
+ DEFAULT_LOCALE: en
54
81
 
55
82
  GOOGLE_ANALYTICS_UA: ""
56
83
  DISQUS_SHORT_NAME: ""
@@ -90,22 +117,53 @@ rails_deploy_env:
90
117
  PUMA_THREADS_MIN: 0
91
118
  PUMA_THREADS_MAX: 16
92
119
 
93
- # ensure there are always at least 2 workers so puma can properly do phased restarts
94
120
  PUMA_WORKERS: "{{ ansible_processor_cores if ansible_processor_cores > 1 else 2 }}"
95
121
 
96
122
  SIDEKIQ_CONCURRENCY: 25
97
123
 
98
- # whenever configuration
124
+ # -----------------------------------------------------------------------------
125
+ # whenever
126
+ # -----------------------------------------------------------------------------
127
+ # default values you can overwrite with documentation:
128
+ # https://github.com/nickjj/ansible-whenever/#role-variables
129
+ # -----------------------------------------------------------------------------
130
+
99
131
  whenever_update: rails_deploy_app_name
100
132
 
101
- # nginx configuration
102
- nginx_base_domain: localhost
133
+ # -----------------------------------------------------------------------------
134
+ # pumacorn
135
+ # -----------------------------------------------------------------------------
136
+ # default values you can overwrite with documentation:
137
+ # https://github.com/nickjj/ansible-pumacorn/#role-variables
138
+ # -----------------------------------------------------------------------------
139
+
140
+ # -----------------------------------------------------------------------------
141
+ # sidekiq
142
+ # -----------------------------------------------------------------------------
143
+ # default values you can overwrite with documentation:
144
+ # https://github.com/nickjj/ansible-sidekiq/#role-variables
145
+ # -----------------------------------------------------------------------------
146
+
147
+ # -----------------------------------------------------------------------------
148
+ # nginx
149
+ # -----------------------------------------------------------------------------
150
+ # default values you can overwrite with documentation:
151
+ # https://github.com/nickjj/ansible-nginx/#role-variables
152
+ # -----------------------------------------------------------------------------
153
+
154
+ nginx_base_domain: localhost # change this to yourdomain.com
103
155
  nginx_upstream_name: "{{ rails_deploy_app_name }}"
104
156
  nginx_upstream_server: unix://{{ rails_deploy_path }}/tmp/puma.sock
105
157
  nginx_root_path: "{{ rails_deploy_path }}/public"
106
158
  nginx_ssl_local_path: "{{ secrets_load_path }}"
107
159
 
108
- # monit configuration
160
+ # -----------------------------------------------------------------------------
161
+ # monit
162
+ # -----------------------------------------------------------------------------
163
+ # default values you can overwrite with documentation:
164
+ # https://github.com/nickjj/ansible-monit/#role-variables
165
+ # -----------------------------------------------------------------------------
166
+
109
167
  monit_process_list: |
110
168
  check process {{ rails_deploy_app_name }} with pidfile {{ rails_deploy_path }}/tmp/{{ pumacorn_server }}.pid
111
169
  start program = "/etc/init.d/{{ rails_deploy_app_name }} start"