Defined Type: st2::kv

Defined in:
manifests/kv.pp

Summary

Sets a value to the StackStorm Key/Value Store

Overview

Examples:

Basic usage

st2::kv { 'install_uuid':
  value => $_uuid,
}

Parameters:

  • key (Any) (defaults to: $name)

    Key to set

  • value (Any)

    Value of key

  • ensure (Any) (defaults to: present)
  • apikey (Any) (defaults to: $st2::cli_apikey)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'manifests/kv.pp', line 13

define st2::kv (
  $value,
  $ensure = present,
  $key    = $name,
  $apikey = $st2::cli_apikey,
) {
  include st2

  if $apikey {
    $_cmd_flags = "--api-key ${apikey}"
  }
  else {
    $_cmd_flags = ''
  }
  $_command = "st2 key set ${_cmd_flags} ${key} ${value}"
  $_unless = "st2 key get ${_cmd_flags} ${key} | grep ${key}"
  exec { "set-st2-key-${key}":
    command   => $_command,
    unless    => $_unless,
    path      => '/usr/sbin:/usr/bin:/sbin:/bin',
    tries     => '5',
    try_sleep => '10',
  }

  Service<| tag == 'st2::service' |> -> Exec["set-st2-key-${key}"]
  Exec<| tag == 'st2::reload' |> ~> Exec["set-st2-key-${key}"]
}