Sha256: d49eda2f3b1a66d713e6af1c52855439f944dd4af5956dee9571e31f5c0e7408

Contents?: true

Size: 1.99 KB

Versions: 7

Compression:

Stored size: 1.99 KB

Contents

module VagrantPlugins
  module Chef
    module Config
      class Base < Vagrant.plugin("2", :config)
        # Shared config
        attr_accessor :node_name
        attr_accessor :provisioning_path
        attr_accessor :log_level
        attr_accessor :json
        attr_accessor :http_proxy
        attr_accessor :http_proxy_user
        attr_accessor :http_proxy_pass
        attr_accessor :https_proxy
        attr_accessor :https_proxy_user
        attr_accessor :https_proxy_pass
        attr_accessor :no_proxy
        attr_accessor :binary_path
        attr_accessor :binary_env
        attr_accessor :attempts
        attr_accessor :arguments
        attr_writer :run_list

        # Provide defaults in such a way that they won't override the instance
        # variable. This is so merging continues to work properly.
        def attempts; @attempts || 1; end
        def json; @json ||= {}; end
        def log_level; @log_level || :info; end

        # This returns the json that is merged with the defaults and the
        # user set data.
        def merged_json
          original = { :instance_role => "vagrant" }
          original[:run_list] = @run_list if @run_list
          original.merge(json || {})
        end

        # Returns the run list, but also sets it up to be empty if it
        # hasn't been defined already.
        def run_list
          @run_list ||= []
        end

        # Adds a recipe to the run list
        def add_recipe(name)
          name = "recipe[#{name}]" unless name =~ /^recipe\[(.+?)\]$/
            run_list << name
        end

        # Adds a role to the run list
        def add_role(name)
          name = "role[#{name}]" unless name =~ /^role\[(.+?)\]$/
            run_list << name
        end

        def instance_variables_hash
          # Overridden so that the 'json' key could be removed, since its just
          # merged into the config anyways
          result = super
          result.delete("json")
          result
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
vagrantup-1.1.3 plugins/provisioners/chef/config/base.rb
vagrantup-1.1.2 plugins/provisioners/chef/config/base.rb
vagrantup-1.1.1 plugins/provisioners/chef/config/base.rb
vagrantup-1.1.0 plugins/provisioners/chef/config/base.rb
vagrantup-1.1.4 plugins/provisioners/chef/config/base.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/plugins/provisioners/chef/config/base.rb
vagrant-lxc-0.0.1 vendor/vagrant/plugins/provisioners/chef/config/base.rb