Module: Ra10ke::Install

Included in:
RakeTask
Defined in:
lib/ra10ke/install.rb

Instance Method Summary collapse

Instance Method Details

#define_task_install(*_args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ra10ke/install.rb', line 2

def define_task_install(*_args)
  desc 'Install modules specified in Puppetfile'
  task :install do
    require 'r10k/puppetfile'

    puppetfile = get_puppetfile
    puppetfile.load!

    puts 'Processing Puppetfile for fixtures'
    puppetfile.modules.each do |mod|
      if mod.status == :insync
        puts "Skipping #{mod.name} (#{mod.version}) already in sync"
      else
        msg = if mod.status == :absent
                "installed #{mod.name}"
              else
                "updated #{mod.name} from #{mod.version} to"
              end
        mod.sync
        if mod.status == :insync
          puts "Successfully #{msg} #{mod.version}".green
        else
          puts "Failed to sync #{mod.name}".red
        end
      end
    end

    puppetfile.purge! if @purge
  end
end