smartmachine 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +661 -0
  3. data/README.md +147 -0
  4. data/bin/console +14 -0
  5. data/bin/setup +8 -0
  6. data/exe/smartmachine +3 -0
  7. data/lib/smart_machine/apps/app.rb +165 -181
  8. data/lib/smart_machine/apps/container.rb +120 -0
  9. data/lib/smart_machine/apps/manager.rb +182 -0
  10. data/lib/smart_machine/base.rb +24 -6
  11. data/lib/smart_machine/buildpackers/buildpacker.rb +95 -0
  12. data/lib/smart_machine/{engine/buildpacks → buildpackers}/rails/Dockerfile +3 -3
  13. data/lib/smart_machine/buildpackers/rails.rb +221 -0
  14. data/lib/smart_machine/commands/app.rb +112 -0
  15. data/lib/smart_machine/commands/buildpacker.rb +53 -0
  16. data/lib/smart_machine/commands/credentials.rb +17 -0
  17. data/lib/smart_machine/commands/docker.rb +23 -0
  18. data/lib/smart_machine/commands/engine.rb +27 -0
  19. data/lib/smart_machine/commands/grid.rb +33 -0
  20. data/lib/smart_machine/commands/grid_commands/elasticsearch.rb +68 -0
  21. data/lib/smart_machine/commands/grid_commands/minio.rb +65 -0
  22. data/lib/smart_machine/commands/grid_commands/mysql.rb +71 -0
  23. data/lib/smart_machine/commands/grid_commands/nginx.rb +53 -0
  24. data/lib/smart_machine/commands/grid_commands/prereceiver.rb +96 -0
  25. data/lib/smart_machine/commands/grid_commands/redis.rb +65 -0
  26. data/lib/smart_machine/commands/grid_commands/scheduler.rb +15 -0
  27. data/lib/smart_machine/commands/grid_commands/sub_thor.rb +15 -0
  28. data/lib/smart_machine/commands/machine.rb +24 -0
  29. data/lib/smart_machine/commands/syncer.rb +23 -0
  30. data/lib/smart_machine/commands/utilities.rb +37 -0
  31. data/lib/smart_machine/commands.rb +66 -0
  32. data/lib/smart_machine/configuration.rb +79 -0
  33. data/lib/smart_machine/credentials.rb +93 -95
  34. data/lib/smart_machine/docker.rb +144 -143
  35. data/lib/smart_machine/engine/Dockerfile +7 -5
  36. data/lib/smart_machine/engine.rb +104 -79
  37. data/lib/smart_machine/grids/elasticsearch.rb +70 -89
  38. data/lib/smart_machine/grids/minio.rb +79 -68
  39. data/lib/smart_machine/grids/mysql.rb +207 -202
  40. data/lib/smart_machine/grids/nginx.rb +176 -135
  41. data/lib/smart_machine/grids/prereceiver/Dockerfile +2 -2
  42. data/lib/smart_machine/grids/prereceiver/pre-receive +17 -0
  43. data/lib/smart_machine/grids/prereceiver.rb +169 -169
  44. data/lib/smart_machine/grids/redis.rb +73 -57
  45. data/lib/smart_machine/logger.rb +26 -26
  46. data/lib/smart_machine/machine.rb +128 -194
  47. data/lib/smart_machine/scp.rb +15 -0
  48. data/lib/smart_machine/ssh.rb +69 -40
  49. data/lib/smart_machine/syncer.rb +133 -0
  50. data/lib/smart_machine/templates/dotsmartmachine/Gemfile +7 -0
  51. data/lib/smart_machine/templates/dotsmartmachine/config/elasticsearch.yml +5 -0
  52. data/lib/smart_machine/templates/dotsmartmachine/config/environment.rb +0 -9
  53. data/lib/smart_machine/templates/dotsmartmachine/config/minio.yml +13 -0
  54. data/lib/smart_machine/templates/dotsmartmachine/config/mysql/schedule.rb +3 -3
  55. data/lib/smart_machine/templates/dotsmartmachine/config/mysql.yml +13 -0
  56. data/lib/smart_machine/templates/dotsmartmachine/config/prereceiver.yml +7 -0
  57. data/lib/smart_machine/templates/dotsmartmachine/config/redis.yml +13 -0
  58. data/lib/smart_machine/templates/dotsmartmachine/config/users.yml +1 -1
  59. data/lib/smart_machine/templates/dotsmartmachine/gitignore-template +47 -0
  60. data/lib/smart_machine/templates/dotsmartmachine/{grids/elasticsearch/data → vendor}/.keep +0 -0
  61. data/lib/smart_machine/version.rb +30 -6
  62. data/lib/smart_machine.rb +42 -16
  63. metadata +97 -47
  64. data/CHANGELOG.rdoc +0 -0
  65. data/MIT-LICENSE +0 -21
  66. data/README.rdoc +0 -87
  67. data/bin/buildpacker +0 -8
  68. data/bin/prereceiver +0 -8
  69. data/bin/scheduler +0 -18
  70. data/bin/smartmachine +0 -81
  71. data/bin/smartrunner +0 -33
  72. data/lib/smart_machine/apps/rails.rb +0 -250
  73. data/lib/smart_machine/apps.rb +0 -14
  74. data/lib/smart_machine/boot.rb +0 -32
  75. data/lib/smart_machine/buildpacker.rb +0 -106
  76. data/lib/smart_machine/gem_version.rb +0 -17
  77. data/lib/smart_machine/grids.rb +0 -18
  78. data/lib/smart_machine/sync.rb +0 -120
  79. data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/logs/.keep +0 -0
  80. data/lib/smart_machine/templates/dotsmartmachine/grids/minio/data/.keep +0 -0
  81. data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/backups/.keep +0 -0
  82. data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/data/.keep +0 -0
  83. data/lib/smart_machine/templates/dotsmartmachine/grids/prereceiver/pre-receive +0 -17
  84. data/lib/smart_machine/templates/dotsmartmachine/grids/redis/data/.keep +0 -0
  85. data/lib/smart_machine/user.rb +0 -38
