orats 0.6.5 → 0.7.0
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.
- checksums.yaml +4 -4
- data/README.md +231 -58
- data/lib/orats/cli.rb +63 -25
- data/lib/orats/commands/common.rb +47 -22
- data/lib/orats/commands/{outdated → diff}/compare.rb +5 -4
- data/lib/orats/commands/diff/exec.rb +86 -0
- data/lib/orats/commands/{outdated → diff}/parse.rb +5 -1
- data/lib/orats/commands/inventory.rb +121 -0
- data/lib/orats/commands/{play.rb → playbook.rb} +5 -5
- data/lib/orats/commands/project/exec.rb +74 -0
- data/lib/orats/commands/{new → project}/rails.rb +57 -81
- data/lib/orats/commands/{new → project}/server.rb +6 -4
- data/lib/orats/templates/auth.rb +26 -481
- data/lib/orats/templates/base.rb +74 -716
- data/lib/orats/templates/includes/common/LICENSE +22 -0
- data/lib/orats/templates/includes/new/rails/.env +43 -0
- data/lib/orats/templates/includes/{Gemfile → new/rails/Gemfile} +1 -1
- data/lib/orats/templates/includes/new/rails/Procfile +3 -0
- data/lib/orats/templates/includes/new/rails/README.md +3 -0
- data/lib/orats/templates/includes/{app → new/rails/app}/assets/favicon/favicon_base.png +0 -0
- data/lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb +53 -0
- data/lib/orats/templates/includes/new/rails/app/models/account.rb +40 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb +8 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb +28 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb +51 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb +31 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb +39 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb +38 -0
- data/lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb +26 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb +19 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb +12 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_flash.html.erb +10 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb +2 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb +13 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_tracker.html.erb +4 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation.html.erb +18 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb +15 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb +3 -0
- data/lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb +48 -0
- data/lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb +81 -0
- data/lib/orats/templates/includes/new/rails/config/database.yml +19 -0
- data/lib/orats/templates/includes/new/rails/config/environments/staging.rb +5 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb +1 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb +4 -0
- data/lib/orats/templates/includes/new/rails/config/initializers/sidekiq.rb +16 -0
- data/lib/orats/templates/includes/new/rails/config/puma.rb +25 -0
- data/lib/orats/templates/includes/new/rails/config/secrets.yml +12 -0
- data/lib/orats/templates/includes/new/rails/config/sidekiq.yml +5 -0
- data/lib/orats/templates/includes/new/rails/config/sitemap.rb +20 -0
- data/lib/orats/templates/includes/new/rails/config/whenever.rb +7 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/config.rb +116 -0
- data/lib/orats/templates/includes/new/rails/lib/backup/models/backup.rb +55 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/backup.rake +18 -0
- data/lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake +48 -0
- data/lib/orats/templates/includes/new/rails/public/404.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/422.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/500.html +13 -0
- data/lib/orats/templates/includes/new/rails/public/502.html +13 -0
- data/lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml +27 -0
- data/lib/orats/templates/includes/new/rails/test/models/account_test.rb +46 -0
- data/lib/orats/templates/includes/{Galaxyfile → playbook/Galaxyfile} +0 -0
- data/lib/orats/templates/includes/playbook/site.yml +53 -0
- data/lib/orats/templates/playbook.rb +115 -0
- data/lib/orats/version.rb +1 -1
- data/test/integration/cli_test.rb +122 -75
- data/test/test_helper.rb +16 -8
- metadata +63 -14
- data/lib/orats/commands/new/ansible.rb +0 -98
- data/lib/orats/commands/new/exec.rb +0 -60
- data/lib/orats/commands/outdated/exec.rb +0 -46
- data/lib/orats/templates/play.rb +0 -185
data/test/test_helper.rb
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
require 'minitest/autorun'
|
|
2
2
|
require 'securerandom'
|
|
3
|
-
require_relative '../lib/orats/commands/
|
|
3
|
+
require_relative '../lib/orats/commands/project/server'
|
|
4
4
|
|
|
5
5
|
module Orats
|
|
6
6
|
module Test
|
|
7
|
-
include Commands::
|
|
7
|
+
include Commands::Project::Server
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
TEST_PATH = ENV['TEST_PATH'] || '/tmp/orats'
|
|
10
|
+
POSTGRES_LOCATION = ENV['POSTGRES_LOCATION'] || 'localhost'
|
|
11
|
+
POSTGRES_USERNAME = ENV['POSTGRES_USERNAME'] || 'postgres'
|
|
12
|
+
POSTGRES_PASSWORD = ENV['POSTGRES_PASSWORD'] || 'pleasedonthackme'
|
|
13
|
+
REDIS_LOCATION = ENV['REDIS_LOCATION'] || 'localhost'
|
|
14
|
+
REDIS_PASSWORD = ENV['REDIS_PASSWORD'] || ''
|
|
15
|
+
|
|
16
|
+
CREDENTIALS = "-l #{POSTGRES_LOCATION} -u #{POSTGRES_USERNAME} -p #{POSTGRES_PASSWORD} -n #{REDIS_LOCATION} -d #{REDIS_PASSWORD}"
|
|
17
|
+
|
|
18
|
+
BINARY_PATH = File.absolute_path('../../bin/orats', __FILE__)
|
|
19
|
+
ORATS_NEW_FLAGS = "#{CREDENTIALS} -FG"
|
|
12
20
|
|
|
13
21
|
def orats(command, options = {})
|
|
14
22
|
cmd, app_name = command.split(' ')
|
|
15
23
|
prepend_command = ''
|
|
16
|
-
|
|
17
|
-
command = "#{cmd} #{TEST_PATH}/#{app_name}" if command.include?(' ')
|
|
24
|
+
command = "#{cmd} #{TEST_PATH}/#{app_name}" unless app_name.nil?
|
|
18
25
|
|
|
19
26
|
if options.has_key?(:answer)
|
|
20
|
-
options[:answer] == 'y' || options[:answer] == 'yes' ?
|
|
27
|
+
options[:answer] == 'y' || options[:answer] == 'yes' ?
|
|
28
|
+
insert_answer = 'yes' : insert_answer = 'echo'
|
|
21
29
|
|
|
22
30
|
prepend_command = "#{insert_answer} | "
|
|
23
31
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: orats
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Janetakis
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-06-
|
|
11
|
+
date: 2014-06-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -84,24 +84,73 @@ files:
|
|
|
84
84
|
- lib/orats.rb
|
|
85
85
|
- lib/orats/cli.rb
|
|
86
86
|
- lib/orats/commands/common.rb
|
|
87
|
-
- lib/orats/commands/
|
|
88
|
-
- lib/orats/commands/
|
|
89
|
-
- lib/orats/commands/
|
|
90
|
-
- lib/orats/commands/
|
|
87
|
+
- lib/orats/commands/diff/compare.rb
|
|
88
|
+
- lib/orats/commands/diff/exec.rb
|
|
89
|
+
- lib/orats/commands/diff/parse.rb
|
|
90
|
+
- lib/orats/commands/inventory.rb
|
|
91
91
|
- lib/orats/commands/nuke.rb
|
|
92
|
-
- lib/orats/commands/
|
|
93
|
-
- lib/orats/commands/
|
|
94
|
-
- lib/orats/commands/
|
|
95
|
-
- lib/orats/commands/
|
|
92
|
+
- lib/orats/commands/playbook.rb
|
|
93
|
+
- lib/orats/commands/project/exec.rb
|
|
94
|
+
- lib/orats/commands/project/rails.rb
|
|
95
|
+
- lib/orats/commands/project/server.rb
|
|
96
96
|
- lib/orats/commands/ui.rb
|
|
97
97
|
- lib/orats/templates/auth.rb
|
|
98
98
|
- lib/orats/templates/base.rb
|
|
99
|
-
- lib/orats/templates/includes/
|
|
100
|
-
- lib/orats/templates/includes/Gemfile
|
|
101
|
-
- lib/orats/templates/includes/app/assets/favicon/favicon_base.png
|
|
99
|
+
- lib/orats/templates/includes/common/LICENSE
|
|
102
100
|
- lib/orats/templates/includes/inventory/group_vars/all.yml
|
|
103
101
|
- lib/orats/templates/includes/inventory/hosts
|
|
104
|
-
- lib/orats/templates/
|
|
102
|
+
- lib/orats/templates/includes/new/rails/.env
|
|
103
|
+
- lib/orats/templates/includes/new/rails/Gemfile
|
|
104
|
+
- lib/orats/templates/includes/new/rails/Procfile
|
|
105
|
+
- lib/orats/templates/includes/new/rails/README.md
|
|
106
|
+
- lib/orats/templates/includes/new/rails/app/assets/favicon/favicon_base.png
|
|
107
|
+
- lib/orats/templates/includes/new/rails/app/helpers/application_helper.rb
|
|
108
|
+
- lib/orats/templates/includes/new/rails/app/models/account.rb
|
|
109
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/confirmations/new.html.erb
|
|
110
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/mailer/confirmation_instructions.html.erb
|
|
111
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/mailer/reset_password_instructions.html.erb
|
|
112
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/mailer/unlock_instructions.html.erb
|
|
113
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/passwords/edit.html.erb
|
|
114
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/passwords/new.html.erb
|
|
115
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/registrations/edit.html.erb
|
|
116
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/registrations/new.html.erb
|
|
117
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/sessions/new.html.erb
|
|
118
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/shared/_links.html.erb
|
|
119
|
+
- lib/orats/templates/includes/new/rails/app/views/devise/unlocks/new.html.erb
|
|
120
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_comments_snippet.html.erb
|
|
121
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_disqus_count_snippet.html.erb
|
|
122
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_flash.html.erb
|
|
123
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_footer.html.erb
|
|
124
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_snippet.html.erb
|
|
125
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_google_analytics_tracker.html.erb
|
|
126
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_navigation.html.erb
|
|
127
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_auth.html.erb
|
|
128
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/_navigation_links.html.erb
|
|
129
|
+
- lib/orats/templates/includes/new/rails/app/views/layouts/application.html.erb
|
|
130
|
+
- lib/orats/templates/includes/new/rails/app/views/pages/home.html.erb
|
|
131
|
+
- lib/orats/templates/includes/new/rails/config/database.yml
|
|
132
|
+
- lib/orats/templates/includes/new/rails/config/environments/staging.rb
|
|
133
|
+
- lib/orats/templates/includes/new/rails/config/initializers/devise_async.rb
|
|
134
|
+
- lib/orats/templates/includes/new/rails/config/initializers/mini_profiler.rb
|
|
135
|
+
- lib/orats/templates/includes/new/rails/config/initializers/sidekiq.rb
|
|
136
|
+
- lib/orats/templates/includes/new/rails/config/puma.rb
|
|
137
|
+
- lib/orats/templates/includes/new/rails/config/secrets.yml
|
|
138
|
+
- lib/orats/templates/includes/new/rails/config/sidekiq.yml
|
|
139
|
+
- lib/orats/templates/includes/new/rails/config/sitemap.rb
|
|
140
|
+
- lib/orats/templates/includes/new/rails/config/whenever.rb
|
|
141
|
+
- lib/orats/templates/includes/new/rails/lib/backup/config.rb
|
|
142
|
+
- lib/orats/templates/includes/new/rails/lib/backup/models/backup.rb
|
|
143
|
+
- lib/orats/templates/includes/new/rails/lib/tasks/orats/backup.rake
|
|
144
|
+
- lib/orats/templates/includes/new/rails/lib/tasks/orats/favicon.rake
|
|
145
|
+
- lib/orats/templates/includes/new/rails/public/404.html
|
|
146
|
+
- lib/orats/templates/includes/new/rails/public/422.html
|
|
147
|
+
- lib/orats/templates/includes/new/rails/public/500.html
|
|
148
|
+
- lib/orats/templates/includes/new/rails/public/502.html
|
|
149
|
+
- lib/orats/templates/includes/new/rails/test/fixtures/accounts.yml
|
|
150
|
+
- lib/orats/templates/includes/new/rails/test/models/account_test.rb
|
|
151
|
+
- lib/orats/templates/includes/playbook/Galaxyfile
|
|
152
|
+
- lib/orats/templates/includes/playbook/site.yml
|
|
153
|
+
- lib/orats/templates/playbook.rb
|
|
105
154
|
- lib/orats/version.rb
|
|
106
155
|
- orats.gemspec
|
|
107
156
|
- test/integration/cli_test.rb
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
require 'securerandom'
|
|
2
|
-
|
|
3
|
-
module Orats
|
|
4
|
-
module Commands
|
|
5
|
-
module New
|
|
6
|
-
module Ansible
|
|
7
|
-
def ansible_extras
|
|
8
|
-
create_inventory
|
|
9
|
-
|
|
10
|
-
secrets_path = "#{@target_path}/secrets"
|
|
11
|
-
create_secrets secrets_path
|
|
12
|
-
|
|
13
|
-
log_task 'Update secrets path in group_vars/all.yml'
|
|
14
|
-
gsub_file "#{@target_path}/#{fix_path_for_user(Commands::Common::RELATIVE_PATHS[:inventory])}",
|
|
15
|
-
'~/tmp/testproj/secrets/', File.expand_path(secrets_path)
|
|
16
|
-
|
|
17
|
-
log_task 'Update place holder app name in group_vars/all.yml'
|
|
18
|
-
gsub_file "#{@target_path}/#{fix_path_for_user(Commands::Common::RELATIVE_PATHS[:inventory])}",
|
|
19
|
-
'testproj', File.basename(@target_path)
|
|
20
|
-
|
|
21
|
-
log_task 'Add ssh keypair'
|
|
22
|
-
run "ssh-keygen -t rsa -P '' -f #{secrets_path}/id_rsa"
|
|
23
|
-
|
|
24
|
-
log_task 'Add self signed ssl certificates'
|
|
25
|
-
run create_rsa_certificate(secrets_path, 'sslkey.key', 'sslcert.crt')
|
|
26
|
-
|
|
27
|
-
log_task 'Add monit pem file'
|
|
28
|
-
run "#{create_rsa_certificate(secrets_path,
|
|
29
|
-
'monit.pem', 'monit.pem')} && openssl gendh 512 >> #{secrets_path}/monit.pem"
|
|
30
|
-
|
|
31
|
-
install_role_dependencies unless @options[:skip_galaxy]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def create_inventory
|
|
37
|
-
log_task 'Add ansible inventory'
|
|
38
|
-
run "mkdir -p #{@target_path}/inventory/group_vars"
|
|
39
|
-
|
|
40
|
-
local_to_user Commands::Common::RELATIVE_PATHS[:hosts]
|
|
41
|
-
local_to_user Commands::Common::RELATIVE_PATHS[:inventory]
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def local_to_user(file)
|
|
45
|
-
fixed_file = fix_path_for_user(file)
|
|
46
|
-
|
|
47
|
-
log_task "Add #{fixed_file}"
|
|
48
|
-
run "cp #{base_path}/#{file} #{@target_path}/#{fixed_file}"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def create_secrets(secrets_path)
|
|
52
|
-
log_task 'Add ansible secrets'
|
|
53
|
-
run "mkdir #{secrets_path}"
|
|
54
|
-
|
|
55
|
-
save_secret_string "#{secrets_path}/postgres_password"
|
|
56
|
-
save_secret_string "#{secrets_path}/redis_password"
|
|
57
|
-
save_secret_string "#{secrets_path}/mail_password"
|
|
58
|
-
save_secret_string "#{secrets_path}/rails_token"
|
|
59
|
-
save_secret_string "#{secrets_path}/devise_token"
|
|
60
|
-
save_secret_string "#{secrets_path}/devise_pepper_token"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def save_secret_string(file)
|
|
64
|
-
File.open(file, 'w+') { |f| f.write(SecureRandom.hex(64)) }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def create_rsa_certificate(secrets_path, keyout, out)
|
|
68
|
-
"openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -subj '/C=US/ST=Foo/L=Bar/O=Baz/CN=qux.com' -keyout #{secrets_path}/#{keyout} -out #{secrets_path}/#{out}"
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def install_role_dependencies
|
|
72
|
-
log_task 'Update ansible roles from the galaxy'
|
|
73
|
-
|
|
74
|
-
galaxy_install =
|
|
75
|
-
"ansible-galaxy install -r #{base_path}/#{Commands::Common::RELATIVE_PATHS[:galaxyfile]} --force"
|
|
76
|
-
|
|
77
|
-
galaxy_out = run(galaxy_install, capture: true)
|
|
78
|
-
|
|
79
|
-
if galaxy_out.include?('you do not have permission')
|
|
80
|
-
if @options[:sudo_password].empty?
|
|
81
|
-
sudo_galaxy_command = 'sudo'
|
|
82
|
-
else
|
|
83
|
-
sudo_galaxy_command = "echo #{@options[:sudo_password]} | sudo -S"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
run("#{sudo_galaxy_command} #{galaxy_install}")
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
def fix_path_for_user(file)
|
|
93
|
-
file.sub('templates/includes/', '')
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
require 'orats/commands/common'
|
|
2
|
-
require 'orats/commands/new/ansible'
|
|
3
|
-
require 'orats/commands/new/rails'
|
|
4
|
-
require 'orats/commands/new/server'
|
|
5
|
-
|
|
6
|
-
module Orats
|
|
7
|
-
module Commands
|
|
8
|
-
module New
|
|
9
|
-
class Exec < Commands::Common
|
|
10
|
-
include Ansible
|
|
11
|
-
include Rails
|
|
12
|
-
include Server
|
|
13
|
-
|
|
14
|
-
def initialize(target_path = '', options = {})
|
|
15
|
-
super
|
|
16
|
-
|
|
17
|
-
@active_path = services_path
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def init
|
|
21
|
-
check_exit_conditions
|
|
22
|
-
|
|
23
|
-
rails_template 'base' do
|
|
24
|
-
gsub_postgres_info
|
|
25
|
-
gsub_redis_info unless @options[:redis_password].empty?
|
|
26
|
-
gsub_project_path
|
|
27
|
-
gsub_readme
|
|
28
|
-
|
|
29
|
-
bundle_install
|
|
30
|
-
bundle_binstubs
|
|
31
|
-
spring_binstub
|
|
32
|
-
|
|
33
|
-
create_and_migrate_database
|
|
34
|
-
generate_home_page
|
|
35
|
-
run_rake 'orats:favicons'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
if @options[:auth]
|
|
39
|
-
rails_template 'auth', '--skip ' do
|
|
40
|
-
run_rake 'db:migrate db:seed'
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
ansible_extras unless @options[:skip_extras]
|
|
45
|
-
|
|
46
|
-
custom_rails_template unless @options[:template].empty?
|
|
47
|
-
|
|
48
|
-
server_start unless @options[:skip_server_start]
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
private
|
|
52
|
-
|
|
53
|
-
def services_path
|
|
54
|
-
@options[:skip_extras] ? @target_path
|
|
55
|
-
: "#{@target_path}/services/#{File.basename @target_path}"
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
require 'orats/commands/common'
|
|
2
|
-
require 'orats/version'
|
|
3
|
-
require 'orats/commands/outdated/parse'
|
|
4
|
-
require 'orats/commands/outdated/compare'
|
|
5
|
-
|
|
6
|
-
module Orats
|
|
7
|
-
module Commands
|
|
8
|
-
module Outdated
|
|
9
|
-
class Exec < Commands::Common
|
|
10
|
-
include Parse
|
|
11
|
-
include Compare
|
|
12
|
-
|
|
13
|
-
def initialize(target_path = '', options = {})
|
|
14
|
-
super
|
|
15
|
-
|
|
16
|
-
@remote_galaxyfile = galaxyfile url_to_string(@remote_paths[:galaxyfile])
|
|
17
|
-
@remote_inventory = inventory url_to_string(@remote_paths[:inventory])
|
|
18
|
-
@remote_playbook = playbook url_to_string(@remote_paths[:playbook])
|
|
19
|
-
|
|
20
|
-
@local_galaxyfile = galaxyfile file_to_string(@local_paths[:galaxyfile])
|
|
21
|
-
@local_inventory = inventory file_to_string(@local_paths[:inventory])
|
|
22
|
-
@local_playbook = playbook file_to_string(@local_paths[:playbook])
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def init
|
|
26
|
-
remote_to_local_gem_versions
|
|
27
|
-
remote_to_local_galaxyfiles
|
|
28
|
-
remote_to_local 'inventory', 'variables', @remote_inventory, @local_inventory
|
|
29
|
-
remote_to_local 'playbook', 'roles', @remote_playbook, @local_playbook
|
|
30
|
-
|
|
31
|
-
unless @options[:playbook].empty?
|
|
32
|
-
local_to_user('playbook', 'roles', @options[:playbook], @local_playbook) do
|
|
33
|
-
playbook file_to_string(@options[:playbook])
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
unless @options[:inventory].empty?
|
|
38
|
-
local_to_user('inventory', 'variables', @options[:inventory], @local_inventory) do
|
|
39
|
-
inventory file_to_string(@options[:inventory])
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
data/lib/orats/templates/play.rb
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
require 'securerandom'
|
|
2
|
-
|
|
3
|
-
# =============================================================================
|
|
4
|
-
# template for generating an orats ansible playbook for ansible 1.6.x
|
|
5
|
-
# =============================================================================
|
|
6
|
-
# view the task list at the bottom of the file
|
|
7
|
-
# -----------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
# -----------------------------------------------------------------------------
|
|
10
|
-
# private functions
|
|
11
|
-
# -----------------------------------------------------------------------------
|
|
12
|
-
def generate_token
|
|
13
|
-
SecureRandom.hex(64)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def method_to_sentence(method)
|
|
17
|
-
method.tr!('_', ' ')
|
|
18
|
-
method[0] = method[0].upcase
|
|
19
|
-
method
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def log_task(message)
|
|
23
|
-
puts
|
|
24
|
-
say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
|
|
25
|
-
puts '-'*80, ''; sleep 0.25
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def git_commit(message)
|
|
29
|
-
git add: '-A'
|
|
30
|
-
git commit: "-m '#{message}'"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def git_config(field)
|
|
34
|
-
command = "git config --global user.#{field}"
|
|
35
|
-
git_field_value = run(command, capture: true).gsub("\n", '')
|
|
36
|
-
default_value = "YOUR_#{field.upcase}"
|
|
37
|
-
|
|
38
|
-
git_field_value.to_s.empty? ? default_value : git_field_value
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# ---
|
|
42
|
-
|
|
43
|
-
def delete_generated_rails_code
|
|
44
|
-
log_task __method__
|
|
45
|
-
|
|
46
|
-
run 'rm -rf * .git .gitignore'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def add_playbook_directory
|
|
50
|
-
log_task __method__
|
|
51
|
-
|
|
52
|
-
run "mkdir -p #{app_name}"
|
|
53
|
-
run "mv #{app_name}/* ."
|
|
54
|
-
run "rm -rf #{app_name}"
|
|
55
|
-
git :init
|
|
56
|
-
git_commit 'Initial commit'
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def add_license
|
|
60
|
-
log_task __method__
|
|
61
|
-
|
|
62
|
-
author_name = git_config 'name'
|
|
63
|
-
author_email = git_config 'email'
|
|
64
|
-
|
|
65
|
-
run 'rm -rf LICENSE'
|
|
66
|
-
file 'LICENSE' do
|
|
67
|
-
<<-S
|
|
68
|
-
The MIT License (MIT)
|
|
69
|
-
|
|
70
|
-
Copyright (c) #{Time.now.year} #{author_name} <#{author_email}>
|
|
71
|
-
|
|
72
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
73
|
-
a copy of this software and associated documentation files (the
|
|
74
|
-
'Software'), to deal in the Software without restriction, including
|
|
75
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
76
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
77
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
78
|
-
the following conditions:
|
|
79
|
-
|
|
80
|
-
The above copyright notice and this permission notice shall be
|
|
81
|
-
included in all copies or substantial portions of the Software.
|
|
82
|
-
|
|
83
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
84
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
85
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
86
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
87
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
88
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
89
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
90
|
-
S
|
|
91
|
-
end
|
|
92
|
-
git_commit 'Add MIT license'
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def add_main_playbook
|
|
96
|
-
log_task __method__
|
|
97
|
-
|
|
98
|
-
file 'site.yml' do
|
|
99
|
-
<<-S
|
|
100
|
-
---
|
|
101
|
-
- name: ensure all servers are commonly configured
|
|
102
|
-
hosts: all
|
|
103
|
-
sudo: true
|
|
104
|
-
|
|
105
|
-
roles:
|
|
106
|
-
- { role: nickjj.user, tags: [common, user] }
|
|
107
|
-
|
|
108
|
-
- name: ensure database servers are configured
|
|
109
|
-
hosts: database
|
|
110
|
-
sudo: true
|
|
111
|
-
|
|
112
|
-
roles:
|
|
113
|
-
- role: nickjj.security
|
|
114
|
-
tags: [database, security]
|
|
115
|
-
security_ufw_ports:
|
|
116
|
-
- rule: deny
|
|
117
|
-
port: 80
|
|
118
|
-
proto: tcp
|
|
119
|
-
- { role: nickjj.postgres, tags: [database, postgres] }
|
|
120
|
-
|
|
121
|
-
- name: ensure cache servers are configured
|
|
122
|
-
hosts: cache
|
|
123
|
-
sudo: true
|
|
124
|
-
|
|
125
|
-
roles:
|
|
126
|
-
- role: nickjj.security
|
|
127
|
-
tags: [cache, security]
|
|
128
|
-
security_ufw_ports:
|
|
129
|
-
- rule: deny
|
|
130
|
-
port: 80
|
|
131
|
-
proto: tcp
|
|
132
|
-
- { role: DavidWittman.redis, tags: [cache, redis] }
|
|
133
|
-
|
|
134
|
-
- name: ensure app servers are configured
|
|
135
|
-
hosts: app
|
|
136
|
-
sudo: true
|
|
137
|
-
|
|
138
|
-
roles:
|
|
139
|
-
- role: nickjj.security
|
|
140
|
-
tags: [app, security]
|
|
141
|
-
security_ufw_ports:
|
|
142
|
-
- rule: allow
|
|
143
|
-
port: 80
|
|
144
|
-
proto: tcp
|
|
145
|
-
- { role: nickjj.ruby, tags: [app, ruby] }
|
|
146
|
-
- { role: nickjj.nodejs, tags: [app, nodejs] }
|
|
147
|
-
- { role: nickjj.nginx, tags: [app, nginx] }
|
|
148
|
-
- { role: nickjj.rails, tags: [app, rails] }
|
|
149
|
-
- { role: nickjj.whenever, tags: [app, rails] }
|
|
150
|
-
- { role: nickjj.pumacorn, tags: [app, rails] }
|
|
151
|
-
- { role: nickjj.sidekiq, tags: [app, rails] }
|
|
152
|
-
- { role: nickjj.monit, tags: [app, monit] }
|
|
153
|
-
S
|
|
154
|
-
end
|
|
155
|
-
git_commit 'Add the main playbook'
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def remove_unused_files_from_git
|
|
159
|
-
log_task __method__
|
|
160
|
-
|
|
161
|
-
git add: '-u'
|
|
162
|
-
git_commit 'Remove unused files'
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def log_complete
|
|
166
|
-
puts
|
|
167
|
-
say_status 'success', "\e[1m\Everything has been setup successfully\e[0m", :cyan
|
|
168
|
-
puts
|
|
169
|
-
say_status 'question', 'Are most of your apps similar?', :yellow
|
|
170
|
-
say_status 'answer', 'You only need to generate one playbook and you just did', :white
|
|
171
|
-
say_status 'answer', 'Use the inventory in each project to customize certain things', :white
|
|
172
|
-
puts
|
|
173
|
-
say_status 'question', 'Are you new to ansible?', :yellow
|
|
174
|
-
say_status 'answer', 'http://docs.ansible.com/intro_getting_started.html', :white
|
|
175
|
-
puts '-'*80
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
# ---
|
|
179
|
-
|
|
180
|
-
delete_generated_rails_code
|
|
181
|
-
add_playbook_directory
|
|
182
|
-
add_license
|
|
183
|
-
add_main_playbook
|
|
184
|
-
remove_unused_files_from_git
|
|
185
|
-
log_complete
|