vagrant-puppet-scp 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.
data/.gitignore ADDED
@@ -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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-puppet-scp.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 W. Andrew Loe III
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Vagrant::Puppet::Scp
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'vagrant-puppet-scp'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install vagrant-puppet-scp
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ require_relative 'scp/version'
2
+ require 'vagrant'
3
+
4
+ module Vagrant
5
+ module Puppet
6
+ module Scp
7
+ class Plugin < Vagrant.plugin('2')
8
+ name 'puppet_scp'
9
+ description <<-DESC
10
+ Provides support for provisioning your virtual machines with
11
+ Puppet using `puppet apply`. Manifests are copied using SCP.
12
+ DESC
13
+
14
+ config(:puppet_scp, :provisioner) do
15
+ require_relative 'scp/config'
16
+ Config
17
+ end
18
+
19
+ provisioner(:puppet_scp) do
20
+ require_relative 'scp/provisioner'
21
+ Provisioner
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,80 @@
1
+ module Vagrant
2
+ module Puppet
3
+ module Scp
4
+ class Config < Vagrant.plugin('2', :config)
5
+ attr_accessor :manifest_file
6
+ attr_accessor :manifests_path
7
+ attr_accessor :modules_path
8
+ attr_accessor :guest_path
9
+ attr_accessor :options
10
+ attr_accessor :facter
11
+
12
+ def initialize
13
+ super
14
+
15
+ @manifest_file = UNSET_VALUE
16
+ @manifests_path = UNSET_VALUE
17
+ @modules_path = UNSET_VALUE
18
+ @guest_path = UNSET_VALUE
19
+ @options = []
20
+ @facter = {}
21
+ end
22
+
23
+ def finalize!
24
+ super
25
+
26
+ @manifest_file = 'default.pp' if @manifest_file == UNSET_VALUE
27
+ @manifests_path = 'manifests' if @manifests_path == UNSET_VALUE
28
+ @modules_path = 'modules' if @modules_path == UNSET_VALUE
29
+ @guest_path = '/etc/puppet' if @guest_path == UNSET_VALUE
30
+ end
31
+
32
+ def expanded_manifests_path(root_path)
33
+ Pathname.new(manifests_path).expand_path(root_path)
34
+ end
35
+
36
+ def expanded_modules_path(root_path)
37
+ Pathname.new(modules_path).expand_path(root_path)
38
+ end
39
+
40
+ def manifests_guest_path
41
+ File.join(guest_path, 'manifests')
42
+ end
43
+
44
+ def modules_guest_path
45
+ File.join(guest_path, 'modules')
46
+ end
47
+
48
+ def validate(machine)
49
+ errors = []
50
+
51
+ # Calculate the manifests and module paths based on env
52
+ this_expanded_manifests_path = expanded_manifests_path(machine.env.root_path)
53
+ this_expanded_modules_path = expanded_modules_path(machine.env.root_path)
54
+
55
+ # Manifests path/file validation
56
+ # TODO: Provide vagrant.provisioners.puppet_scp translations.
57
+ if !this_expanded_manifests_path.directory?
58
+ errors << I18n.t("vagrant.provisioners.puppet.manifests_path_missing",
59
+ :path => this_expanded_manifests_path)
60
+ else
61
+ expanded_manifest_file = this_expanded_manifests_path.join(manifest_file)
62
+ if !expanded_manifest_file.file?
63
+ errors << I18n.t("vagrant.provisioners.puppet.manifest_missing",
64
+ :manifest => expanded_manifest_file.to_s)
65
+ end
66
+ end
67
+
68
+ # Module paths validation
69
+ if !this_expanded_modules_path.directory?
70
+ errors << I18n.t("vagrant.provisioners.puppet.module_path_missing",
71
+ :path => path)
72
+ end
73
+
74
+ { "puppet_scp provisioner" => errors }
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
@@ -0,0 +1,105 @@
1
+ require 'log4r'
2
+
3
+ module Vagrant
4
+ module Puppet
5
+ module Scp
6
+ class PuppetScpError < Vagrant::Errors::VagrantError
7
+ error_namespace('vagrant.provisioners.puppet_scp')
8
+ end
9
+
10
+ class Provisioner < Vagrant.plugin(2, :provisioner)
11
+ def initialize(machine, config)
12
+ super
13
+
14
+ @logger = Log4r::Logger.new('vagrant::provisioners::puppet_scp')
15
+ end
16
+
17
+ def configure(root_config)
18
+ # Calculate the paths we're going to use based on the environment
19
+ root_path = @machine.env.root_path
20
+ @expanded_manifests_path = @config.expanded_manifests_path(root_path)
21
+ @expanded_modules_path = @config.expanded_modules_path(root_path)
22
+ @manifest_file = File.join(@config.manifests_guest_path, @config.manifest_file)
23
+ end
24
+
25
+ def provision
26
+ create_guest_path
27
+ share_manifests
28
+ share_modules
29
+ verify_binary('puppet')
30
+ run_puppet_apply
31
+ end
32
+
33
+ def create_guest_path
34
+ @machine.communicate.tap do |comm|
35
+ comm.sudo("mkdir -p #{@config.guest_path}")
36
+ comm.sudo("chown -R #{@machine.ssh_info[:username]} #{@config.guest_path}")
37
+ end
38
+ end
39
+
40
+ def share_manifests
41
+ recursive_scp(@expanded_manifests_path, @config.manifests_guest_path)
42
+ end
43
+
44
+ def share_modules
45
+ recursive_scp(@expanded_modules_path, @config.modules_guest_path)
46
+ end
47
+
48
+ def verify_binary(binary)
49
+ @machine.communicate.sudo(
50
+ "which #{binary}",
51
+ :error_class => PuppetScpError,
52
+ :error_key => :not_detected,
53
+ :binary => binary)
54
+ end
55
+
56
+ def run_puppet_apply
57
+ options = [config.options].flatten
58
+ options << "--modulepath '#{@config.modules_guest_path}'" if !@config.modules_guest_path.empty?
59
+ options << @manifest_file
60
+ options = options.join(" ")
61
+
62
+ # Build up the custom facts if we have any
63
+ facter = ""
64
+ if !config.facter.empty?
65
+ facts = []
66
+ config.facter.each do |key, value|
67
+ facts << "FACTER_#{key}='#{value}'"
68
+ end
69
+
70
+ facter = "#{facts.join(" ")} "
71
+ end
72
+
73
+ command = "#{facter}puppet apply #{options} || [ $? -eq 2 ]"
74
+
75
+ @machine.env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet",
76
+ :manifest => @config.manifest_file)
77
+
78
+ @machine.communicate.sudo(command) do |type, data|
79
+ data.chomp!
80
+ @machine.env.ui.info(data, :prefix => false) if !data.empty?
81
+ end
82
+ end
83
+
84
+ def recursive_scp(from, to)
85
+ @machine.communicate.tap do |comm|
86
+ comm.sudo("rm -rf #{to}")
87
+ comm.sudo("mkdir -p #{to}")
88
+ comm.sudo("chown #{@machine.ssh_info[:username]} #{to}")
89
+ end
90
+
91
+ Dir.glob("#{from}/**/*") do |path|
92
+ to_path = path.gsub(from.to_s, '') # Remove the local cruft
93
+
94
+ if File.directory?(path)
95
+ @machine.communicate.execute("mkdir -p #{to}#{to_path}")
96
+ else
97
+ @machine.communicate.upload(path, "#{to}#{to_path}")
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+
@@ -0,0 +1,7 @@
1
+ module Vagrant
2
+ module Puppet
3
+ module Scp
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant/puppet/scp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-puppet-scp"
8
+ spec.version = Vagrant::Puppet::Scp::VERSION
9
+ spec.authors = ["W. Andrew Loe III"]
10
+ spec.email = ["andrew@andrewloe.com"]
11
+ spec.description = %q{A puppet apply provisioner for Vagrant that uses SCP instead of shared directories.}
12
+ spec.summary = %q{A puppet apply provisioner for Vagrant that uses SCP instead of shared directories.}
13
+ spec.homepage = "https://github.com/loe/vagrant-puppet-scp"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-puppet-scp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - W. Andrew Loe III
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
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: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
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
+ description: A puppet apply provisioner for Vagrant that uses SCP instead of shared
47
+ directories.
48
+ email:
49
+ - andrew@andrewloe.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/vagrant/puppet/scp.rb
60
+ - lib/vagrant/puppet/scp/config.rb
61
+ - lib/vagrant/puppet/scp/provisioner.rb
62
+ - lib/vagrant/puppet/scp/version.rb
63
+ - vagrant-puppet-scp.gemspec
64
+ homepage: https://github.com/loe/vagrant-puppet-scp
65
+ licenses:
66
+ - MIT
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ segments:
78
+ - 0
79
+ hash: 675507941066642747
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ segments:
87
+ - 0
88
+ hash: 675507941066642747
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 1.8.23
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: A puppet apply provisioner for Vagrant that uses SCP instead of shared directories.
95
+ test_files: []