@@ -1,197 +1,131 @@
1
1
  require "net/ssh"
2
2
 
3
- # The main SmartMachine Machine driver
4
3
  module SmartMachine
5
- class Machine < SmartMachine::Base
6
- def initialize
7
- end
8
-
9
- def create(*args)
10
- args.flatten!
11
-
12
- raise "Please specify a machine name" if args.empty?
13
-
14
- name = args.shift
15
- pathname = File.expand_path "./#{name}"
16
-
17
- self.setup_dotsmartmachine(pathname)
18
-
19
- puts "New machine #{name} has been created."
20
- end
21
-
22
- def init_local(*args)
23
- args.flatten!
24
-
25
- pathname = File.expand_path "~/.smartmachine"
26
-
27
- if args.delete("--force")
28
- puts "Removing all the data to reinitialize."
29
- FileUtils.rmtree(pathname)
30
- end
31
-
32
- if Dir.exist?(pathname)
33
- puts "SmartMachine Local already initialized. If you want to delete all the data and reinitialize, please use the --force option."
34
- return
35
- end
36
-
37
- self.setup_dotsmartmachine(pathname)
38
-
39
- puts "SmartMachine Local Initialised."
40
- end
41
-
42
- def installer(*args)
43
- args.flatten!
44
-
45
- action = args.shift
46
-
47
- if args.empty? || args.include?("docker")
48
- docker = SmartMachine::Docker.new
49
- docker.public_send(action)
50
- end
51
-
52
- if args.empty? || args.include?("engine")
53
- engine = SmartMachine::Engine.new
54
- engine.public_send(action)
55
- end
56
-
57
- if args.empty? || args.include?("buildpacker")
58
- buildpacker = SmartMachine::Buildpacker.new
59
- buildpacker.public_send(action)
60
- end
61
-
62
- if args.empty? || args.include?("prereceiver")
63
- prereceiver = SmartMachine::Grids::Prereceiver.new
64
- prereceiver.public_send(action)
65
- end
66
-
67
- if args.empty? || args.include?("scheduler")
68
- scheduler = SmartMachine::Grids::Scheduler.new
69
- scheduler.public_send(action)
70
- end
71
-
72
- if args.empty? || args.include?("elasticsearch")
73
- elasticsearch = SmartMachine::Grids::Elasticsearch.new
74
- elasticsearch.public_send(action)
75
- end
76
- end
77
-
78
- def grids(*args)
79
- args.flatten!
80
-
81
- if args.delete("--local")
82
- exec "smartmachine runner grids #{args.join(" ")}"
83
- else
84
- ssh = SmartMachine::SSH.new
85
- ssh.run "smartmachine runner grids #{args.join(" ")}"
86
- end
87
- end
88
-
89
- def apps(*args)
90
- args.flatten!
91
-
92
- if args.delete("--local")
93
- exec "smartmachine runner apps #{args.join(" ")}"
94
- else
95
- ssh = SmartMachine::SSH.new
96
- ssh.run "smartmachine runner apps #{args.join(" ")}"
97
- end
98
- end
99
-
100
- def ps(*args)
101
- args.flatten!
102
-
103
- if args.delete("--local")
104
- exec "docker ps #{args.join(' ')}"
105
- else
106
- ssh = SmartMachine::SSH.new
107
- ssh.run "docker ps #{args.join(' ')}"
108
- end
109
- end
110
-
111
- def logs(*args)
112
- args.flatten!
113
-
114
- if args.delete("--local")
115
- exec "docker logs #{args.join(' ')}"
116
- else
117
- ssh = SmartMachine::SSH.new
118
- ssh.run "docker logs #{args.join(' ')}"
119
- end
120
- end
121
-
122
- def ssh
123
- ssh = SmartMachine::SSH.new
124
- ssh.login
125
- end
126
-
127
- def getting_started
128
- # puts 'You may be prompted to make a menu selection when the Grub package is updated on Ubuntu. If prompted, select keep the local version currently installed.'
129
-
130
- # apt-get update && apt-get upgrade
131
-
132
- # hostnamectl set-hostname example_hostname
133
-
134
- # /etc/hosts
135
- # 127.0.0.1 localhost.localdomain localhost
136
- # 203.0.113.10 hostname.example.com hostname
137
- # 2600:3c01::a123:b456:c789:d012 hostname.example.com hostname
138
- # Add DNS records for IPv4 and IPv6 for ip addresses and their fully qualified domain names FQDN
139
-
140
- # dpkg-reconfigure tzdata
141
- # date
142
- end
143
-
144
- def securing_your_server
145
- # sudo apt install unattended-upgrades
146
-
147
- # sudo nano /etc/apt/apt.conf.d/20auto-upgrades
148
- # APT::Periodic::Update-Package-Lists "1";
149
- # APT::Periodic::Download-Upgradeable-Packages "1";
150
- # APT::Periodic::AutocleanInterval "7";
151
- # APT::Periodic::Unattended-Upgrade "1";
152
-
153
- # sudo apt install apticron
154
- # /etc/apticron/apticron.conf
155
- # EMAIL="root@example.com"
156
-
157
- # adduser example_user
158
- # adduser example_user sudo
159
-
160
- # mkdir -p ~/.ssh && sudo chmod -R 700 ~/.ssh/
161
- # scp ~/.ssh/id_rsa.pub example_user@203.0.113.10:~/.ssh/authorized_keys
162
- # sudo chmod -R 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
163
-
164
- # sudo nano /etc/ssh/sshd_config
165
- # PermitRootLogin no
166
- # PasswordAuthentication no
167
- # echo 'AddressFamily inet' | sudo tee -a /etc/ssh/sshd_config
168
- # sudo systemctl restart sshd
169
-
170
- # sudo apt-get update && sudo apt-get upgrade -y
171
- # sudo apt-get install fail2ban
172
- # sudo apt-get install sendmail
173
- # sudo ufw allow ssh
174
- # sudo ufw enable
175
- # sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
176
- # sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
177
- # Change destmail, sendername, sender
178
- # Change action = %(action_mwl)s
179
- # sudo fail2ban-client reload
180
- # sudo fail2ban-client status
181
- end
182
-
183
- def in_local_machine_dir?
184
- File.file?("./config/master.key")
185
- end
186
-
187
- def setup_dotsmartmachine(pathname)
188
- FileUtils.mkdir pathname
189
- FileUtils.cp_r "#{SmartMachine.config.root_path}/lib/smart_machine/templates/dotsmartmachine/.", pathname
190
- FileUtils.chdir pathname do
191
- credentials = SmartMachine::Credentials.new
192
- credentials.create
193
- system("git init && git add . && git commit -m 'initial commit'")
194
- end
195
- end
196
- end
197
- end
4
+ class Machine < SmartMachine::Base
5
+ def initialize
6
+ end
7
+
8
+ # Create a new smartmachine
9
+ #
10
+ # Example:
11
+ # >> Machine.create("qw21334q")
12
+ # => "New machine qw21334q has been created."
13
+ #
14
+ # Arguments:
15
+ # name: (String)
16
+ # dev: (Boolean)
17
+ def create(name:, dev:)
18
+ raise "Please specify a machine name" if name.blank?
19
+
20
+ pathname = File.expand_path "./#{name}"
21
+
22
+ if Dir.exist?(pathname)
23
+ puts "A machine with this name already exists. Please use a different name."
24
+ return
25
+ end
26
+
27
+ FileUtils.mkdir pathname
28
+ FileUtils.cp_r "#{SmartMachine.config.gem_dir}/lib/smart_machine/templates/dotsmartmachine/.", pathname
29
+ FileUtils.chdir pathname do
30
+ credentials = SmartMachine::Credentials.new
31
+ credentials.create
32
+
33
+ File.write("Gemfile", File.open("Gemfile",&:read).gsub("replace_ruby_version", "#{SmartMachine.ruby_version}"))
34
+ File.write(".ruby-version", SmartMachine.ruby_version)
35
+ if dev
36
+ File.write("Gemfile", File.open("Gemfile",&:read).gsub("\"~> replace_smartmachine_version\"", "path: \"../\""))
37
+ else
38
+ File.write("Gemfile", File.open("Gemfile",&:read).gsub("replace_smartmachine_version", "#{SmartMachine.version}"))
39
+ end
40
+ system("mv gitignore-template .gitignore")
41
+
42
+ # Here BUNDLE_GEMFILE is needed as it may be already set due to usage of bundle exec (which may not be correct in this case)
43
+ bundle_gemfile = "#{pathname}/Gemfile"
44
+ system("BUNDLE_GEMFILE='#{bundle_gemfile}' bundle install && BUNDLE_GEMFILE='#{bundle_gemfile}' bundle binstubs smartmachine")
45
+
46
+ system("git init && git add . && git commit -m 'initial commit by SmartMachine #{SmartMachine.version}'")
47
+ end
48
+
49
+ puts "New machine #{name} has been created."
50
+ end
51
+
52
+ def initial_setup
53
+ getting_started
54
+ securing_your_server
55
+ end
56
+
57
+ def run_on_machine(commands:)
58
+ commands = Array(commands).flatten
59
+ ssh = SmartMachine::SSH.new
60
+ status = ssh.run commands
61
+
62
+ status[:exit_code] == 0
63
+ end
64
+
65
+ private
66
+
67
+ def getting_started
68
+ # apt install locales-all
69
+
70
+ # puts 'You may be prompted to make a menu selection when the Grub package is updated on Ubuntu. If prompted, select keep the local version currently installed.'
71
+ # apt update && apt upgrade
72
+
73
+ # hostnamectl set-hostname SmartMachine.credentials.machine[:name]
74
+
75
+ # The value you assign as your system’s FQDN should have an “A” record in DNS pointing to your Linode’s IPv4 address. For IPv6, you should also set up a DNS “AAAA” record pointing to your Linode’s IPv6 address.
76
+ # Add DNS records for IPv4 and IPv6 for ip addresses and their fully qualified domain names FQDN
77
+ # /etc/hosts
78
+ # 203.0.113.10 SmartMachine.credentials.machine[:name].example.com SmartMachine.credentials.machine[:name]
79
+ # 2600:3c01::a123:b456:c789:d012 SmartMachine.credentials.machine[:name].example.com SmartMachine.credentials.machine[:name]
80
+
81
+ # dpkg-reconfigure tzdata
82
+ # date
83
+ end
84
+
85
+ def securing_your_server
86
+ # apt install unattended-upgrades
87
+ # dpkg-reconfigure --priority=low unattended-upgrades
88
+
89
+ # nano /etc/apt/apt.conf.d/20auto-upgrades
90
+ # APT::Periodic::Update-Package-Lists "1";
91
+ # APT::Periodic::Download-Upgradeable-Packages "1";
92
+ # APT::Periodic::AutocleanInterval "7";
93
+ # APT::Periodic::Unattended-Upgrade "1";
94
+
95
+ # apt install apticron
96
+ # /usr/lib/apticron/apticron.conf
97
+ # EMAIL="root@example.com"
98
+
99
+ # adduser example_user
100
+ # adduser example_user sudo
101
+
102
+ # mkdir -p ~/.ssh && sudo chmod -R 700 ~/.ssh/
103
+ # scp ~/.ssh/id_rsa.pub example_user@203.0.113.10:~/.ssh/authorized_keys
104
+ # sudo chmod -R 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
105
+
106
+ # sudo nano /etc/ssh/sshd_config
107
+ # PermitRootLogin no
108
+ # PasswordAuthentication no
109
+ # echo 'AddressFamily inet' | sudo tee -a /etc/ssh/sshd_config
110
+ # sudo systemctl restart sshd
111
+
112
+ # sudo apt update && sudo apt upgrade -y
113
+
114
+ # sudo apt install ufw
115
+ # sudo ufw default allow outgoing
116
+ # sudo ufw default deny incoming
117
+ # sudo ufw allow SmartMachine.credentials.machine[:port]/tcp
118
+ # sudo ufw enable
119
+ # sudo ufw logging on
120
+
121
+ # sudo apt install fail2ban
122
+ # sudo apt install sendmail
123
+ # sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
124
+ # sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
125
+ # Change destmail, sendername, sender
126
+ # Change action = %(action_mwl)s
127
+ # sudo fail2ban-client reload
128
+ # sudo fail2ban-client status
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,15 @@
1
+ module SmartMachine
2
+ class SCP < SmartMachine::Base
3
+ def initialize
4
+ @address = SmartMachine.credentials.machine[:address]
5
+ @port = SmartMachine.credentials.machine[:port]
6
+ @username = SmartMachine.credentials.machine[:username]
7
+ @password = SmartMachine.credentials.machine[:password]
8
+ end
9
+
10
+ def upload!(local_path:, remote_path:)
11
+ system("scp -q -P #{@port} #{local_path} #{@username}@#{@address}:#{remote_path}")
12
+ $?
13
+ end
14
+ end
15
+ end
@@ -1,43 +1,72 @@
1
1
  require "net/ssh"
