zauberware-devops 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +13 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +125 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/zauberware/devops/capistrano/v3/tasks/backup.rake +29 -0
- data/lib/zauberware/devops/capistrano/v3/tasks/figaro_yml.rake +78 -0
- data/lib/zauberware/devops/capistrano/v3/tasks/invoke.rake +24 -0
- data/lib/zauberware/devops/capistrano/v3/tasks/logs.rake +16 -0
- data/lib/zauberware/devops/capistrano/v3/tasks/whenever.rake +12 -0
- data/lib/zauberware/devops/capistrano.rb +13 -0
- data/lib/zauberware/devops/railtie.rb +15 -0
- data/lib/zauberware/devops/tasks/pg/dump.rake +68 -0
- data/lib/zauberware/devops/tasks/pg/remove_old_dumps.rake +19 -0
- data/lib/zauberware/devops/version.rb +6 -0
- data/lib/zauberware/devops.rb +21 -0
- data/zauberware-devops.gemspec +24 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 06e76ef48ec28db7e06e1b00fda968e2e4fec43b407796be19077bf47f9fb228
|
4
|
+
data.tar.gz: 599ceabd442cdf60dad419d9567ab689e8d883c1288f53e81c1d75f197487e1a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdf635c7efff594ac64211bf6981553462337fdc235602e36779938f89e93f9669e2a16d6821b869ba05b3b4bf0fe3197d85014689f110a1bd997dafa792b210
|
7
|
+
data.tar.gz: eab9bdc31bd4f6aaa206ae93b96359c391b1cff1bb79bf3c3d63426c2af848d5791b65af2de261223f29720464c2f954abb2fc3f8ce509ab5296f2f82e59a61b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Sheharyar Naseer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# zauberware-devops
|
2
|
+
|
3
|
+
Library of useful scripts for DevOps using capistrano with rails.
|
4
|
+
|
5
|
+
**Only supports Capistrano 3 and above**.
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
'capistrano', '~> 3.0'
|
11
|
+
'whenever'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add the gem to your `Gemfile` after setting up Capistrano
|
17
|
+
group:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
group :development do
|
21
|
+
gem 'capistrano', require: false
|
22
|
+
end
|
23
|
+
|
24
|
+
gem 'zauberware-devops'
|
25
|
+
```
|
26
|
+
|
27
|
+
Then `bundle` and add it to your `Capfile`
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# Capfile
|
31
|
+
|
32
|
+
require 'zauberware/devops/capistrano'
|
33
|
+
```
|
34
|
+
|
35
|
+
and `initializers`
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
# initializers/zauberware_devops.rb
|
39
|
+
require 'zauberware/devops'
|
40
|
+
```
|
41
|
+
|
42
|
+
## Script overview
|
43
|
+
|
44
|
+
| Script | Description |
|
45
|
+
| ------------------------------------------------ | ----------------------------------------------------------------- |
|
46
|
+
| `cap <environment> backup:create` | creates backup of postgres database on the server |
|
47
|
+
| `cap <environment> backup:pull` | download latest postgres backup from server |
|
48
|
+
| `cap <environment> figaro_yml:compare` | compare local application.yml with server application.yml |
|
49
|
+
| `cap <environment> figaro_yml:get` | shows env vars from server application.yml configured thru figaro |
|
50
|
+
| `cap <environment> logs:rails` | display server log live |
|
51
|
+
| `cap <environment> whenever:show_crontab` | display server app crontab generated with whenever |
|
52
|
+
| `cap <environment> invoke:rake TASK=<your:task>` | invoke rake task on server |
|
53
|
+
| `rake pg:dump` | creates postgres database backup |
|
54
|
+
| `rake pg:remove_old_dumps` | remove old postgres backups |
|
55
|
+
|
56
|
+
## Usage
|
57
|
+
|
58
|
+
for all backup task you have to setup your database.yml properly:
|
59
|
+
|
60
|
+
```
|
61
|
+
production:
|
62
|
+
|
63
|
+
database: database_name
|
64
|
+
username: database_username
|
65
|
+
password: database_password
|
66
|
+
host: database_host
|
67
|
+
port: database_port
|
68
|
+
```
|
69
|
+
|
70
|
+
### Optional Settings for backup task
|
71
|
+
|
72
|
+
| env | description |
|
73
|
+
| ----------------- | ----------------------------------- |
|
74
|
+
| NUMBER_OF_BACKUPS | number of backups to keep |
|
75
|
+
| BACKUPS_ENABLED | enable/disable backup task |
|
76
|
+
| DEFAULT_URL | for slack integration message title |
|
77
|
+
| SLACK_SECRET | for slack integration |
|
78
|
+
| SLACK_CHANNEL | for slack integration |
|
79
|
+
|
80
|
+
### use with whenever/capistrano
|
81
|
+
|
82
|
+
install whenever gem and add this to your schedule.rb
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
# config/schedule.rb
|
86
|
+
# Use this file to easily define all of your cron jobs.
|
87
|
+
env :PATH, ENV['PATH']
|
88
|
+
set :output, -> { '2>&1 | logger -t whenever_cron' }
|
89
|
+
|
90
|
+
every :day, at: '2:00 am' do
|
91
|
+
rake 'pg:dump'
|
92
|
+
end
|
93
|
+
|
94
|
+
every :day, at: '3:00 am' do
|
95
|
+
rake 'pg:remove_old_dumps'
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
add this to your capfile
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
# Capfile
|
103
|
+
require 'whenever/capistrano'
|
104
|
+
```
|
105
|
+
|
106
|
+
## Configuration
|
107
|
+
|
108
|
+
You can optionally specify the capistrano roles for the rake task (Defaults to `:app`):
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
# Defaults to [:app]
|
112
|
+
set :rake_roles, %i[db app]
|
113
|
+
```
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
1. Fork it ( https://github.com/zauberware/zauberware-devops/fork )
|
118
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
119
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
120
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
121
|
+
5. Create a new Pull Request
|
122
|
+
|
123
|
+
## License
|
124
|
+
|
125
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'capistrano/rake'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :backup do
|
4
|
+
# Default to :app role
|
5
|
+
rake_roles = fetch(:rake_roles, :app)
|
6
|
+
|
7
|
+
desc 'create a backup of the server database'
|
8
|
+
task :create do
|
9
|
+
on roles(rake_roles) do
|
10
|
+
env = "RAILS_ENV=#{fetch(:stage)}"
|
11
|
+
# rubocop:disable Layout/LineLength
|
12
|
+
path_cmd = "PATH=$HOME/.rbenv/versions/#{RUBY_VERSION}/bin:$PATH"
|
13
|
+
# rubocop:enable Layout/LineLength
|
14
|
+
execute "cd #{release_path} && #{path_cmd} && #{env} BACKUPS_ENABLED=true bundle exec rake pg:dump"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
desc 'pull latest database backups from server to local'
|
18
|
+
task :pull do
|
19
|
+
on roles(rake_roles) do
|
20
|
+
# rubocop:disable Layout/LineLength
|
21
|
+
execute "cd #{shared_path}/backups && tar -czf #{shared_path}/backups.tar.gz $(ls -lt | grep -E -i '.{0,}\.dump' | head -n 1 | awk '{print $9}')"
|
22
|
+
# rubocop:enable Layout/LineLength
|
23
|
+
download! "#{shared_path}/backups.tar.gz", 'backups.tar.gz'
|
24
|
+
execute "rm #{shared_path}/backups.tar.gz"
|
25
|
+
system 'tar -xzf backups.tar.gz'
|
26
|
+
system 'rm backups.tar.gz'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/BlockLength
|
4
|
+
namespace :figaro_yml do
|
5
|
+
# Defaults to :app role
|
6
|
+
rake_roles = fetch(:rake_roles, :app)
|
7
|
+
|
8
|
+
desc 'get the figaro_yml file from the server'
|
9
|
+
task :get do
|
10
|
+
on roles(rake_roles) do
|
11
|
+
puts capture "cat #{shared_path}/config/application.yml"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
task :compare do
|
16
|
+
env = fetch(:stage)
|
17
|
+
# read local application.yml
|
18
|
+
local = File.read('config/application.yml')
|
19
|
+
|
20
|
+
# convert to hash
|
21
|
+
local_global_env = YAML.safe_load(local)
|
22
|
+
|
23
|
+
# split into stage and global
|
24
|
+
local_stage_env = local_global_env[env.to_s]
|
25
|
+
local_global_env.delete('staging')
|
26
|
+
local_global_env.delete('production')
|
27
|
+
|
28
|
+
on roles(rake_roles) do
|
29
|
+
# read remote application.yml
|
30
|
+
remote = capture("cat #{shared_path}/config/application.yml")
|
31
|
+
|
32
|
+
remote_global_env = YAML.safe_load(remote)
|
33
|
+
remote_stage_env = remote_global_env[env.to_s]
|
34
|
+
remote_global_env.delete(env.to_s)
|
35
|
+
|
36
|
+
puts "with command 'cap #{env} figaro_yml:setup', following variables will be overwritten:"
|
37
|
+
puts '--------------------------------------------------------------------------------'
|
38
|
+
result1 = compare_hashes(local_global_env, remote_global_env)
|
39
|
+
result2 = compare_hashes(local_stage_env, remote_stage_env)
|
40
|
+
if !result1.empty? || !result2.empty?
|
41
|
+
loop do
|
42
|
+
print 'Update remote application.yml? (y/N): '
|
43
|
+
input = $stdin.gets.strip.downcase
|
44
|
+
answer = (input.empty? ? 'N' : input).downcase.to_s
|
45
|
+
|
46
|
+
next unless %w(y n).include?(answer)
|
47
|
+
|
48
|
+
if answer == 'y'
|
49
|
+
puts 'Updating remote application.yml'
|
50
|
+
invoke 'figaro_yml:setup'
|
51
|
+
exit
|
52
|
+
end
|
53
|
+
break
|
54
|
+
end
|
55
|
+
puts 'remote application.yml not updated'
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
puts 'remote application.yml is up to date'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
def compare_hashes(hash1, hash2)
|
62
|
+
changes = false
|
63
|
+
local_server = hash1.to_a - hash2.to_a
|
64
|
+
server_local = hash2.to_a - hash1.to_a
|
65
|
+
|
66
|
+
[local_server + server_local].flatten(1).to_h.keys.each do |k|
|
67
|
+
new_value = hash1[k].to_s
|
68
|
+
new_value = new_value.empty? ? "nil" : new_value
|
69
|
+
old_value = hash2[k].to_s
|
70
|
+
old_value = old_value.empty? ? "nil" : old_value
|
71
|
+
if old_value != new_value
|
72
|
+
puts "#{k}: #{old_value} => #{new_value} \r\n"
|
73
|
+
changes = true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :invoke do
|
2
|
+
|
3
|
+
# Defalut to :app roles
|
4
|
+
rake_roles = fetch(:rake_roles, :app)
|
5
|
+
|
6
|
+
desc "Execute a rake task on a remote server (cap invoke:rake TASK=db:migrate)"
|
7
|
+
task :rake do
|
8
|
+
if ENV['TASK']
|
9
|
+
on roles(rake_roles) do
|
10
|
+
within current_path do
|
11
|
+
with rails_env: fetch(:rails_env) do
|
12
|
+
execute :rake, ENV['TASK']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
else
|
18
|
+
puts "\n\nFailed! You need to specify the 'TASK' parameter!",
|
19
|
+
"Usage: cap <stage> invoke:rake TASK=your:task"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :logs do
|
4
|
+
# Default to :app role
|
5
|
+
rake_roles = fetch(:rake_roles, :app)
|
6
|
+
desc 'tail rails logs'
|
7
|
+
task :rails do
|
8
|
+
on roles(rake_roles) do
|
9
|
+
trap('SIGINT') do
|
10
|
+
puts "\nDisconnecting..."
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capistrano/version'
|
4
|
+
|
5
|
+
if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION).release >= Gem::Version.new('3.0.0')
|
6
|
+
load File.expand_path('capistrano/v3/tasks/whenever.rake', __dir__)
|
7
|
+
load File.expand_path('capistrano/v3/tasks/backup.rake', __dir__)
|
8
|
+
load File.expand_path('capistrano/v3/tasks/figaro_yml.rake', __dir__)
|
9
|
+
load File.expand_path('capistrano/v3/tasks/logs.rake', __dir__)
|
10
|
+
load File.expand_path('capistrano/v3/tasks/invoke.rake', __dir__)
|
11
|
+
else
|
12
|
+
puts 'Capistrano 3 is required to use this gem'
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'zauberware/devops'
|
4
|
+
require 'rails'
|
5
|
+
module Zauberware
|
6
|
+
module DevOps
|
7
|
+
class Railtie < Rails::Railtie
|
8
|
+
railtie_name :devops
|
9
|
+
rake_tasks do
|
10
|
+
path = File.expand_path(__dir__)
|
11
|
+
Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/BlockLength
|
4
|
+
namespace :pg do
|
5
|
+
default_backup_path = Rails.env.development? ? 'tmp/backups' : '../../shared/backups'
|
6
|
+
database = Rails.configuration.database_configuration[Rails.env]['database']
|
7
|
+
username = Rails.configuration.database_configuration[Rails.env]['username']
|
8
|
+
password = Rails.configuration.database_configuration[Rails.env]['password']
|
9
|
+
hostname = Rails.configuration.database_configuration[Rails.env]['host']
|
10
|
+
portnumber = Rails.configuration.database_configuration[Rails.env]['port']
|
11
|
+
backup_path = Rails.root.join(default_backup_path).to_s
|
12
|
+
backups_enabled = Rails.env.production? || ENV['BACKUPS_ENABLED'] == 'true'
|
13
|
+
|
14
|
+
task :dump do
|
15
|
+
date = Time.now.to_i
|
16
|
+
user = username.present? ? " -U #{username}" : ''
|
17
|
+
host = hostname.present? ? " -h #{hostname}" : ''
|
18
|
+
port = portnumber.present? ? " -p #{portnumber}" : ''
|
19
|
+
# rubocop:disable Layout/LineLength
|
20
|
+
dump_cmd = "export PGPASSWORD='#{password}' && cd #{backup_path} && pg_dump -d #{database}#{user}#{host}#{port} > #{database}_#{date}.dump"
|
21
|
+
# rubocop:enable Layout/LineLength
|
22
|
+
if backups_enabled
|
23
|
+
system "mkdir -p #{backup_path}" unless Dir.exist?(backup_path)
|
24
|
+
result = system(dump_cmd)
|
25
|
+
slack_notification(result, date, database, backup_path)
|
26
|
+
end
|
27
|
+
if backups_enabled
|
28
|
+
# rubocop:disable Layout/LineLength
|
29
|
+
p result ? "Backup created: #{backup_path}/#{database}_#{date}.dump" : "Backup failed, created empty file at #{backup_path}/#{database}_#{date}.dump"
|
30
|
+
# rubocop:enable Layout/LineLength
|
31
|
+
else
|
32
|
+
p 'dump: Backups are disabled'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
# rubocop:disable Metrics/MethodLength
|
36
|
+
def slack_notification(result, date, database, backup_path)
|
37
|
+
return unless ENV['SLACK_SECRET'].present? && ENV['SLACK_CHANNEL'].present?
|
38
|
+
|
39
|
+
message_one = "Backup of #{database} successfully finished at #{Time.now}"
|
40
|
+
message_two = "Backup path:\`#{backup_path}/#{database}_#{date}.dump\`"
|
41
|
+
data = {
|
42
|
+
channel: ENV['SLACK_CHANNEL'],
|
43
|
+
blocks: [
|
44
|
+
{
|
45
|
+
type: 'header',
|
46
|
+
text: {
|
47
|
+
type: 'plain_text',
|
48
|
+
text: ENV['DEFAULT_URL'] || "#{database} Backup",
|
49
|
+
emoji: true
|
50
|
+
}
|
51
|
+
},
|
52
|
+
{
|
53
|
+
type: 'section',
|
54
|
+
text: {
|
55
|
+
type: 'mrkdwn',
|
56
|
+
text: result ? "#{message_one}\n#{message_two}" : "Backup of #{database} failed at #{Time.now}"
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
# rubocop:disable Layout/LineLength
|
62
|
+
curl = "curl -X POST https://slack.com/api/chat.postMessage -H 'Content-type: application/json; charset=utf-8' --data '#{data.to_json}' -H 'Authorization: Bearer #{ENV['SLACK_SECRET']}'"
|
63
|
+
# rubocop:enable Layout/LineLength
|
64
|
+
system curl
|
65
|
+
end
|
66
|
+
# rubocop:enable Metrics/MethodLength
|
67
|
+
end
|
68
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :pg do
|
4
|
+
default_backup_path = Rails.env.development? ? 'tmp/backups' : '../../shared/backups'
|
5
|
+
database = Rails.configuration.database_configuration[Rails.env]['database']
|
6
|
+
|
7
|
+
backup_path = Rails.root.join(default_backup_path).to_s
|
8
|
+
backups_enabled = Rails.env.production? || ENV['BACKUPS_ENABLED'] == 'true'
|
9
|
+
|
10
|
+
task :remove_old_dumps do
|
11
|
+
bash_regex = "'#{database}.{0,}\.dump'"
|
12
|
+
total_backups_no = ENV['NUMBER_OF_BACKUPS'] || 1
|
13
|
+
# rubocop:disable Layout/LineLength
|
14
|
+
cmd = "cd #{backup_path} && ls -lt | grep -E -i #{bash_regex} | tail -n +#{total_backups_no.to_i + 1} | awk '{print $9}'|xargs rm -rf"
|
15
|
+
# rubocop:enable Layout/LineLength
|
16
|
+
system(cmd) if backups_enabled
|
17
|
+
p backups_enabled ? 'Old backups removed' : 'remove_old_dumps: Backups are disabled'
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Zauberware
|
2
|
+
module DevOps
|
3
|
+
require 'zauberware/devops/railtie' if defined?(Rails)
|
4
|
+
|
5
|
+
def self.path
|
6
|
+
Dir.pwd
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.bin_rails?
|
10
|
+
File.exist?(File.join(path, 'bin', 'rails'))
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.script_rails?
|
14
|
+
File.exist?(File.join(path, 'script', 'rails'))
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.bundler?
|
18
|
+
File.exist?(File.join(path, 'Gemfile'))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
|
5
|
+
require 'zauberware/devops/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'zauberware-devops'
|
9
|
+
s.version = Zauberware::DevOps::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ['Florian Crusius']
|
12
|
+
s.email = ['florian@zauberware.com']
|
13
|
+
s.license = 'MIT'
|
14
|
+
s.homepage = 'https://github.com/zauberware/zauberware-devops'
|
15
|
+
s.summary = 'devops tasks for rails applications'
|
16
|
+
s.description = 'A collection of devops tasks for rails applications'
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- test/{functional,unit}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
|
22
|
+
s.add_development_dependency 'bundler', '~> 1.11'
|
23
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zauberware-devops
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Florian Crusius
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A collection of devops tasks for rails applications
|
42
|
+
email:
|
43
|
+
- florian@zauberware.com
|
44
|
+
executables:
|
45
|
+
- console
|
46
|
+
- setup
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- ".travis.yml"
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- lib/zauberware/devops.rb
|
59
|
+
- lib/zauberware/devops/capistrano.rb
|
60
|
+
- lib/zauberware/devops/capistrano/v3/tasks/backup.rake
|
61
|
+
- lib/zauberware/devops/capistrano/v3/tasks/figaro_yml.rake
|
62
|
+
- lib/zauberware/devops/capistrano/v3/tasks/invoke.rake
|
63
|
+
- lib/zauberware/devops/capistrano/v3/tasks/logs.rake
|
64
|
+
- lib/zauberware/devops/capistrano/v3/tasks/whenever.rake
|
65
|
+
- lib/zauberware/devops/railtie.rb
|
66
|
+
- lib/zauberware/devops/tasks/pg/dump.rake
|
67
|
+
- lib/zauberware/devops/tasks/pg/remove_old_dumps.rake
|
68
|
+
- lib/zauberware/devops/version.rb
|
69
|
+
- zauberware-devops.gemspec
|
70
|
+
homepage: https://github.com/zauberware/zauberware-devops
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubygems_version: 3.3.26
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: devops tasks for rails applications
|
93
|
+
test_files: []
|