noc 0.0.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.
Files changed (6) hide show
  1. data/README.rdoc +6 -0
  2. data/bin/noc +142 -0
  3. data/lib/noc.rb +6 -0
  4. data/lib/noc/version.rb +3 -0
  5. data/noc.rdoc +5 -0
  6. metadata +138 -0
@@ -0,0 +1,6 @@
1
+ = noc
2
+
3
+ Describe your project here
4
+
5
+ :include:noc.rdoc
6
+
data/bin/noc ADDED
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ begin # XXX: Remove this begin/rescue before distributing your app
4
+ require 'noc'
5
+ rescue LoadError
6
+ STDERR.puts "In development, you need to use `bundle exec bin/todo` to run your app"
7
+ STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
8
+ STDERR.puts "Feel free to remove this message from bin/todo now"
9
+ exit 64
10
+ end
11
+
12
+
13
+ CHEF=".chef"
14
+ KNIFE="knife.rb"
15
+ CHEF_KNIFE=File.join(CHEF, KNIFE )
16
+ VAGRANTFILE="Vagrantfile"
17
+
18
+
19
+ include GLI::App
20
+
21
+ program_desc 'Describe your application here'
22
+
23
+ version Noc::VERSION
24
+
25
+ # desc 'Describe some switch here'
26
+ # switch [:s,:switch]
27
+
28
+ desc 'Cluster file'
29
+ default_value 'Clusterfile.yml'
30
+ arg_name 'CLUSTERFILE'
31
+ flag [:c,:clusterfile]
32
+
33
+
34
+ desc 'Scaffold the cluster'
35
+ arg_name 'options'
36
+ command :init do |c|
37
+ # c.desc 'Describe a switch to init'
38
+ # c.switch :s
39
+
40
+ # c.desc 'Describe a flag to init'
41
+ # c.default_value 'default'
42
+ # c.flag :f
43
+ c.action do |global_options,options,args|
44
+ case
45
+ when args[0] == "solo"
46
+ puts "Init solo"
47
+ else
48
+ if File.exists?(CHEF_KNIFE) then
49
+ raise "File exists #{CHEF_KNIFE}"
50
+ end
51
+ if $cluster[:knife].nil? then
52
+ raise "No knife section in cluster"
53
+ end
54
+ # create chef directory
55
+ Dir.mkdir(CHEF) unless File.exists?(CHEF)
56
+ # knife.rb template
57
+ template = File.join(File.dirname(__FILE__), '..', 'templates', KNIFE + ".erb" )
58
+ if not File.exists?(template) then
59
+ raise "Template not found: #{template}"
60
+ end
61
+ # create knife.rb
62
+ File.open( CHEF_KNIFE, 'w' ) do |f|
63
+ f.write( Erubis::Eruby.new(File.new(template).read).result($cluster[:knife]) )
64
+ end
65
+ puts "#{CHEF_KNIFE}"
66
+ end
67
+
68
+ # create vagrantfile
69
+ if File.exists?(VAGRANTFILE) then
70
+ raise "File exists #{VAGRANTFILE}"
71
+ end
72
+ template = File.join(File.dirname(__FILE__), '..', 'templates', VAGRANTFILE + ".erb" )
73
+ if not File.exists?(template) then
74
+ raise "Template not found: #{template}"
75
+ end
76
+ puts Erubis::Eruby.new(File.new(template).read).result({:clusterfile => global_options[:clusterfile],
77
+ :cluster => $cluster}).inspect
78
+ puts "init command ran"
79
+ end
80
+ end
81
+
82
+ desc 'Upload cookbook, role, databag'
83
+ arg_name 'COMMAND [options]'
84
+ command :upload do |c|
85
+ c.action do |global_options,options,args|
86
+ case
87
+ when args[0] == 'books'
88
+ system("knife cookbook upload --all")
89
+ when args[0] == "book"
90
+ system("knife cookbook upload #{args[1]}")
91
+
92
+ when args[0] == "roles"
93
+ Dir.glob("roles/*.rb").each do |f|
94
+ system("knife role from file #{f}")
95
+ end
96
+ when args[0] == "role"
97
+ system("knife role from file roles/#{args[1]}.rb")
98
+
99
+ when args[0] == "envs"
100
+ Dir.glob("environments/*.rb").each do |f|
101
+ system("knife environment from file #{f}")
102
+ end
103
+ when args[0] == "env"
104
+ system("knife environment from file environments/#{args[1]}.rb")
105
+ end
106
+
107
+ puts "upload command ran"
108
+ end
109
+ end
110
+
111
+ pre do |global,command,options,args|
112
+ # Pre logic here
113
+ # Return true to proceed; false to abourt and not call the
114
+ # chosen command
115
+ # Use skips_pre before a command to skip this block
116
+ # on that command only
117
+
118
+ begin
119
+ file = global[:clusterfile]
120
+ $cluster = YAML.load_file file
121
+ rescue Exception => e
122
+ STDERR.puts e.message
123
+ # STDERR.puts "ERROR: No infrastructure .yml file provided."
124
+ exit(-1)
125
+ end
126
+
127
+ true
128
+ end
129
+
130
+ post do |global,command,options,args|
131
+ # Post logic here
132
+ # Use skips_post before a command to skip this
133
+ # block on that command only
134
+ end
135
+
136
+ on_error do |exception|
137
+ # Error logic here
138
+ # return false to skip default error handling
139
+ true
140
+ end
141
+
142
+ exit run(ARGV)
@@ -0,0 +1,6 @@
1
+ require 'noc/version.rb'
2
+
3
+ # Add requires for other files you add to your project here, so
4
+ # you just need to require this one file in your bin file
5
+ require 'erubis'
6
+
@@ -0,0 +1,3 @@
1
+ module Noc
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,5 @@
1
+ = noc
2
+
3
+ Generate this with
4
+ noc rdoc
5
+ After you have described your command line interface
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: noc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tom Hornos
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: aruba
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: erubis
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: gli
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 2.0.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '='
92
+ - !ruby/object:Gem::Version
93
+ version: 2.0.0
94
+ description:
95
+ email: tom.hornos@gmail.com
96
+ executables:
97
+ - noc
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - README.rdoc
101
+ - noc.rdoc
102
+ files:
103
+ - bin/noc
104
+ - lib/noc/version.rb
105
+ - lib/noc.rb
106
+ - README.rdoc
107
+ - noc.rdoc
108
+ homepage: http://your.website.com
109
+ licenses: []
110
+ post_install_message:
111
+ rdoc_options:
112
+ - --title
113
+ - noc
114
+ - --main
115
+ - README.rdoc
116
+ - -ri
117
+ require_paths:
118
+ - lib
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 1.8.24
135
+ signing_key:
136
+ specification_version: 3
137
+ summary: A description of your project
138
+ test_files: []