bixby-provision 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +29 -0
  3. data/Gemfile.lock +192 -0
  4. data/Rakefile +13 -0
  5. data/VERSION +1 -0
  6. data/Vagrantfile +64 -0
  7. data/bin/bixby-provision +6 -0
  8. data/bixby-provision.gemspec +113 -0
  9. data/lib/bixby-provision.rb +2 -0
  10. data/lib/bixby/provision.rb +65 -0
  11. data/lib/bixby/provision/app.rb +34 -0
  12. data/lib/bixby/provision/dsl.rb +23 -0
  13. data/lib/bixby/provision/dsl/base.rb +76 -0
  14. data/lib/bixby/provision/dsl/bundler.rb +18 -0
  15. data/lib/bixby/provision/dsl/config.rb +124 -0
  16. data/lib/bixby/provision/dsl/dir.rb +34 -0
  17. data/lib/bixby/provision/dsl/file.rb +108 -0
  18. data/lib/bixby/provision/dsl/inventory.rb +18 -0
  19. data/lib/bixby/provision/dsl/meteor.rb +30 -0
  20. data/lib/bixby/provision/dsl/nodejs.rb +73 -0
  21. data/lib/bixby/provision/dsl/npm.rb +18 -0
  22. data/lib/bixby/provision/dsl/ntp.rb +41 -0
  23. data/lib/bixby/provision/dsl/packager/apt.rb +46 -0
  24. data/lib/bixby/provision/dsl/packager/base.rb +11 -0
  25. data/lib/bixby/provision/dsl/packager/npm.rb +67 -0
  26. data/lib/bixby/provision/dsl/packager/yum.rb +100 -0
  27. data/lib/bixby/provision/dsl/packager/yum/epel.rb +71 -0
  28. data/lib/bixby/provision/dsl/packager/yum/mongodb.rb +43 -0
  29. data/lib/bixby/provision/dsl/ruby.rb +21 -0
  30. data/lib/bixby/provision/dsl/run_control.rb +49 -0
  31. data/lib/bixby/provision/dsl/scm.rb +34 -0
  32. data/lib/bixby/provision/dsl/scm/base.rb +11 -0
  33. data/lib/bixby/provision/dsl/scm/git.rb +89 -0
  34. data/lib/bixby/provision/dsl/scm/svn.rb +11 -0
  35. data/lib/bixby/provision/dsl/service.rb +56 -0
  36. data/lib/bixby/provision/dsl/services/base.rb +11 -0
  37. data/lib/bixby/provision/dsl/services/init.rb +40 -0
  38. data/lib/bixby/provision/dsl/system.rb +53 -0
  39. data/lib/bixby/provision/dsl/util/file.rb +100 -0
  40. data/lib/bixby/provision/dsl/variable.rb +27 -0
  41. data/lib/bixby/provision/manifest.rb +49 -0
  42. data/lib/bixby/provision/manifest/dsl_proxy.rb +17 -0
  43. data/manifest.rb +31 -0
  44. data/tasks/coverage.rake +2 -0
  45. data/tasks/jeweler.rake +21 -0
  46. data/tasks/test.rake +5 -0
  47. data/tasks/yard.rake +2 -0
  48. metadata +244 -0
