Class: VagrantPuppetconf::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-puppetconf/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Middleware

Returns a new instance of Middleware.



3
4
5
6
# File 'lib/vagrant-puppetconf/middleware.rb', line 3

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#augeas_installed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/vagrant-puppetconf/middleware.rb', line 26

def augeas_installed?
  @env[:vm].channel.execute("dpkg -l | grep augeas-tools", :error_check => false) == 0
end

#call(env) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/vagrant-puppetconf/middleware.rb', line 8

def call(env)
  @env = env
  create_puppet_conf unless puppet_conf_exists?
  install_augeas unless augeas_installed?
  Updater.update(@env[:vm], @env[:ui], @env[:vm].config.puppetconf.updates, @env[:vm].config.puppetconf.update_only)
  @app.call env
end

#create_puppet_confObject



20
21
22
23
24
# File 'lib/vagrant-puppetconf/middleware.rb', line 20

def create_puppet_conf
  @env[:ui].warn I18n.t('vagrant.plugins.puppetconf.middleware.create_puppetconf')
  @env[:vm].channel.sudo("mkdir -p /etc/puppet")
  @env[:vm].channel.sudo("touch /etc/puppet/puppet.conf")
end

#install_augeasObject



30
31
32
33
# File 'lib/vagrant-puppetconf/middleware.rb', line 30

def install_augeas
  @env[:ui].warn I18n.t('vagrant.plugins.puppetconf.middleware.install_augeas')
  @env[:vm].channel.sudo("apt-get -y --force-yes install augeas-tools")
end

#puppet_conf_exists?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/vagrant-puppetconf/middleware.rb', line 16

def puppet_conf_exists?
  @env[:vm].channel.execute("ls /etc/puppet/puppet.conf", :error_check => false) == 0
end