climbr 0.2.1
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 +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/README.markdown +26 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/setup +10 -0
- data/climbr.gemspec +30 -0
- data/exe/climbr +8 -0
- data/lib/climbr.rb +27 -0
- data/lib/climbr/cli.rb +63 -0
- data/lib/climbr/commands/help.rb +24 -0
- data/lib/climbr/commands/list_instances.rb +22 -0
- data/lib/climbr/commands/list_variables.rb +26 -0
- data/lib/climbr/commands/maintenance_off.rb +8 -0
- data/lib/climbr/commands/maintenance_on.rb +8 -0
- data/lib/climbr/commands/restart.rb +23 -0
- data/lib/climbr/commands/set_variables.rb +60 -0
- data/lib/climbr/commands/ssh.rb +20 -0
- data/lib/climbr/instances.rb +35 -0
- data/lib/climbr/project.rb +22 -0
- data/lib/climbr/ssh_commands.rb +25 -0
- data/lib/climbr/ssh_connection.rb +44 -0
- data/lib/climbr/toggle_maintenance.rb +23 -0
- data/lib/climbr/version.rb +5 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb50fb545722f82181a0c85ef1ce9d40aba732f6
|
4
|
+
data.tar.gz: 807ff8326f4d5ed1b22bc59d2d69eff26bb7f2b8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be256780e59ece6e9dcc94c0cee018765665e6d321c504cbbd1e8a4f55093ffa802a4709e8fded1cbeb09ab72bb968a67c336fd61d1d5a228f1b7bae7fa95619
|
7
|
+
data.tar.gz: 70cd650a4b3125e1fec290720fa9ed97e5482a19fa715a274a48301d8ec761f42b95a0b60acfc8da03b90ff2c5a2500cfe222bfb9de4b2652b4109a539042b15
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at pat@freelancing-gods.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Climbr
|
2
|
+
|
3
|
+
Command-line tool for interacting with Limbr servers.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
It's a gem, so you can install it like any other gem.
|
8
|
+
|
9
|
+
$ gem install climbr
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The following commands are available:
|
14
|
+
|
15
|
+
$ climbr PROJECT config:set FOO=BAR
|
16
|
+
$ climbr PROJECT config
|
17
|
+
$ climbr PROJECT instances
|
18
|
+
$ climbr PROJECT restart
|
19
|
+
$ climbr PROJECT maintenance:on
|
20
|
+
$ climbr PROJECT maintenance:off
|
21
|
+
|
22
|
+
Any arguments not matching the known values will result in the help documentation being displayed instead.
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
|
26
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/limbrup/climbr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
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 "climbr"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/climbr.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "climbr/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "climbr"
|
9
|
+
spec.version = Climbr::VERSION
|
10
|
+
spec.authors = ["Pat Allan"]
|
11
|
+
spec.email = ["pat@freelancing-gods.com"]
|
12
|
+
|
13
|
+
spec.summary = "CLI tool for managing Limbr infrastructure."
|
14
|
+
spec.homepage = "https://github.com/limbrup/climbr"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |file|
|
17
|
+
file.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |file| File.basename(file) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "aws-sdk", "~> 2.7.12"
|
24
|
+
spec.add_runtime_dependency "boltos", "~> 0.2.0"
|
25
|
+
spec.add_runtime_dependency "net-ssh", "~> 4.1.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency "rubocop", "~> 0.50.0"
|
30
|
+
end
|
data/exe/climbr
ADDED
data/lib/climbr.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "aws-sdk"
|
4
|
+
require "boltos"
|
5
|
+
require "net/ssh"
|
6
|
+
|
7
|
+
module Climbr
|
8
|
+
module Commands
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require "climbr/commands/help"
|
13
|
+
require "climbr/commands/list_instances"
|
14
|
+
require "climbr/commands/list_variables"
|
15
|
+
require "climbr/commands/maintenance_off"
|
16
|
+
require "climbr/commands/maintenance_on"
|
17
|
+
require "climbr/commands/restart"
|
18
|
+
require "climbr/commands/set_variables"
|
19
|
+
require "climbr/commands/ssh"
|
20
|
+
|
21
|
+
require "climbr/cli"
|
22
|
+
require "climbr/instances"
|
23
|
+
require "climbr/project"
|
24
|
+
require "climbr/ssh_commands"
|
25
|
+
require "climbr/ssh_connection"
|
26
|
+
require "climbr/toggle_maintenance"
|
27
|
+
require "climbr/version"
|
data/lib/climbr/cli.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::CLI
|
4
|
+
CONTEXTLESS_COMMANDS = %w[
|
5
|
+
config instances restart maintenance:on maintenance:off
|
6
|
+
].freeze
|
7
|
+
|
8
|
+
def self.call(*arguments)
|
9
|
+
new(arguments[0], arguments[1], arguments[2], arguments[3..-1]).call
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(app, environment, action, arguments)
|
13
|
+
@project = Climbr::Project.new app, environment
|
14
|
+
@action = action
|
15
|
+
@arguments = arguments
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
if commands.keys.include? action
|
20
|
+
commands[action].call(*command_arguments)
|
21
|
+
else
|
22
|
+
Climbr::Commands::Help.call
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :project, :action, :arguments
|
29
|
+
|
30
|
+
def arguments_as_hash
|
31
|
+
arguments.inject({}) do |hash, argument|
|
32
|
+
key, value = argument.split("=", 2)
|
33
|
+
|
34
|
+
hash[key] = value
|
35
|
+
hash
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def commands
|
40
|
+
@commands ||= {
|
41
|
+
"config" => Climbr::Commands::ListVariables,
|
42
|
+
"config:set" => Climbr::Commands::SetVariables,
|
43
|
+
"instances" => Climbr::Commands::ListInstances,
|
44
|
+
"restart" => Climbr::Commands::Restart,
|
45
|
+
"maintenance:on" => Climbr::Commands::MaintenanceOn,
|
46
|
+
"maintenance:off" => Climbr::Commands::MaintenanceOff,
|
47
|
+
"ssh" => Climbr::Commands::SSH
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def command_arguments
|
52
|
+
case action
|
53
|
+
when "config:set"
|
54
|
+
[project, arguments_as_hash]
|
55
|
+
when "ssh"
|
56
|
+
[project, arguments.first]
|
57
|
+
when *CONTEXTLESS_COMMANDS
|
58
|
+
[project]
|
59
|
+
else
|
60
|
+
raise "Unexpected command #{action}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Commands::Help
|
4
|
+
def self.call
|
5
|
+
puts <<~HELP
|
6
|
+
climbr #{Climbr::VERSION}
|
7
|
+
|
8
|
+
Command-line tool for interacting with Limbr servers.
|
9
|
+
The following commands are available:
|
10
|
+
|
11
|
+
climbr PROJECT ENVIRONMENT config:set FOO=BAR
|
12
|
+
climbr PROJECT ENVIRONMENT config
|
13
|
+
climbr PROJECT ENVIRONMENT instances
|
14
|
+
climbr PROJECT ENVIRONMENT restart
|
15
|
+
climbr PROJECT ENVIRONMENT maintenance:on
|
16
|
+
climbr PROJECT ENVIRONMENT maintenance:off
|
17
|
+
climbr PROJECT ENVIRONMENT ssh IP_ADDRESS
|
18
|
+
|
19
|
+
For any commands that make use of SSH (config:set, restart, maintenance),
|
20
|
+
you can use the CLIMBR_KEY environment variable to provide a path to the
|
21
|
+
appropriate SSH key.
|
22
|
+
HELP
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Commands::ListInstances
|
4
|
+
def self.call(project, stream = STDOUT)
|
5
|
+
new(project, stream).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project, stream)
|
9
|
+
@project = project
|
10
|
+
@stream = stream
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
Climbr::Instances.call(project).each do |instance|
|
15
|
+
stream.puts "* #{instance.public_ip_address}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :project, :stream
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Commands::ListVariables
|
4
|
+
def self.call(project, stream = STDOUT)
|
5
|
+
new(project, stream).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project, stream)
|
9
|
+
@project = project
|
10
|
+
@stream = stream
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
voltos_bundle.variables.keys.sort.each do |key|
|
15
|
+
stream.puts "#{key}=#{voltos_bundle.variables[key]}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :project, :stream
|
22
|
+
|
23
|
+
def voltos_bundle
|
24
|
+
@voltos_bundle ||= Boltos::Bundle.find_or_create project.to_s
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Commands::Restart
|
4
|
+
def self.call(project, stream = STDOUT)
|
5
|
+
new(project, stream).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project, stream)
|
9
|
+
@project = project
|
10
|
+
@stream = stream
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
stream.puts "Restarting Puma on servers"
|
15
|
+
Climbr::SSHCommands.call project, [
|
16
|
+
"sudo -H -u deploy /srv/shared/scripts/restart"
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :project, :stream
|
23
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Commands::SetVariables
|
4
|
+
def self.call(project, variables, stream = STDOUT)
|
5
|
+
new(project, stream).call(variables)
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project, stream)
|
9
|
+
@project = project
|
10
|
+
@stream = stream
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(variables)
|
14
|
+
store_variables variables
|
15
|
+
upload_variables
|
16
|
+
update_servers
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :project, :stream
|
22
|
+
|
23
|
+
def client
|
24
|
+
Aws::S3::Client.new :profile => project.profile
|
25
|
+
end
|
26
|
+
|
27
|
+
def env_contents
|
28
|
+
voltos_bundle.variables.inject("") do |string, (key, value)|
|
29
|
+
string + "export #{key}=\"#{value}\"\n"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def store_variables(variables)
|
34
|
+
stream.puts "Setting variables"
|
35
|
+
variables.each do |key, value|
|
36
|
+
voltos_bundle.set key, value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_servers
|
41
|
+
stream.puts "Updating servers"
|
42
|
+
Climbr::SSHCommands.call project, [
|
43
|
+
"sudo -H -u deploy /srv/shared/scripts/setup #{project.bucket}",
|
44
|
+
"sudo -H -u deploy /srv/shared/scripts/restart"
|
45
|
+
]
|
46
|
+
end
|
47
|
+
|
48
|
+
def upload_variables
|
49
|
+
stream.puts "Uploading variables"
|
50
|
+
client.put_object(
|
51
|
+
:bucket => project.bucket,
|
52
|
+
:key => ".env",
|
53
|
+
:body => env_contents
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
def voltos_bundle
|
58
|
+
@voltos_bundle ||= Boltos::Bundle.find_or_create project.to_s
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Commands::SSH
|
4
|
+
def self.call(project, ip_address, stream = STDOUT)
|
5
|
+
new(project, stream).call(ip_address)
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project, stream)
|
9
|
+
@project = project
|
10
|
+
@stream = stream
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(ip_address)
|
14
|
+
exec Climbr::SSHConnection.new(project, ip_address).to_cli
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :project, :stream
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Instances
|
4
|
+
def self.call(project)
|
5
|
+
new(project).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project)
|
9
|
+
@project = project
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
reservations.collect(&:instances).flatten.select do |instance|
|
14
|
+
instance.state.name == "running"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :project
|
21
|
+
|
22
|
+
def client
|
23
|
+
@client ||= Aws::EC2::Client.new :profile => project.profile
|
24
|
+
end
|
25
|
+
|
26
|
+
def reservations
|
27
|
+
client.describe_instances(
|
28
|
+
:filters => [{:name => "tag:Role", :values => [role]}]
|
29
|
+
).reservations
|
30
|
+
end
|
31
|
+
|
32
|
+
def role
|
33
|
+
"#{project}-app"
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::Project
|
4
|
+
attr_reader :app, :environment
|
5
|
+
|
6
|
+
def initialize(app, environment)
|
7
|
+
@app = app
|
8
|
+
@environment = environment
|
9
|
+
end
|
10
|
+
|
11
|
+
def bucket
|
12
|
+
"limbr-#{app}-#{environment}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def profile
|
16
|
+
ENV["CLIMBR_#{project.environment.upcase}_PROFILE"] || ENV["AWS_PROFILE"]
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"#{app}-#{environment}"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::SSHCommands
|
4
|
+
def self.call(project, commands)
|
5
|
+
new(project).call commands
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project)
|
9
|
+
@project = project
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(commands)
|
13
|
+
Climbr::Instances.call(project).each do |instance|
|
14
|
+
Climbr::SSHConnection.new(
|
15
|
+
project, instance.public_ip_address
|
16
|
+
).to_rb do |ssh|
|
17
|
+
commands.each { |command| ssh.exec!(command) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :project
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::SSHConnection
|
4
|
+
USERNAME = "ubuntu"
|
5
|
+
|
6
|
+
def initialize(project, ip_address)
|
7
|
+
@project = project
|
8
|
+
@ip_address = ip_address
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_cli
|
12
|
+
"ssh #{options_string} #{USERNAME}@#{ip_address}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_rb(&block)
|
16
|
+
Net::SSH.start(ip_address, USERNAME, options_hash, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :project, :ip_address
|
22
|
+
|
23
|
+
def options_hash
|
24
|
+
@options_hash ||= begin
|
25
|
+
if ENV["CLIMBR_KEY"]
|
26
|
+
{:keys => [ENV["CLIMBR_KEY"]]}
|
27
|
+
elsif ENV["CLIMBR_KEY_DIRECTORY"]
|
28
|
+
{:keys => [File.join(ENV["CLIMBR_KEY_DIRECTORY"], project.to_s)]}
|
29
|
+
else
|
30
|
+
{}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def options_string
|
36
|
+
strings = []
|
37
|
+
|
38
|
+
if options_hash[:keys]
|
39
|
+
strings += options_hash[:keys].collect { |key| "-i #{key}" }
|
40
|
+
end
|
41
|
+
|
42
|
+
strings.join(" ")
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Climbr::ToggleMaintenance
|
4
|
+
def self.call(project, on = true)
|
5
|
+
new(project).call(on)
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(project)
|
9
|
+
@project = project
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(on)
|
13
|
+
switch = on ? "maintenance" : "default"
|
14
|
+
|
15
|
+
Climbr::SSHCommands.call project, [
|
16
|
+
"sudo -H -u deploy /srv/shared/scripts/switch #{switch}"
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :project
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: climbr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pat Allan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.7.12
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.7.12
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: boltos
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: net-ssh
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.50.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.50.0
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- pat@freelancing-gods.com
|
100
|
+
executables:
|
101
|
+
- climbr
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rubocop.yml"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- README.markdown
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- climbr.gemspec
|
115
|
+
- exe/climbr
|
116
|
+
- lib/climbr.rb
|
117
|
+
- lib/climbr/cli.rb
|
118
|
+
- lib/climbr/commands/help.rb
|
119
|
+
- lib/climbr/commands/list_instances.rb
|
120
|
+
- lib/climbr/commands/list_variables.rb
|
121
|
+
- lib/climbr/commands/maintenance_off.rb
|
122
|
+
- lib/climbr/commands/maintenance_on.rb
|
123
|
+
- lib/climbr/commands/restart.rb
|
124
|
+
- lib/climbr/commands/set_variables.rb
|
125
|
+
- lib/climbr/commands/ssh.rb
|
126
|
+
- lib/climbr/instances.rb
|
127
|
+
- lib/climbr/project.rb
|
128
|
+
- lib/climbr/ssh_commands.rb
|
129
|
+
- lib/climbr/ssh_connection.rb
|
130
|
+
- lib/climbr/toggle_maintenance.rb
|
131
|
+
- lib/climbr/version.rb
|
132
|
+
homepage: https://github.com/limbrup/climbr
|
133
|
+
licenses: []
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.6.13
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: CLI tool for managing Limbr infrastructure.
|
155
|
+
test_files: []
|