vagrant-librarian-puppet-plugin 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -22,12 +22,20 @@ simply set up your Puppetfile as you normally would.
22
22
  You may specify the subdirectory within which to run `librarian-puppet`
23
23
  using the `librarian_puppet.puppetfile_dir` config key. Please keep in mind
24
24
  that you will need to explicitly set the `modules` path in the
25
- `:puppet` provisioner and this path must exist before running vagrant commands:
25
+ `:puppet` provisioner and this path must exist before running vagrant commands.
26
+
27
+ **NOTE:** Since the puppet provisioner will fail if the path provided to
28
+ "puppet.modules" doesn't exist and librarian-puppet will destroy and recreate
29
+ the modules directory on each run, this plugin supports a placeholder file
30
+ within the modules directory that can be checked into version control and will
31
+ persist between provisions.
26
32
 
27
33
  ```ruby
28
34
  Vagrant.configure("2") do |config|
29
35
 
30
36
  config.librarian_puppet.puppetfile_dir = "puppet"
37
+ # placeholder_filename defaults to .PLACEHOLDER
38
+ config.librarian_puppet.placeholder_filename = ".MYPLACEHOLDER"
31
39
 
32
40
  config.vm.provision :puppet do |puppet|
33
41
  puppet.modules = "puppet/modules"
@@ -27,6 +27,19 @@ module VagrantPlugins
27
27
  bin_path = env[:gems_path].join('bin')
28
28
  ENV['PATH'] = "#{bin_path}#{::File::PATH_SEPARATOR}#{ENV['PATH']}"
29
29
 
30
+ # Determine if we need to persist placeholder file
31
+ placeholder_file = File.join(
32
+ env[:root_path],
33
+ config.puppetfile_dir,
34
+ 'modules',
35
+ config.placeholder_filename
36
+ )
37
+ if File.exist? placeholder_file
38
+ placeholder_contents = File.read(placeholder_file)
39
+ else
40
+ placeholder_contents = nil
41
+ end
42
+
30
43
  environment = Librarian::Puppet::Environment.new({
31
44
  :project_path => File.join(env[:root_path], config.puppetfile_dir)
32
45
  })
@@ -36,6 +49,14 @@ module VagrantPlugins
36
49
 
37
50
  # Restore the original path
38
51
  ENV['PATH'] = original_path
52
+
53
+ # Persist placeholder if necessary
54
+ if placeholder_contents != nil
55
+ File.open(placeholder_file, 'w') { |file|
56
+ file.write(placeholder_contents)
57
+ }
58
+ end
59
+
39
60
  end
40
61
  @app.call(env)
41
62
  end
@@ -2,13 +2,16 @@ module VagrantPlugins
2
2
  module LibrarianPuppet
3
3
  class Config < Vagrant.plugin(2, :config)
4
4
  attr_accessor :puppetfile_dir
5
+ attr_accessor :placeholder_filename
5
6
 
6
7
  def initialize
7
8
  @puppetfile_dir = UNSET_VALUE
9
+ @placeholder_filename = UNSET_VALUE
8
10
  end
9
11
 
10
12
  def finalize!
11
13
  @puppetfile_dir = '.' if @puppetfile_dir == UNSET_VALUE
14
+ @placeholder_filename = '.PLACEHOLDER' if @placeholder_filename == UNSET_VALUE
12
15
  end
13
16
 
14
17
  def puppetfile_path
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module LibrarianPuppet
3
- VERSION = "0.1.3"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-librarian-puppet-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: