Defined Type: keycloak::spi_deployment

Defined in:
manifests/spi_deployment.pp

Summary

Manage Keycloak SPI deployment

Overview

}

Examples:

Add Duo SPI

keycloak::spi_deployment { 'duo-spi':
  ensure        => 'present',
  deployed_name => 'keycloak-duo-spi-jar-with-dependencies.jar',
  source        => 'file:///path/to/source/keycloak-duo-spi-jar-with-dependencies.jar',
}

Add Duo SPI and check API for existance of resources before going onto dependenct resources

keycloak::spi_deployment { 'duo-spi':
  deployed_name => 'keycloak-duo-spi-jar-with-dependencies.jar',
  source        => 'file:///path/to/source/keycloak-duo-spi-jar-with-dependencies.jar',
  test_url      => 'authentication/authenticator-providers',
  test_key      => 'id',
  test_value    => 'duo-mfa-authenticator',
  test_realm    => 'test',
  before        => Keycloak_flow_execution['duo-mfa-authenticator under form-browser-with-duo on test'],

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    State of the deployment

  • deployed_name (String[1]) (defaults to: $name)

    Name of the file to be deployed. Defaults to $name.

  • source (Variant[Stdlib::Filesource, Stdlib::HTTPSUrl])

    Source of the deployment, supports 'file://', 'puppet://', 'https://' or 'http://'

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

    URL to test for existance of resources created by this SPI

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

    Key of resource when testing for resource created by this SPI

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

    Value of the test_key when testing for resources created by this SPI

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

    Realm to query when looking for resources created by this SPI

  • test_before (Optional[Array]) (defaults to: undef)

    Setup autorequires for validator dependent resources



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
100
101
# File 'manifests/spi_deployment.pp', line 38

define keycloak::spi_deployment (
  Variant[Stdlib::Filesource, Stdlib::HTTPSUrl] $source,
  Enum['present', 'absent'] $ensure = 'present',
  String[1] $deployed_name = $name,
  Optional[String] $test_url = undef,
  Optional[String] $test_key = undef,
  Optional[String] $test_value = undef,
  Optional[String] $test_realm = undef,
  Optional[Array] $test_before = undef,
) {
  include keycloak

  $basename = basename($source)
  $dest = "${keycloak::providers_dir}/${deployed_name}"
  $tmp = "${keycloak::tmp_dir}/${basename}"

  if $ensure == 'present' {
    if $source =~ Stdlib::HTTPUrl or $source =~ Stdlib::HTTPSUrl {
      $_source = $tmp
      archive { $name:
        ensure  => 'present',
        extract => false,
        path    => $tmp,
        source  => $source,
        creates => $tmp,
        cleanup => false,
        user    => $keycloak::user,
        group   => $keycloak::group,
        require => File[$keycloak::tmp_dir],
        before  => File[$dest],
      }
    } else {
      $_source = $source
    }
    file { $dest:
      ensure  => 'file',
      source  => $_source,
      owner   => $keycloak::user,
      group   => $keycloak::group,
      mode    => '0644',
      require => Class['keycloak::install'],
      notify  => Class['keycloak::service'],
    }

    if $test_url and $test_key and $test_value {
      keycloak_resource_validator { $name:
        test_url            => $test_url,
        test_key            => $test_key,
        test_value          => $test_value,
        realm               => $test_realm,
        dependent_resources => $test_before,
        require             => Class['keycloak::service'],
      }
    }
  }

  if $ensure == 'absent' {
    file { $dest:
      ensure  => 'absent',
      require => Class['keycloak::install'],
      notify  => Class['keycloak::service'],
    }
  }
}