@@ -0,0 +1,27 @@
1
+
2
+ module Bixby
3
+ module Provision
4
+
5
+ class Variable < Base
6
+
7
+ EXPORTS = [:set, :get]
8
+
9
+ def initialize(*args)
10
+ super
11
+ @variables = {}
12
+ end
13
+
14
+ def set(name, value)
15
+ @variables[name] = value
16
+ end
17
+
18
+ def get(name)
19
+ @variables[name]
20
+ end
21
+
22
+ end
23
+
24
+ register_dsl Variable
25
+
26
+ end
27
+ end
@@ -0,0 +1,49 @@
1
+
2
+ require "bixby/provision/manifest/dsl_proxy"
3
+
4
+ module Bixby
5
+ module Provision
6
+
7
+ class Manifest
8
+
9
+ include Bixby::Log
10
+
11
+ attr_reader :filename, :digest
12
+
13
+ def initialize(filename)
14
+ test_sudo_access()
15
+ @filename = filename
16
+ @digest = Digest::SHA2.new(256).file(filename).hexdigest()
17
+ load_manifest(filename)
18
+ end
19
+
20
+ def load_manifest(filename)
21
+ dsl = DSLProxy.new(self)
22
+ str = File.read(filename)
23
+ logger.debug { sprintf("read %s line(s)", str.split(/\n/).size) }
24
+ dsl.instance_eval(str, filename, 1)
25
+ end
26
+
27
+ private
28
+
29
+ def test_sudo_access
30
+ if Process.pid == 0 then
31
+ sudo = ENV["SUDO_USER"]
32
+ logger.debug "running as root" + (sudo ? " (via sudo user #{sudo})" : "")
33
+ return
34
+ end
35
+
36
+ cmd = Mixlib::ShellOut.new("sudo -n whoami")
37
+ cmd.run_command
38
+ if cmd.success? then
39
+ logger.debug "running as #{ENV['USER']} with sudo access"
40
+ else
41
+ STDERR.ptus "running as #{ENV['USER']} but sudo command failed: #{cmd.stdout}"
42
+ exit 1
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+
2
+ module Bixby
3
+ module Provision
4
+ class Manifest
5
+
6
+ class DSLProxy
7
+ extend Forwardable
8
+ attr_reader :manifest
9
+
10
+ def initialize(manifest)
11
+ @manifest = manifest
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
data/manifest.rb ADDED
@@ -0,0 +1,31 @@
1
+
2
+ first_boot do
3
+ sys.refresh_packages
4
+ upgrade_system
5
+ end
6
+
7
+ repo "epel", :platforms => [:rhel, :centos]
8
+
9
+ package "sudo", "wget"
10
+ package "group-build_tools"
11
+ package %w{ntp screen curl git}
12
+ package "openssl-dev", "readline-dev", "zlib-dev", "curl-dev", "xslt-dev", "xml2-dev"
13
+
14
+ ntp.set "ntp.ubuntu.com"
15
+
16
+ ruby.install :path => "/usr/local"
17
+ gem "bundler", :version => "1.5.3"
18
+
19
+ dir.create "/var/cache/omnibus", :chown => "bixby"
20
+ dir.recreate "/opt/bixby-foo", :chown => "$USER" # rm then create
21
+
22
+ checkout "https://github.com/chetan/bixby-omnibus.git", :path => "/home/vagrant/bixby-omnibus"
23
+ bundle.install "~/bixby-omnibus"
24
+
25
+ inventory.tap do
26
+ tags "foo", "bar"
27
+ end
28
+
29
+ # monitoring.tap do
30
+ # checks %w{cpu.loadavg cpu.usage fs.disk fs.inode net.conns net.throughput}
31
+ # end
@@ -0,0 +1,2 @@
1
+
2
+ require "easycov/rake"
@@ -0,0 +1,21 @@
1
+
2
+ require 'jeweler'
3
+
4
+ Jeweler::Tasks.new do |gemspec|
5
+ gemspec.name = "bixby-provision"
6
+ gemspec.summary = "Bixby Provision"
7
+ gemspec.description = "Bixby Provisioner"
8
+ gemspec.email = "chetan@pixelcop.net"
9
+ gemspec.homepage = "http://github.com/chetan/bixby-provision"
10
+ gemspec.authors = ["Chetan Sarva"]
11
+ gemspec.license = "MIT"
12
+
13
+ gemspec.executables = %w{ bixby-provision }
14
+
15
+ # exclude these bin scripts for now
16
+ # %w{ bin/bundle bin/cache_all.rb bin/install.sh bin/old_install.sh bin/package }.each do |f|
17
+ # gemspec.files.exclude f
18
+ # end
19
+
20
+ end
21
+ Jeweler::RubygemsDotOrgTasks.new
data/tasks/test.rake ADDED
@@ -0,0 +1,5 @@
1
+
2
+ require "micron/rake"
3
+ Micron::Rake.new do |task|
4
+ end
5
+ task :default => :test
data/tasks/yard.rake ADDED
@@ -0,0 +1,2 @@
1
+ require 'yard'
2
+ YARD::Rake::YardocTask.new
metadata ADDED
@@ -0,0 +1,244 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bixby-provision
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chetan Sarva
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bixby-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: api-auth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mixlib-shellout
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: git
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.6
69
+ - !ruby/object:Gem::Dependency
70
+ name: tilt
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jeweler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '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'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.7'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.7'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: awesome_print
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: test_guard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: micron
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Bixby Provisioner
168
+ email: chetan@pixelcop.net
169
+ executables:
170
+ - bixby-provision
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - Gemfile
175
+ - Gemfile.lock
176
+ - Rakefile
177
+ - VERSION
178
+ - Vagrantfile
179
+ - bin/bixby-provision
180
+ - bixby-provision.gemspec
181
+ - lib/bixby-provision.rb
182
+ - lib/bixby/provision.rb
183
+ - lib/bixby/provision/app.rb
184
+ - lib/bixby/provision/dsl.rb
185
+ - lib/bixby/provision/dsl/base.rb
186
+ - lib/bixby/provision/dsl/bundler.rb
187
+ - lib/bixby/provision/dsl/config.rb
188
+ - lib/bixby/provision/dsl/dir.rb
189
+ - lib/bixby/provision/dsl/file.rb
190
+ - lib/bixby/provision/dsl/inventory.rb
191
+ - lib/bixby/provision/dsl/meteor.rb
192
+ - lib/bixby/provision/dsl/nodejs.rb
193
+ - lib/bixby/provision/dsl/npm.rb
194
+ - lib/bixby/provision/dsl/ntp.rb
195
+ - lib/bixby/provision/dsl/packager/apt.rb
196
+ - lib/bixby/provision/dsl/packager/base.rb
197
+ - lib/bixby/provision/dsl/packager/npm.rb
198
+ - lib/bixby/provision/dsl/packager/yum.rb
199
+ - lib/bixby/provision/dsl/packager/yum/epel.rb
200
+ - lib/bixby/provision/dsl/packager/yum/mongodb.rb
201
+ - lib/bixby/provision/dsl/ruby.rb
202
+ - lib/bixby/provision/dsl/run_control.rb
203
+ - lib/bixby/provision/dsl/scm.rb
204
+ - lib/bixby/provision/dsl/scm/base.rb
205
+ - lib/bixby/provision/dsl/scm/git.rb
206
+ - lib/bixby/provision/dsl/scm/svn.rb
207
+ - lib/bixby/provision/dsl/service.rb
208
+ - lib/bixby/provision/dsl/services/base.rb
209
+ - lib/bixby/provision/dsl/services/init.rb
210
+ - lib/bixby/provision/dsl/system.rb
211
+ - lib/bixby/provision/dsl/util/file.rb
212
+ - lib/bixby/provision/dsl/variable.rb
213
+ - lib/bixby/provision/manifest.rb
214
+ - lib/bixby/provision/manifest/dsl_proxy.rb
215
+ - manifest.rb
216
+ - tasks/coverage.rake
217
+ - tasks/jeweler.rake
218
+ - tasks/test.rake
219
+ - tasks/yard.rake
220
+ homepage: http://github.com/chetan/bixby-provision
221
+ licenses:
222
+ - MIT
223
+ metadata: {}
224
+ post_install_message:
225
+ rdoc_options: []
226
+ require_paths:
227
+ - lib
228
+ required_ruby_version: !ruby/object:Gem::Requirement
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: '0'
233
+ required_rubygems_version: !ruby/object:Gem::Requirement
234
+ requirements:
235
+ - - ">="
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ requirements: []
239
+ rubyforge_project:
240
+ rubygems_version: 2.2.2
241
+ signing_key:
242
+ specification_version: 4
243
+ summary: Bixby Provision
244
+ test_files: []