2
2
 
3
- # The main SmartMachine SSH driver
4
3
  module SmartMachine
5
- class SSH < SmartMachine::Base
6
- def initialize
7
- end
8
-
9
- def run(*commands)
10
- commands.flatten!
11
- Net::SSH.start(SmartMachine.credentials.machine[:address], SmartMachine.credentials.machine[:username], { port: SmartMachine.credentials.machine[:port], password: SmartMachine.credentials.machine[:password] }) do |ssh|
12
- channel = ssh.open_channel do |channel, success|
13
- channel.request_pty do |channel, success|
14
- channel.exec commands.join(';') do |channel, success|
15
- raise "Could not execute command" unless success
16
-
17
- channel.on_data do |channel, data|
18
- $stdout.print data
19
-
20
- if data =~ /^\[sudo\] password for /
21
- channel.send_data "#{SmartMachine.credentials.machine[:password]}\n"
22
- end
23
- end
24
-
25
- channel.on_extended_data do |channel, type, data|
26
- $stderr.print data
27
- end
28
-
29
- channel.on_close do |channel|
30
- # puts "done!"
31
- end
32
- end
33
- end
34
- end
35
- channel.wait
36
- end
37
- end
38
-
39
- def login
40
- exec "ssh #{SmartMachine.credentials.machine[:username]}@#{SmartMachine.credentials.machine[:address]}"
41
- end
42
- end
43
- end
4
+ class SSH < SmartMachine::Base
5
+ def initialize
6
+ end
7
+
8
+ def run(*commands)
9
+ commands.flatten!
10
+ status = {}
11
+
12
+ Net::SSH.start(SmartMachine.credentials.machine[:address], SmartMachine.credentials.machine[:username], { port: SmartMachine.credentials.machine[:port], password: SmartMachine.credentials.machine[:password] }) do |ssh|
13
+ commands.each do |command|
14
+
15
+ puts "\e[1m" + "$ " + command + "\e[0m"
16
+
17
+ channel = ssh.open_channel do |channel|
18
+
19
+ channel.on_open_failed do |channel, code, description|
20
+ raise "could not open channel (#{description}, ##{code})"
21
+ end
22
+
23
+ ssh.listen_to(STDIN) do |stdin|
24
+ input = stdin.readpartial(1024)
25
+ channel.send_data(input) unless input.empty?
26
+ end
27
+
28
+ channel.request_pty :modes => { Net::SSH::Connection::Term::ECHO => 0 } do |channel, success|
29
+ raise "could not obtain pty" unless success
30
+
31
+ channel.exec command do |channel, success|
32
+ raise "could not execute command: #{command.inspect}" unless success
33
+
34
+ if status
35
+ channel.on_request("exit-status") do |ch2, data|
36
+ status[:exit_code] = data.read_long
37
+ end
38
+
39
+ channel.on_request("exit-signal") do |ch2, data|
40
+ status[:exit_signal] = data.read_long
41
+ end
42
+ end
43
+
44
+ channel.on_data do |ch2, data|
45
+ $stdout.print data
46
+
47
+ if (data[/\[sudo\]|Password/i])
48
+ channel.send_data "#{SmartMachine.credentials.machine[:password]}\n"
49
+ end
50
+ end
51
+
52
+ channel.on_extended_data do |ch2, type, data|
53
+ $stderr.print data
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ channel.wait
60
+
61
+ break if status[:exit_code] != 0
62
+ end
63
+ end
64
+
65
+ status
66
+ end
67
+
68
+ def login
69
+ exec "ssh -p #{SmartMachine.credentials.machine[:port]} #{SmartMachine.credentials.machine[:username]}@#{SmartMachine.credentials.machine[:address]}"
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,133 @@
1
+ module SmartMachine
2
+ class Syncer < SmartMachine::Base
3
+ def initialize
4
+ end
5
+
6
+ def sync(initial: false)
7
+ puts "-----> Syncing SmartMachine"
8
+
9
+ push if initial
10
+
11
+ pull
12
+ push
13
+
14
+ puts "-----> Syncing SmartMachine Complete"
15
+ end
16
+
17
+ def rsync(*args)
18
+ exec "rsync #{args.join(' ')}"
19
+ end
20
+
21
+ private
22
+
23
+ def pull
24
+ puts "-----> Syncer pulling ... "
25
+ if system("#{rsync_command(pull_files_list)} #{SmartMachine.credentials.machine[:username]}@#{SmartMachine.credentials.machine[:address]}:~/machine/ .")
26
+ puts "done"
27
+ else
28
+ raise "Syncer error while pulling..."
29
+ end
30
+ end
31
+
32
+ def push
33
+ puts "-----> Syncer pushing ... "
34
+ if system("#{rsync_command(push_files_list)} ./ #{SmartMachine.credentials.machine[:username]}@#{SmartMachine.credentials.machine[:address]}:~/machine")
35
+ puts "done"
36
+ else
37
+ raise "Syncer error while pushing..."
38
+ end
39
+ end
40
+
41
+ def rsync_command(files_list)
42
+ command = [
43
+ "rsync -azumv",
44
+ "-e 'ssh -p #{SmartMachine.credentials.machine[:port]}'",
45
+ "--rsync-path='smartengine syncer rsync'",
46
+ "--delete",
47
+ "--include={#{files_list}}",
48
+ "--exclude=*"
49
+ ]
50
+
51
+ command.join(" ")
52
+ end
53
+
54
+ def pull_files_list
55
+ files = [
56
+ 'apps/***',
57
+
58
+ 'bin/***',
59
+
60
+ 'grids',
61
+
62
+ 'grids/elasticsearch',
63
+ 'grids/elasticsearch/***',
64
+
65
+ 'grids/minio',
66
+ 'grids/minio/***',
67
+
68
+ 'grids/mysql',
69
+ 'grids/mysql/***',
70
+
71
+ 'grids/nginx',
72
+ 'grids/nginx/certificates/***',
73
+
74
+ 'grids/prereceiver',
75
+ 'grids/prereceiver/***',
76
+
77
+ 'grids/redis',
78
+ 'grids/redis/***',
79
+
80
+ 'grids/scheduler',
81
+ 'grids/scheduler/crontabs/***',
82
+
83
+ 'grids/solr',
84
+ 'grids/solr/solr/***',
85
+ ]
86
+ files.join(',')
87
+ end
88
+
89
+ def push_files_list
90
+ files = [
91
+ 'apps',
92
+ 'apps/containers',
93
+ 'apps/containers/.keep',
94
+ 'apps/repositories',
95
+ 'apps/repositories/.keep',
96
+
97
+ 'bin',
98
+ 'bin/smartmachine',
99
+
100
+ 'config',
101
+ 'config/mysql',
102
+ 'config/mysql/schedule.rb',
103
+ 'config/credentials.yml.enc',
104
+ 'config/environment.rb',
105
+ 'config/elasticsearch.yml',
106
+ 'config/minio.yml',
107
+ 'config/mysql.yml',
108
+ 'config/prereceiver.yml',
109
+ 'config/redis.yml',
110
+
111
+ 'grids',
112
+
113
+ 'grids/nginx',
114
+ 'grids/nginx/certificates',
115
+ 'grids/nginx/certificates/.keep',
116
+ 'grids/nginx/htpasswd/***',
117
+ 'grids/nginx/fastcgi.conf',
118
+ 'grids/nginx/nginx.tmpl',
119
+
120
+ 'grids/scheduler',
121
+ 'grids/scheduler/crontabs',
122
+ 'grids/scheduler/crontabs/.keep',
123
+
124
+ 'grids/solr',
125
+ 'grids/solr/solr',
126
+ 'grids/solr/solr/.keep',
127
+
128
+ 'tmp/***',
129
+ ]
130
+ files.join(',')
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby 'replace_ruby_version'
5
+
6
+ # SmartMachine
7
+ gem 'smartmachine', "~> replace_smartmachine_version"
@@ -0,0 +1,5 @@
1
+ elasticsearchone:
2
+ port: 9200
3
+
4
+ # elasticsearchtwo:
5
+ # port: 9201
@@ -1,18 +1,9 @@
1
1
  # => NOTE: Ensure that the specified top-level domains are pointing to this server ip address using DNS records.
