Class: VagrantPuppetconf::Middleware
- Inherits:
-
Object
- Object
- VagrantPuppetconf::Middleware
- Defined in:
- lib/vagrant-puppetconf/middleware.rb
Instance Method Summary collapse
- #augeas_installed? ⇒ Boolean
- #call(env) ⇒ Object
- #create_puppet_conf ⇒ Object
-
#initialize(app, env) ⇒ Middleware
constructor
A new instance of Middleware.
- #install_augeas ⇒ Object
- #puppet_conf_exists? ⇒ Boolean
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
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_conf ⇒ Object
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_augeas ⇒ Object
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
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 |