capistrano-master-key 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 97629d569521ff07823c184db72810db16ed8ac5273f4caf7ffcb17117b6b6b2
4
+ data.tar.gz: abe35f10f5cd65de426c5bc959ed5318ebcc048505862369d52b599c708ad06e
5
+ SHA512:
6
+ metadata.gz: f92c4558867ba744888ccb882d6eee2e7870e1d72c9d22c84c104dac665ceeffedbe1b6073dedf06cdb23bea6e292bc060cd4d514a07e347e0daebfd330e3c0d
7
+ data.tar.gz: fb9f2a2f3ef9fafb6489119d268ac1a2812595f15b7830a389c2ee18068f42d577a4fe8496ad41a423d9bbacdf5e42a2fd182921fe50664250c7977bffad0f6a
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .idea
2
+ Gemfile.lock
3
+ *.gem
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ### First Fork from capistrano-secrets.yml -> capistrano-master-key
4
+ - v1.0.2 working for our use case
5
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in *.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2014 Bruno Sutic, 2018 Virgoproz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the
8
+ Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included
11
+ in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
19
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Capistrano:MasterKey
2
+
3
+ Capistrano tasks for handling `master.key` when deploying Rails 5.2+ apps.
4
+
5
+ ### Install
6
+
7
+ Add this to `Gemfile`:
8
+
9
+ group :development do
10
+ gem 'capistrano', '~> 3.11.0'
11
+ gem 'capistrano-master-key', '~> 1.0.0'
12
+ end
13
+
14
+ And then:
15
+
16
+ $ bundle install
17
+
18
+ ### Setup and usage
19
+
20
+ - Make sure your local `config/master.key` is not git tracked. It **should be on
21
+ the disk**, but gitignored.
22
+
23
+ - Add to `Capfile`:
24
+
25
+ require 'capistrano/master_key'
26
+
27
+ - Add your master_key_local_path setting to your deploy.rb file (or wherever you need if you have multi-repo setup)
28
+
29
+ `set :master_key_local_path, "/home/myname/mycode/repo_path/config/master.key"
30
+
31
+ - You will have now a working master_key:setup
32
+
33
+ ### License
34
+
35
+ [MIT](LICENSE.md)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/master_key/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'capistrano-master-key'
8
+ gem.version = Capistrano::MasterKey::VERSION
9
+ gem.authors = ['Bruno Sutic, Virgoproz']
10
+ gem.email = ['bruno.sutic@gmail.com']
11
+ gem.description = <<-EOF.gsub(/^\s+/, '')
12
+ Capistrano tasks for automating `master.key` file handling for Rails 5.2+ apps.
13
+
14
+ This plugins syncs contents of your local master key and copies that to
15
+ the remote server.
16
+ EOF
17
+ gem.summary = 'Capistrano tasks for automating `master.key` file handling for Rails 5.2+ apps.'
18
+ gem.homepage = 'https://github.com/virgoproz/capistrano-master-key'
19
+
20
+ gem.files = `git ls-files`.split($/)
21
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
+ gem.require_paths = ['lib']
24
+
25
+ gem.license = 'MIT'
26
+
27
+ gem.add_dependency 'capistrano', '~> 3.11'
28
+ gem.add_dependency 'sshkit', '~> 1.17'
29
+
30
+ gem.add_development_dependency 'rake', '~> 12.3'
31
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,3 @@
1
+ require "capistrano/master_key/paths"
2
+ require "capistrano/master_key/helpers"
3
+ load File.expand_path("../tasks/master_key.rake", __FILE__)
@@ -0,0 +1,40 @@
1
+ require "yaml"
2
+
3
+ module Capistrano
4
+ module MasterKey
5
+ module Helpers
6
+
7
+ def master_key_env
8
+ fetch(:master_key_env).to_s
9
+ end
10
+
11
+ # error helpers
12
+ def check_git_tracking_error
13
+ puts
14
+ puts "Error - please remove '#{fetch(:master_key_local_path)}' from git:"
15
+ puts
16
+ puts " $ git rm --cached #{fetch(:master_key_local_path)}"
17
+ puts
18
+ puts "and gitignore it:"
19
+ puts
20
+ puts " $ echo '#{fetch(:master_key_local_path)}' >> .gitignore"
21
+ puts
22
+ end
23
+
24
+ def check_config_present_error
25
+ puts
26
+ puts "Error - '#{master_key_env}' config not present in '#{fetch(:master_key_local_path)}'."
27
+ puts "Please populate it."
28
+ puts
29
+ end
30
+
31
+ def check_master_file_exists_error
32
+ puts
33
+ puts "Error - '#{fetch(:master_key_local_path)}' file does not exists, and it's required."
34
+ puts
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,17 @@
1
+ require "pathname"
2
+
3
+ module Capistrano
4
+ module MasterKey
5
+ module Paths
6
+
7
+ def master_key_local_path
8
+ Pathname.new fetch(:master_key_local_path)
9
+ end
10
+
11
+ def master_key_remote_path
12
+ shared_path.join fetch(:master_key_remote_path)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module MasterKey
3
+ VERSION = '1.0.2'
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ include Capistrano::MasterKey::Paths
2
+ include Capistrano::MasterKey::Helpers
3
+
4
+ namespace :load do task :defaults do
5
+ set :master_key_local_path, 'config/master.key'
6
+ set :master_key_remote_path, 'config/master.key'
7
+ set :master_key_env, -> { fetch(:rails_env) || fetch(:stage) }
8
+ end
9
+ end
10
+
11
+ namespace :master_key do
12
+
13
+ task :check_master_file_exists do
14
+ next if File.exist?(master_key_local_path)
15
+ check_master_file_exists_error
16
+ exit 1
17
+ end
18
+
19
+ task :check_git_tracking do
20
+ next unless system("git ls-files #{fetch(:master_key_local_path)} --error-unmatch >/dev/null 2>&1")
21
+ check_git_tracking_error
22
+ exit 1
23
+ end
24
+
25
+ desc "master.key file checks"
26
+ task :check do
27
+ raise(":deploy_to in your app/config/deploy/\#{environment}.rb file cannot contain ~") if shared_path.to_s.include?('~') # SCP doesn't support ~ in the path
28
+ invoke "master_key:check_master_file_exists"
29
+ invoke "master_key:check_git_tracking"
30
+ end
31
+
32
+ desc "Setup `master.key` file on the server(s)"
33
+ task setup: [:check] do
34
+ on release_roles :all do
35
+ execute :mkdir, "-pv", File.dirname(master_key_remote_path)
36
+ Net::SCP.upload!(self.host.hostname, fetch(:user), StringIO.new(File.read(master_key_local_path)), master_key_remote_path)
37
+ end
38
+ end
39
+
40
+ # Update `linked_files` after the deploy starts so that users'
41
+ # `master_key_remote_path` override is respected.
42
+ task :master_key_symlink do
43
+ set :linked_files, fetch(:linked_files, []).push(fetch(:master_key_remote_path))
44
+ end
45
+ after "deploy:started", "master_key:master_key_symlink"
46
+
47
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-master-key
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Sutic, Virgoproz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sshkit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.17'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.17'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
55
+ description: |
56
+ Capistrano tasks for automating `master.key` file handling for Rails 5.2+ apps.
57
+ This plugins syncs contents of your local master key and copies that to
58
+ the remote server.
59
+ email:
60
+ - bruno.sutic@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".gitignore"
66
+ - CHANGELOG.md
67
+ - Gemfile
68
+ - LICENSE.md
69
+ - README.md
70
+ - Rakefile
71
+ - capistrano-master-key.gemspec
72
+ - lib/capistrano-master-key.rb
73
+ - lib/capistrano/master_key.rb
74
+ - lib/capistrano/master_key/helpers.rb
75
+ - lib/capistrano/master_key/paths.rb
76
+ - lib/capistrano/master_key/version.rb
77
+ - lib/capistrano/tasks/master_key.rake
78
+ homepage: https://github.com/virgoproz/capistrano-master-key
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 3.1.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Capistrano tasks for automating `master.key` file handling for Rails 5.2+
101
+ apps.
102
+ test_files: []