Puppet Function: salt_key_status

Defined in:
lib/puppet/functions/salt_key_status.rb
Function type:
Ruby 4.x API

Overview

salt_key_status(String $arg)Any

Parameters:

  • arg (String)

Returns:

  • (Any)


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
# File 'lib/puppet/functions/salt_key_status.rb', line 1

Puppet::Functions.create_function(:salt_key_status) do |args|
  dispatch :salt_key_status do
    param 'String', :arg
  end

  def salt_key_status(arg)
    # salt-key -L --out=txt | grep "'centos7.vm'" | cut -f 1 -d:
    command = ['/usr/bin/salt-key -L --out=txt 2>/dev/null | grep']
    command.push("\"'" + arg + "'\"")
    command.push("| cut -f 1 -d:")

    command = command.join ' '

    output = Puppet::Util::Execution.execute(command, {
      :uid                => 'root',
      :gid                => 'root',
      :failonfail         => false,
      :combine            => true,
      :override_locale    => true,
    })

    return output
  end

end