noc 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. data/bin/noc +26 -3
  2. data/lib/noc.rb +0 -1
  3. data/lib/noc/version.rb +1 -1
  4. metadata +1 -1
data/bin/noc CHANGED
@@ -73,8 +73,10 @@ command :init do |c|
73
73
  if not File.exists?(template) then
74
74
  raise "Template not found: #{template}"
75
75
  end
76
- puts Erubis::Eruby.new(File.new(template).read).result({:clusterfile => global_options[:clusterfile],
77
- :cluster => $cluster}).inspect
76
+ File.open( VAGRANTFILE, 'w' ) do |f|
77
+ f.write( Erubis::Eruby.new(File.new(template).read).result({:clusterfile => global_options[:clusterfile],
78
+ :cluster => $cluster}))
79
+ end
78
80
  puts "init command ran"
79
81
  end
80
82
  end
@@ -82,12 +84,18 @@ end
82
84
  desc 'Upload cookbook, role, databag'
83
85
  arg_name 'COMMAND [options]'
84
86
  command :upload do |c|
87
+ c.desc 'force'
88
+ c.switch :f
89
+
85
90
  c.action do |global_options,options,args|
86
91
  case
87
92
  when args[0] == 'books'
88
93
  system("knife cookbook upload --all")
89
94
  when args[0] == "book"
90
- system("knife cookbook upload #{args[1]}")
95
+ args.shift
96
+ args.each do |a|
97
+ system("knife cookbook upload #{a}")
98
+ end
91
99
 
92
100
  when args[0] == "roles"
93
101
  Dir.glob("roles/*.rb").each do |f|
@@ -102,6 +110,21 @@ command :upload do |c|
102
110
  end
103
111
  when args[0] == "env"
104
112
  system("knife environment from file environments/#{args[1]}.rb")
113
+
114
+ when args[0] == "cluster"
115
+ data_bag = File.join( "data_bags", "clusters", "#{$cluster[:id]}.json" )
116
+ if File.exists?( data_bag ) then
117
+ if not options[:f] then
118
+ raise "Cluster found: #{data_bag}"
119
+ end
120
+ end
121
+ data_bag_dir = File.join( "data_bags", "clusters" )
122
+ Dir.mkdir(data_bag_dir) unless File.exists?(data_bag_dir)
123
+ File.open( data_bag, 'w' ) do |f|
124
+ f.write( $cluster.to_json )
125
+ end
126
+ system("knife data bag create clusters")
127
+ system("knife data bag from file clusters #{$cluster[:id]}.json")
105
128
  end
106
129
 
107
130
  puts "upload command ran"
data/lib/noc.rb CHANGED
@@ -3,4 +3,3 @@ require 'noc/version.rb'
3
3
  # Add requires for other files you add to your project here, so
4
4
  # you just need to require this one file in your bin file
5
5
  require 'erubis'
6
-
data/lib/noc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Noc
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: