vmerize 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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/README ADDED
@@ -0,0 +1,34 @@
1
+ This is currently a highly opinionated way of applying Chef recipes against a
2
+ remote machine. It does the following:
3
+
4
+ * Installs a Ruby environment and the latest version of Chef
5
+ * Copies a set of files to the remote host
6
+ * Runs chef-solo with a prefined configuration
7
+
8
+ It has several limitations:
9
+
10
+ * It probably only works with Ubuntu 10.04
11
+ * It requires passwordless ssh access to the remote machine
12
+ * It requires an account with sudo access (if needed will prompt for a password)
13
+ * It needs rsync installed locally
14
+ * It only works with Chef
15
+
16
+ Some of these I might fix one day.
17
+
18
+ My workflow involves frequently starting new virtual machines of different
19
+ types (Rackspace, VMWare, EC2). These tend to be for general development
20
+ activities, rather than production servers, and to be short lived. But I still
21
+ want my shell configiration and common tools installed.
22
+
23
+ This isn't designed as a replacement for knife or for running a proper Chef
24
+ server setup. Please don't use this because you find the server _complicated_.
25
+
26
+ Here's how to use it:
27
+
28
+ > vmerize bootstrap host.example.com
29
+
30
+ > ls
31
+ cookbooks roles configs
32
+ > ls configs
33
+ solo.rb vmerize.json
34
+ > vmerize converge host.example.com
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'highline/import'
5
+ require 'net/ssh'
6
+ require 'gli'
7
+ require 'vmerize'
8
+
9
+ include GLI
10
+
11
+ program_desc 'Run your local Chef recipes against a remote machine. Quickly.'
12
+
13
+ version Vmerize::VERSION
14
+
15
+ USER = ENV['USER'] || `whoami`
16
+
17
+ def execute_command(host, command)
18
+ Net::SSH.start(host, USER.strip) do |ssh|
19
+ ssh.open_channel do |channel|
20
+ channel.request_pty
21
+ channel.exec command
22
+ channel.on_data do |ch, data|
23
+ if data =~ /\[sudo\]/
24
+ password = ask("Enter your password: ") { |q| q.echo = "x" }
25
+ channel.send_data(password + "\n")
26
+ end
27
+ puts data
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ desc 'Install the pre-requisites for running Chef'
34
+ command :bootstrap do |c|
35
+ c.action do |global_options, options, args|
36
+ raise "Must supply host" unless args.size == 1
37
+ execute_command(args.first, "sudo apt-get update; sudo apt-get install rsync ruby ruby-dev libopenssl-ruby libshadow-ruby1.8 rubygems -y; sudo gem install chef --no-ri --no-rdoc")
38
+ end
39
+ end
40
+
41
+ desc 'Sync and then run the Chef cookbooks'
42
+ command :converge do |c|
43
+ c.action do |global_options, options, args|
44
+ raise "Must supply host" unless args.size == 1
45
+ `rsync --delete -r config cookbooks roles #{USER.strip}@#{args.first}:/tmp`
46
+ execute_command(args.first, "sudo /var/lib/gems/1.8/bin/chef-solo -c /tmp/config/solo.rb -j /tmp/config/vmerize.json")
47
+ end
48
+ end
49
+
50
+ exit GLI.run(ARGV)
@@ -0,0 +1,5 @@
1
+ require "vmerize/version"
2
+
3
+ module Vmerize
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Vmerize
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/vmerize/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Gareth Rushgrove"]
6
+ gem.email = ["gareth@morethanseven.net"]
7
+ gem.homepage = 'https://github.com/garethr/vmerize'
8
+ gem.summary = 'Run your local Chef recipes against a remote machine. Quickly.'
9
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
10
+ gem.files = `git ls-files`.split("\n")
11
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
+ gem.name = "vmerize"
13
+ gem.require_paths = ["lib"]
14
+ gem.version = Vmerize::VERSION
15
+
16
+ gem.add_dependency('net-ssh')
17
+ gem.add_dependency('gli')
18
+ gem.add_dependency('highline')
19
+ gem.add_development_dependency('rake')
20
+ gem.add_development_dependency('rdoc')
21
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vmerize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gareth Rushgrove
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: net-ssh
16
+ requirement: &70274263418400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70274263418400
25
+ - !ruby/object:Gem::Dependency
26
+ name: gli
27
+ requirement: &70274263416780 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70274263416780
36
+ - !ruby/object:Gem::Dependency
37
+ name: highline
38
+ requirement: &70274263414800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70274263414800
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70274263413460 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70274263413460
58
+ - !ruby/object:Gem::Dependency
59
+ name: rdoc
60
+ requirement: &70274263412000 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70274263412000
69
+ description:
70
+ email:
71
+ - gareth@morethanseven.net
72
+ executables:
73
+ - vmerize
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - README
80
+ - Rakefile
81
+ - bin/vmerize
82
+ - lib/vmerize.rb
83
+ - lib/vmerize/version.rb
84
+ - vmerize.gemspec
85
+ homepage: https://github.com/garethr/vmerize
86
+ licenses: []
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.10
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Run your local Chef recipes against a remote machine. Quickly.
109
+ test_files: []