vagrant-chef-apply 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,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
@@ -0,0 +1,2 @@
1
+ vagrant-chef-apply
2
+ ==================
@@ -0,0 +1 @@
1
+ require "vagrant-chef-apply/plugin"
@@ -0,0 +1,43 @@
1
+ module VagrantPlugins
2
+ module ChefApply
3
+ class Config < Vagrant.plugin("2", :config)
4
+ attr_accessor :path
5
+ attr_accessor :upload_path
6
+
7
+ def initialize
8
+ @path = UNSET_VALUE
9
+ @upload_path = UNSET_VALUE
10
+ end
11
+
12
+ def finalize!
13
+ @path = nil if @path == UNSET_VALUE
14
+ @upload_path = "/tmp/vagrant-chef-apply.rb" if @upload_path == UNSET_VALUE
15
+ end
16
+
17
+ def validate(machine)
18
+ errors = _detected_errors
19
+
20
+ # Validate that the parameters are properly set
21
+ unless path
22
+ errors << I18n.t("vagrant.provisioners.chef_apply.no_path_set")
23
+ end
24
+
25
+ # Validate the existence of a script to upload
26
+ if path
27
+ expanded_path = Pathname.new(path).expand_path(machine.env.root_path)
28
+ if !expanded_path.file?
29
+ errors << I18n.t("vagrant.provisioners.chef_apply.path_invalid",
30
+ :path => expanded_path)
31
+ end
32
+ end
33
+
34
+ # There needs to be a path to upload the script to
35
+ if !upload_path
36
+ errors << I18n.t("vagrant.provisioners.chef_apply.upload_path_not_set")
37
+ end
38
+
39
+ { "chef_apply provisioner" => errors }
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,23 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module ChefApply
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "chef-apply"
7
+ description <<-DESC
8
+ Provides support for provisioning your virtual machines with
9
+ chef-apply.
10
+ DESC
11
+
12
+ config(:chef_apply, :provisioner) do
13
+ require File.expand_path("../config", __FILE__)
14
+ Config
15
+ end
16
+
17
+ provisioner(:chef_apply) do
18
+ require File.expand_path("../provisioner", __FILE__)
19
+ Provisioner
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,37 @@
1
+ require "pathname"
2
+ require "tempfile"
3
+
4
+ module VagrantPlugins
5
+ module ChefApply
6
+ class Provisioner < Vagrant.plugin("2", :provisioner)
7
+ def provision
8
+ command = "chmod +x #{config.upload_path} && chef-apply #{config.upload_path}"
9
+
10
+ # Upload the script to the machine
11
+ @machine.communicate.tap do |comm|
12
+ # Reset upload path permissions for the current ssh user
13
+ user = @machine.ssh_info[:username]
14
+ comm.sudo("chown -R #{user} #{config.upload_path}",
15
+ :error_check => false)
16
+
17
+ comm.upload(config.path, config.upload_path)
18
+
19
+ @machine.ui.info(I18n.t("vagrant.provisioners.chef_apply.running",
20
+ script: config.path))
21
+
22
+ # Execute it with sudo
23
+ comm.sudo(command) do |type, data|
24
+ if [:stderr, :stdout].include?(type)
25
+ # Output the data with the proper color based on the stream.
26
+ color = type == :stdout ? :green : :red
27
+
28
+ # Note: Be sure to chomp the data to avoid the newlines that the
29
+ # Chef outputs.
30
+ @machine.env.ui.info(data.chomp, :color => color, :prefix => false)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "vagrant-chef-apply"
5
+ spec.version = '0.0.1'
6
+ spec.authors = [ "Brian Akins" ]
7
+ spec.email = [ "brian@akins.org" ]
8
+ spec.description = %q{A Vagrant plugin to add simple chef-apply provisioner}
9
+ spec.summary = spec.description
10
+ spec.homepage = "https://github.com/bakins/vagrant-chef-apply"
11
+ spec.license = "Apache 2.0"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+ spec.required_ruby_version = ">= 1.9.1"
18
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-chef-apply
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brian Akins
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A Vagrant plugin to add simple chef-apply provisioner
15
+ email:
16
+ - brian@akins.org
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - README.md
23
+ - lib/vagrant-chef-apply.rb
24
+ - lib/vagrant-chef-apply/config.rb
25
+ - lib/vagrant-chef-apply/plugin.rb
26
+ - lib/vagrant-chef-apply/provisioner.rb
27
+ - vagrant-chef-apply.gemspec
28
+ homepage: https://github.com/bakins/vagrant-chef-apply
29
+ licenses:
30
+ - Apache 2.0
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.9.1
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.23
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: A Vagrant plugin to add simple chef-apply provisioner
53
+ test_files: []
54
+ has_rdoc: