Defined Type: st2::client::settings

Defined in:
manifests/client/settings.pp

Summary

Generates a configuration file for the st2 CLI (st2client)

Overview

Examples:

Basic usage

st2::client::settings { 'john':
  username => 'st2_john',
  password => 'xyz123',
}

Parameters:

  • name

    OS-level username. Used to determine where the config file will be placed.

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

    See name

  • homedir (Any) (defaults to: "/home/${name}")

    Path to home directory of the user.

  • auth (Any) (defaults to: $st2::auth)

    Is auth enabled or not.

  • api_url (Any) (defaults to: $st2::cli_api_url)

    URL of the StackStorm API service

  • auth_url (Any) (defaults to: $st2::cli_auth_url)

    URL of the StackStorm Auth service

  • base_url (Any) (defaults to: $st2::cli_base_url)

    Base URL for other StackStorm services

  • username (Any) (defaults to: $st2::cli_username)

    Username for auth on the CLI

  • password (Any) (defaults to: $st2::cli_password)

    Password for auth on the CLI

  • disable_credentials (Any) (defaults to: false)

    Prevents credentials (username, password) from being written to the config file

  • api_version (Any) (defaults to: $st2::cli_api_version)

    Version of the StackStorm API

  • cacert (Any) (defaults to: $st2::cli_cacert)

    Path to the SSL CA certficate for the StackStorm services

  • debug (Any) (defaults to: $st2::cli_debug)

    Enable debug mode

  • cache_token (Any) (defaults to: $st2::cli_cache_token)

    Enable cacheing authentication tokens until they expire

  • silence_ssl_warnings (Any) (defaults to: $st2::cli_silence_ssl_warnings)

    Enable silencing SSL warnings for self-signed certs



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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'manifests/client/settings.pp', line 40

define st2::client::settings(
  $user                 = $name,
  $homedir              = "/home/${name}",
  $auth                 = $st2::auth,
  $api_url              = $st2::cli_api_url,
  $auth_url             = $st2::cli_auth_url,
  $base_url             = $st2::cli_base_url,
  $username             = $st2::cli_username,
  $password             = $st2::cli_password,
  $disable_credentials  = false,
  $api_version          = $st2::cli_api_version,
  $cacert               = $st2::cli_cacert,
  $debug                = $st2::cli_debug,
  $cache_token          = $st2::cli_cache_token,
  $silence_ssl_warnings = $st2::cli_silence_ssl_warnings,
) {
  Ini_setting {
    ensure  => present,
    path    => "${homedir}/.st2/config",
    require => File["${homedir}/.st2"],
  }

  file { "${homedir}/.st2":
    ensure => directory,
    owner  => $user,
    mode   => '0700',
  }

  ini_setting { "${user}-st2_cli_api_url":
    section => 'api',
    setting => 'url',
    value   => $api_url,
  }
  ini_setting { "${user}-st2_cli_general_base_url":
    section => 'general',
    setting => 'base_url',
    value   => $base_url,
  }
  ini_setting { "${user}-st2_cli_general_api_version":
    section => 'general',
    setting => 'api_version',
    value   => $api_version,
  }
  ini_setting { "${user}-st2_cli_general_cacert":
    section => 'general',
    setting => 'cacert',
    value   => $cacert,
  }

  $_cli_debug = $debug ? {
    true    => 'True',
    default => 'False',
  }
  ini_setting { "${user}-st2_cli_cli_debug":
    section => 'cli',
    setting => 'debug',
    value   => $_cli_debug,
  }
  $_cache_token = $cache_token ? {
    true    => 'True',
    default => 'False',
  }
  ini_setting { "${user}-st2_cli_cache_token":
    section => 'cli',
    setting => 'cache_token',
    value   => $_cache_token,
  }
  $_silence_ssl_warnings = $silence_ssl_warnings ? {
    true    => 'True',
    default => 'False',
  }
  ini_setting { "${user}-st2_general_silence_ssl_warnings":
    section => 'general',
    setting => 'silence_ssl_warnings',
    value   => $_silence_ssl_warnings,
  }
  if $auth {
    if ! $disable_credentials {
      ini_setting { "${user}-st2_cli_credentials_username":
        section => 'credentials',
        setting => 'username',
        value   => $username,
      }
      ini_setting { "${user}-st2_cli_credentials_password":
        section => 'credentials',
        setting => 'password',
        value   => $password,
      }
    }
    ini_setting { "${user}-st2_cli_auth_url":
      section => 'auth',
      setting => 'url',
      value   => $auth_url,
    }
  }
}