summaryrefslogtreecommitdiff
path: root/lib/leap_cli/remote/puppet_plugin.rb
blob: 5a6e9081c5e0d02f5cdb38b87b0f4a59ef47289e (plain)
1
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
#
# these methods are made available in capistrano tasks as 'puppet.method_name'
# (see RemoteCommand::new_capistrano)
#

module LeapCli; module Remote; module PuppetPlugin

  def apply(options)
    run "#{Leap::Platform.leap_dir}/bin/puppet_command set_hostname apply #{flagize(options)}"
  end

  private

  def flagize(hsh)
    hsh.inject([]) {|str, item|
      if item[1] === false
        str
      elsif item[1] === true
        str << "--" + item[0].to_s
      else
        str << "--" + item[0].to_s + " " + item[1].inspect
      end
    }.join(' ')
  end

end; end; end