Puppet Class: sensu::cli

Defined in:
manifests/cli.pp

Summary

Manage Sensu CLI

Overview

Class to manage the Sensu CLI.

Examples:

class { 'sensu::cli':
  password => 'secret',
}

Parameters:

  • version (Optional[String]) (defaults to: undef)

    Version of sensu-go-cli to install. Defaults to installed to support Windows MSI packaging and to avoid surprising upgrades.

  • package_name (String) (defaults to: 'sensu-go-cli')

    Name of Sensu CLI package.

  • install_source (Optional[Variant[Stdlib::HTTPSUrl, Stdlib::HTTPUrl, Pattern[/^(file|puppet):/]]]) (defaults to: undef)

    Source of Sensu Go CLI download for installing on Windows. Paths with http:// or https:// will be downloaded Paths with puppet:// or file:// paths will also be installed.

  • install_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Where to install sensuctl for Windows. Default to C:\Program Files\Sensu.

  • configure (Boolean) (defaults to: true)

    Determines if sensuctl should be configured

  • sensuctl_chunk_size (Optional[Integer]) (defaults to: undef)

    Chunk size to use when listing sensuctl resources

  • config_format (Optional[Enum['tabular','json','wrapped-json','yaml']]) (defaults to: undef)

    Default format for sensuctl

  • config_namespace (Optional[String]) (defaults to: undef)

    Default namespace for sensuctl



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'manifests/cli.pp', line 30

class sensu::cli (
  Optional[String] $version = undef,
  String $package_name = 'sensu-go-cli',
  Optional[Variant[Stdlib::HTTPSUrl, Stdlib::HTTPUrl, Pattern[/^(file|puppet):/]]] $install_source = undef,
  Optional[Stdlib::Absolutepath] $install_path = undef,
  Boolean $configure = true,
  Optional[Integer] $sensuctl_chunk_size = undef,
  Optional[Enum['tabular','json','wrapped-json','yaml']] $config_format = undef,
  Optional[String] $config_namespace = undef,
) {

  include sensu
  include sensu::common

  $_version = pick($version, $sensu::version)

  if $sensu::use_ssl and $configure {
    Class['sensu::ssl'] -> Sensuctl_configure['puppet']
  }

  if $facts['os']['family'] == 'windows' {
    if ! $install_source {
      fail('sensu::cli: install_source is required for Windows')
    }
    $sensuctl_path = "${install_path}\\sensuctl.exe"
    file { $install_path:
      ensure => 'directory',
    }
    archive { 'sensu-go-cli.zip':
      path         => "${install_path}\\sensu-go-cli.zip",
      source       => $install_source,
      extract      => true,
      extract_path => $install_path,
      creates      => "${install_path}\\sensuctl.exe",
      cleanup      => false,
      require      => File[$install_path],
    }
    windows_env { 'sensuctl-path':
      ensure    => 'present',
      variable  => 'PATH',
      value     => $install_path,
      mergemode => 'append',
      require   => Archive['sensu-go-cli.zip'],
    }
  } else {
    $sensuctl_path = undef
    package { 'sensu-go-cli':
      ensure  => $_version,
      name    => $package_name,
      require => $sensu::package_require,
    }
  }

  if $configure {
    sensuctl_config { 'sensu':
      chunk_size          => $sensuctl_chunk_size,
      path                => $sensuctl_path,
      validate_namespaces => $sensu::validate_namespaces,
    }

    sensuctl_configure { 'puppet':
      url              => $sensu::api_url,
      username         => 'admin',
      password         => $sensu::password,
      trusted_ca_file  => $sensu::trusted_ca_file,
      config_format    => $config_format,
      config_namespace => $config_namespace,
    }
  }
}