pele 0.1.10.pre.pre → 0.1.11.pre.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +4 -4
- data/lib/pele.rb +0 -1
- data/lib/pele/cli.rb +33 -7
- data/lib/pele/version.rb +1 -1
- data/pele.gemspec +1 -0
- metadata +15 -2
- data/lib/pele/utils.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e77d79e2a8a6ee2c6b6c83fd07b4f6765954b2e9
|
4
|
+
data.tar.gz: 23575a1086d015a20215aa43538c7e88e35aa16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be570a0d7866b6ee888eaad6d75ceda4f21107513237c99d2b9a3e9699f7eba7a558c02c24e2255cfcd9a4dbacd1f348f3cc832bb91fb1d4a3f9aeede26c094c
|
7
|
+
data.tar.gz: 530329f6da2faf59d739ea03108f2628dc30c1d5ff8210701e99ec1d08231f5985c1c47604de06b3c638cb3f48c80a12f89de83e471e2c7953fa3c1888e199f2
|
data/bin/console
CHANGED
@@ -7,8 +7,8 @@ require "pele"
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
12
|
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
13
|
+
# require "irb"
|
14
|
+
# IRB.start(__FILE__)
|
data/lib/pele.rb
CHANGED
data/lib/pele/cli.rb
CHANGED
@@ -1,14 +1,32 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
module Pele
|
2
3
|
class Cli < Thor
|
3
4
|
include Thor::Actions
|
4
5
|
|
5
6
|
desc 'pele init', 'Initializes the AWS credentials on your Machine'
|
6
|
-
|
7
7
|
def init
|
8
|
-
os =
|
8
|
+
os = if OS.windows?
|
9
|
+
'%HOMEPATH%\.aws\credentials'
|
10
|
+
elsif OS.mac? || OS.linux?
|
11
|
+
'~/.aws/credentials'
|
12
|
+
end
|
13
|
+
if os.nil?
|
14
|
+
puts ''
|
15
|
+
say("Looks like we could not identify your OS.\n\nPlease setup your ENV values as follows:\n\nAWS_ACCESS_KEY_ID=[YOUR ACCES KEY ID]\nAWS_SECRET_ACCESS_KEY=[YOUR SECRET KEY ID]", :red)
|
16
|
+
abort
|
17
|
+
end
|
9
18
|
prompt = TTY::Prompt.new active_color: :green
|
10
|
-
|
11
|
-
|
19
|
+
if File.exist? File.expand_path os
|
20
|
+
overwrite = prompt.select("This is going to overwrite your existing #{'~/.aws/credentials'.colorize(:green)}. ok?", %w[OK EXIT])
|
21
|
+
abort unless overwrite == 'OK'
|
22
|
+
end
|
23
|
+
puts "\e[H\e[2J"
|
24
|
+
say('Your OS identified: ', :yellow)
|
25
|
+
puts ''
|
26
|
+
puts OS.report
|
27
|
+
puts ''
|
28
|
+
say('Provide your aws credentials below', :yellow)
|
29
|
+
puts ''
|
12
30
|
aws_access_key_id = prompt.ask('AWS Access Key ID: '.colorize(:blue), required: true)
|
13
31
|
aws_secret_access_key = prompt.ask('AWS Secret Access Key: '.colorize(:blue), required: true)
|
14
32
|
aws_region = prompt.select('Choose a AWS region: '.colorize(:blue), Pele::Regions::ALL)
|
@@ -19,18 +37,26 @@ module Pele
|
|
19
37
|
create_file os do
|
20
38
|
"[default]\naws_access_key_id = #{aws_access_key_id}\naws_secret_access_key = #{aws_secret_access_key}\nregion = #{aws_region}"
|
21
39
|
end
|
22
|
-
say('Now lets generate AWS key-pair. This is needed to access EC2 Instances', :green)
|
23
40
|
puts ''
|
41
|
+
say('Now lets generate AWS key-pair. This is needed to access EC2 Instances', :green)
|
24
42
|
if File.exist? File.expand_path "#{os}key"
|
43
|
+
puts ''
|
25
44
|
overwrite = prompt.select('Looks like you already have a key generated. Would you like to generate new one?', %w[Yes No])
|
26
45
|
abort if overwrite == 'Yes'
|
27
46
|
end
|
28
47
|
puts ''
|
29
48
|
key_pair_name = prompt.ask('Name your key-pair. For example: mykeypair.colorize(:green)')
|
30
49
|
begin
|
31
|
-
|
32
|
-
|
50
|
+
ec2 = Aws::EC2::Client.new
|
51
|
+
key_pair = ec2.create_key_pair(key_name: "#{key_pair_name}-pele")
|
52
|
+
create_file "~/.ssh/#{key_pair.key_name}.pem" do
|
53
|
+
key_pair.key_material
|
54
|
+
end
|
55
|
+
say('Key-pair successfully generated', :green)
|
56
|
+
rescue => e
|
33
57
|
say('Something went wrong while trying to create key-pair. Please try again', :red)
|
58
|
+
puts ''
|
59
|
+
puts "Error: #{e}"
|
34
60
|
end
|
35
61
|
end
|
36
62
|
end
|
data/lib/pele/version.rb
CHANGED
data/pele.gemspec
CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.15"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "pry"
|
34
35
|
spec.add_dependency 'aws-sdk', '~> 2'
|
35
36
|
spec.add_dependency 'thor'
|
36
37
|
spec.add_dependency 'os'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pele
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11.pre.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suyesh Bhandari
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: aws-sdk
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,7 +140,6 @@ files:
|
|
126
140
|
- lib/pele.rb
|
127
141
|
- lib/pele/aws_regions.rb
|
128
142
|
- lib/pele/cli.rb
|
129
|
-
- lib/pele/utils.rb
|
130
143
|
- lib/pele/version.rb
|
131
144
|
- pele.gemspec
|
132
145
|
homepage: https://github.com/suyesh/pele
|
data/lib/pele/utils.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'os'
|
3
|
-
require 'tty-prompt'
|
4
|
-
module Pele
|
5
|
-
module Utils
|
6
|
-
def self.get_os_path
|
7
|
-
if OS.windows?
|
8
|
-
'%USERPROFILE%.awscredentials'
|
9
|
-
elsif OS.mac? || OS.linux?
|
10
|
-
'~/.aws/credentials'
|
11
|
-
else
|
12
|
-
puts ''
|
13
|
-
say("Looks like we could not identify your OS.\n\nPlease setup your ENV values as follows:\n\nAWS_ACCESS_KEY_ID=[YOUR ACCES KEY ID]\nAWS_SECRET_ACCESS_KEY=[YOUR SECRET KEY ID]", :red)
|
14
|
-
abort
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.check_existing_file(os, prompt)
|
19
|
-
if File.exist? File.expand_path os
|
20
|
-
overwrite = prompt.select("This is going to overwrite your existing #{'~/.aws/credentials'.colorize(:green)}. ok?", %w[OK EXIT])
|
21
|
-
abort unless overwrite == 'OK'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.post_identification
|
26
|
-
puts "\e[H\e[2J"
|
27
|
-
say('Your OS identified: ', :yellow)
|
28
|
-
puts ''
|
29
|
-
puts OS.report
|
30
|
-
puts ''
|
31
|
-
say('Provide your aws credentials below', :yellow)
|
32
|
-
puts ''
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.create_key_pair(os, key_pair_name)
|
36
|
-
current_dirname = File.basename(Dir.getwd)
|
37
|
-
ec2 = Aws::EC2::Client.new
|
38
|
-
Dir.chdir File.dirname(os)
|
39
|
-
ec2.create_key_pair(key_name: key_pair_name)
|
40
|
-
Dir.chdir current_dirname
|
41
|
-
create_file "#{File.dirname(os)}key" do
|
42
|
-
key_pair_name.to_s
|
43
|
-
end
|
44
|
-
say('Key-pair successfully generated', :green)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|