Sha256: d739444c6049c2583bf1a20c433ff2b7eb01a0fcb3f0ed38d1a8fabf3d91c881

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

module Berkshelf
  module Vagrant
    # @author Jamie Winsor <reset@riotgames.com>
    #
    # A module of common helper functions that can be mixed into Berkshelf::Vagrant actions
    module EnvHelpers
      # A file to persist vagrant-berkshelf specific information in between
      # Vagrant runs.
      #
      # @return [String]
      def cache_file
        File.join('.vagrant', 'berkshelf')
      end

      # Filter all of the provisioners of the given vagrant environment with the given name
      #
      # @param [Symbol] name
      #   name of provisioner to filter
      # @param [Vagrant::Environment, Hash] env
      #   environment to inspect
      #
      # @return [Array]
      def provisioners(name, env)
        env[:machine].config.vm.provisioners.select { |prov| prov.name == name }
      end

      # Determine if the given vagrant environment contains a chef_solo provisioner
      #
      # @param [Vagrant::Environment] env
      #
      # @return [Boolean]
      def chef_solo?(env)
        provisioners(:chef_solo, env).any?
      end

      # Determine if the given vagrant environment contains a chef_client provisioner
      #
      # @param [Vagrant::Environment] env
      #
      # @return [Boolean]
      def chef_client?(env)
        provisioners(:chef_client, env).any?
      end

      # Determine if the Berkshelf plugin should be run for the given environment
      #
      # @param [Vagrant::Environment] env
      #
      # @return [Boolean]
      def berkshelf_enabled?(env)
        env[:global_config].berkshelf.enabled
      end

      # Determine if --no-provision was specified
      #
      # @param [Vagrant::Environment] env
      #
      # @return [Boolean]
      def provision_disabled?(env)
        env.has_key?(:provision_enabled) && !env[:provision_enabled]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-berkshelf-1.2.0 lib/berkshelf/vagrant/env_helpers.rb