Devops 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/bin/ops CHANGED
@@ -9,26 +9,33 @@ end
9
9
  bootstrap_files = [
10
10
  File.join( 'tasks', 'init.rb' ) ]
11
11
 
12
- Rake.application.init( File.basename( $0 ) )
12
+ Dir.chdir Ops::pwd_dir do
13
13
 
14
- begin
15
- bootstrap_files.each do | f |
16
- File.join Ops::root_dir, f
17
- require f
14
+ unless Ops::pwd_dir == Dir.pwd
15
+ puts "Executing from ( #{ Ops::pwd_dir } )".warning
18
16
  end
19
- rescue => e
20
- puts e
21
- end
22
17
 
23
- bootstrap_files.each do | f |
24
- f = File.join Ops::pwd_dir, f
25
- require f if File.exists? f
26
- end
18
+ Rake.application.init( File.basename( $0 ) )
19
+
20
+ begin
21
+ bootstrap_files.each do | f |
22
+ File.join Ops::root_dir, f
23
+ require f
24
+ end
25
+ rescue => e
26
+ puts e
27
+ end
27
28
 
28
- begin
29
- Rake.application.top_level
30
- rescue => e
31
- puts "Failed to call task: #{ e.message }"
29
+ bootstrap_files.each do | f |
30
+ f = File.join Ops::pwd_dir, f
31
+ require f if File.exists? f
32
+ end
33
+
34
+ begin
35
+ Rake.application.top_level
36
+ rescue => e
37
+ puts "Failed to call task: #{ e.message }"
38
+ end
32
39
  end
33
40
 
34
41
  exit
@@ -6,7 +6,10 @@ module Ops
6
6
  end
7
7
 
8
8
  def self.pwd_dir
9
- Dir.pwd
9
+ Pathname.new( Dir.pwd ).ascend do | p |
10
+ return p if File.exists? File.join( p, 'config.json' )
11
+ end
12
+ nil
10
13
  end
11
14
 
12
15
  def self.has_bash?
@@ -50,4 +50,8 @@ class String
50
50
  def error
51
51
  replace Color.print( self , [ :bold, :red ] )
52
52
  end
53
+
54
+ def warning
55
+ replace Color.print( self , [ :bold, :yellow ] )
56
+ end
53
57
  end
@@ -21,7 +21,17 @@ namespace "hosts" do
21
21
  host = ENV[ 'host' ]
22
22
  user = ENV[ 'user' ]
23
23
  type = ENV[ 'type' ] || "default"
24
- identity = File.basename( ENV[ 'identity' ] )
24
+ identity = nil
25
+ tags = {}
26
+
27
+ unless ENV[ 'identity' ].nil?
28
+ identity = File.basename( ENV[ 'identity' ] )
29
+ end
30
+
31
+ unless ENV[ 'tags' ].nil?
32
+ tags = File.basename( ENV[ 'tags' ] )
33
+ tags = JSON.parse( tags )
34
+ end
25
35
 
26
36
 
27
37
  puts "Adding host: #{ host }"
@@ -31,7 +41,9 @@ namespace "hosts" do
31
41
  hosts = {}
32
42
  hosts_file = File.join( pwd, "hosts.json" )
33
43
 
34
- hosts = Ops::read_hosts
44
+ if File.exists? hosts_file
45
+ hosts = JSON.parse( File.read( hosts_file ) )
46
+ end
35
47
 
36
48
  exit_failure( "Error: #{ host } is already defined" ) if
37
49
  hosts.has_key? host
@@ -40,7 +52,8 @@ namespace "hosts" do
40
52
  'HostName' => hostname,
41
53
  'User' => user,
42
54
  'IdentityFile' => identity,
43
- "Type" => "type"
55
+ "Type" => "type",
56
+ "Tags" => tags
44
57
  }
45
58
 
46
59
  File.open( hosts_file, 'w' ) { | f | f.write( hosts.to_json ) }
@@ -1,6 +1,5 @@
1
1
  task "default" do
2
- Rake.application.options.show_task_pattern = //
3
- Rake.application.display_tasks_and_comments()
2
+ puts "run ops -T for a full list of commands"
4
3
  end
5
4
 
6
5
  desc I18n.t( "ops.version.desc" )
@@ -1,6 +1,6 @@
1
1
  module Ops
2
2
 
3
3
  def self.version
4
- "0.0.5"
4
+ "0.0.6"
5
5
  end
6
6
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Devops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-08 00:00:00.000000000 Z
13
+ date: 2013-04-29 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Ops tool for remote servers
16
16
  email: hardeepshoker@gmail.com
@@ -43,8 +43,8 @@ files:
43
43
  - res/samples/default/config.json
44
44
  - res/strings/strings.yml
45
45
  - res/strings/tasks/hosts.yml
46
- - spec/lib/host/default.rb
47
- - spec/lib/host/list.rb
46
+ - spec/lib/host/default_spec.rb
47
+ - spec/lib/host/list_spec.rb
48
48
  - spec/spec_helper.rb
49
49
  homepage: https://github.com/hardeep/ops
50
50
  licenses: []