Sha256: f57cef217efa3228989068b9e90bf1aafc7dda13a3bc5f26e9b68556d87887b3

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

require 'rbconfig'

module VagrantPlugins
  module Invade
    module Validator
      module Provision

        # (see: https://docs.vagrantup.com/v2/provisioning/puppet_apply.html)
        class PuppetApply

          attr_accessor :env
          attr_accessor :puppet_apply

          DEFAULT = {
            'modules_path' => '.puppet/modules',
            'manifests_path' => './puppet/manifests',
            'manifest_file' => 'init.pp',
            'hiera_config_path' => nil,
            'facter' => {}
          }

          def initialize(env, puppet_apply)
            @env = env
            @puppet_apply = puppet_apply
            @invade = env[:invade]
          end

          def validate
            return nil unless @puppet_apply

            # MODULES PATH
            @puppet_apply['modules_path'] = Validator.validate_array(
              @puppet_apply['modules_path'], 'modules_path', DEFAULT['modules_path']
            )

            # MANIFESTS PATH
            @puppet_apply['manifests_path'] = Validator.validate_string(
              @puppet_apply['manifests_path'], 'manifests_path', DEFAULT['manifests_path']
            )

            # MANIFEST FILE
            @puppet_apply['manifest_file'] = Validator.validate_string(
              @puppet_apply['manifest_file'], 'manifest_file', DEFAULT['manifest_file']
            )

            # HIERA CONFIG PATH
            @puppet_apply['hiera_config_path'] = Validator.validate_string(
              @puppet_apply['hiera_config_path'], 'hiera_config_path', DEFAULT['hiera_config_path']
            )

            # FACTER
            @puppet_apply['facter'] = Validator.validate_hash(
              @puppet_apply['facter'], 'facter', DEFAULT['facter']
            )

            @puppet_apply
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-invade-0.4.1 lib/vagrant-invade/validator/provision/puppet_apply.rb
vagrant-invade-0.4.0 lib/vagrant-invade/validator/provision/puppet_apply.rb