2
2
  # => Be sure to restart your server when you modify this file.
3
3
 
4
- # Top-level naked domain to be used for subdomains of apps.
5
- SmartMachine.config.apps_domain = "yourdomain.com"
6
-
7
- # domain to be used for git prereceiver
8
- SmartMachine.config.git_domain = "git.yourdomain.com"
9
-
10
4
  # Sysadmin email id.
11
5
  SmartMachine.config.sysadmin_email = "admin@yourdomain.com"
12
6
 
13
- # letsencrypt test boolean to be used
14
- SmartMachine.config.letsencrypt_test = false
15
-
16
7
  # logger level
17
8
  # DEBUG, INFO, WARN, ERROR, FATAL, UNKNOWN
18
9
  SmartMachine.config.logger_level = "INFO"
@@ -0,0 +1,13 @@
1
+ minioone:
2
+ host: "yourminioone.yourdomain.com"
3
+ access_key: <%= SmartMachine.credentials.dig(:minioone, :access_key) %>
4
+ secret_key: <%= SmartMachine.credentials.dig(:minioone, :secret_key) %>
5
+ browser: on
6
+ worm: off
7
+
8
+ # miniotwo:
9
+ # host: "yourminiotwo.yourdomain.com"
10
+ # access_key: <%= SmartMachine.credentials.dig(:miniotwo, :access_key) %>
11
+ # secret_key: <%= SmartMachine.credentials.dig(:miniotwo, :secret_key) %>
12
+ # browser: on
13
+ # worm: off
@@ -3,17 +3,17 @@
3
3
 
4
4
  # Flush logs used to create consistent binlogs to be used for incremental backups
5
5
  every :day, at: '12:00 pm' do
6
- command "smartmachine runner grids mysql flushlogs"
6
+ command "smartmachine runner grids mysql flushlogs"
7
7
  end
8
8
 
9
9
  # Create daily backup.
10
10
  # This also flushes the logs before backup
11
11
  every :day, at: '12:00 am' do
12
- command "smartmachine runner grids mysql backup --daily"
12
+ command "smartmachine runner grids mysql backup --daily"
13
13
  end
14
14
 
15
15
  # Promote currently latest daily backup to weekly backup.
16
16
  # This is only possible when a daily backup creation has already been completed.
17
17
  every :monday, at: '3:00 am' do
18
- command "smartmachine runner grids mysql backup --promote-to-weekly"
18
+ command "smartmachine runner grids mysql backup --promote-to-weekly"
19
19
  end