Module: Berkshelf::Vagrant::EnvHelpers
- Included in:
- Action::Clean, Action::ConfigureChef, Action::Install, Action::LoadShelf, Action::Upload
- Defined in:
- lib/berkshelf/vagrant/env_helpers.rb
Overview
A module of common helper functions that can be mixed into Berkshelf::Vagrant actions
Instance Method Summary collapse
-
#berkshelf_enabled?(env) ⇒ Boolean
Determine if the Berkshelf plugin should be run for the given environment.
-
#cache_file(env) ⇒ String
A file to persist vagrant-berkshelf specific information in between Vagrant runs.
-
#chef_client?(env) ⇒ Boolean
Determine if the given vagrant environment contains a chef_client provisioner.
-
#chef_solo?(env) ⇒ Boolean
Determine if the given vagrant environment contains a chef_solo provisioner.
-
#provision_disabled?(env) ⇒ Boolean
Determine if –no-provision was specified.
-
#provisioners(name, env) ⇒ Array
Filter all of the provisioners of the given vagrant environment with the given name.
Instance Method Details
#berkshelf_enabled?(env) ⇒ Boolean
Determine if the Berkshelf plugin should be run for the given environment
50 51 52 |
# File 'lib/berkshelf/vagrant/env_helpers.rb', line 50 def berkshelf_enabled?(env) env[:global_config].berkshelf.enabled end |
#cache_file(env) ⇒ String
A file to persist vagrant-berkshelf specific information in between Vagrant runs.
11 12 13 |
# File 'lib/berkshelf/vagrant/env_helpers.rb', line 11 def cache_file(env) File.join('.vagrant', 'machines', env[:machine].name.to_s, 'berkshelf') end |
#chef_client?(env) ⇒ Boolean
Determine if the given vagrant environment contains a chef_client provisioner
41 42 43 |
# File 'lib/berkshelf/vagrant/env_helpers.rb', line 41 def chef_client?(env) provisioners(:chef_client, env).any? end |
#chef_solo?(env) ⇒ Boolean
Determine if the given vagrant environment contains a chef_solo provisioner
32 33 34 |
# File 'lib/berkshelf/vagrant/env_helpers.rb', line 32 def chef_solo?(env) provisioners(:chef_solo, env).any? end |
#provision_disabled?(env) ⇒ Boolean
Determine if –no-provision was specified
59 60 61 |
# File 'lib/berkshelf/vagrant/env_helpers.rb', line 59 def provision_disabled?(env) env.has_key?(:provision_enabled) && !env[:provision_enabled] end |
#provisioners(name, env) ⇒ Array
Filter all of the provisioners of the given vagrant environment with the given name
23 24 25 |
# File 'lib/berkshelf/vagrant/env_helpers.rb', line 23 def provisioners(name, env) env[:machine].config.vm.provisioners.select { |prov| prov.name == name } end |