Puppet Class: artifactory::config

Defined in:
manifests/config.pp

Overview

Parameters:

  • db_type (Enum['derby', 'mariadb', 'mssql', 'mysql', 'oracle', 'postgresql']) (defaults to: 'postgresql')
  • db_host (Stdlib::Host) (defaults to: $artifactory::db_host)
  • db_name (String[1]) (defaults to: $artifactory::db_name)
  • db_user (String[1]) (defaults to: $artifactory::db_user)
  • db_port (Stdlib::Port) (defaults to: $artifactory::db_port)
  • db_password (Variant[ Sensitive[String[1]], String[1] ]) (defaults to: $artifactory::db_password)
  • db_url (Optional[String[1]]) (defaults to: $artifactory::db_url)
  • additional_system_config (Hash) (defaults to: $artifactory::additional_system_config)
  • binary_store_config_xml (Optional[String[1]]) (defaults to: $artifactory::binary_store_config_xml)
  • master_key (Variant[ Undef, Sensitive[Pattern[/\A(\h{32}|\h{64})\z/]], Pattern[/\A(\h{32}|\h{64})\z/] ]) (defaults to: $artifactory::master_key)
  • jvm_max_heap_size (String[1]) (defaults to: $artifactory::jvm_max_heap_size)
  • jvm_min_heap_size (String[1]) (defaults to: $artifactory::jvm_min_heap_size)
  • jvm_extra_args (Array[String[1]]) (defaults to: $artifactory::jvm_extra_args)
  • system_properties (Hash) (defaults to: $artifactory::system_properties)


2
3
4
5
6
7
8
9
10
11
12
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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'manifests/config.pp', line 2

class artifactory::config (
  Enum['derby', 'mariadb', 'mssql', 'mysql', 'oracle', 'postgresql'] $db_type = 'postgresql',
  Stdlib::Host        $db_host                  = $artifactory::db_host,
  String[1]           $db_name                  = $artifactory::db_name,
  String[1]           $db_user                  = $artifactory::db_user,
  Stdlib::Port        $db_port                  = $artifactory::db_port,
  Variant[
    Sensitive[String[1]],
    String[1]
  ]                   $db_password              = $artifactory::db_password,
  Optional[String[1]] $db_url                   = $artifactory::db_url,
  Hash                $additional_system_config = $artifactory::additional_system_config,
  Optional[String[1]] $binary_store_config_xml  = $artifactory::binary_store_config_xml,

  Variant[
    Undef,
    Sensitive[Pattern[/\A(\h{32}|\h{64})\z/]],
    Pattern[/\A(\h{32}|\h{64})\z/]
  ] $master_key = $artifactory::master_key,

  String[1]        $jvm_max_heap_size = $artifactory::jvm_max_heap_size,
  String[1]        $jvm_min_heap_size = $artifactory::jvm_min_heap_size,
  Array[String[1]] $jvm_extra_args    = $artifactory::jvm_extra_args,

  Hash $system_properties = $artifactory::system_properties
) {
  $jfrog_home = '/opt/jfrog'
  $datadir = "${jfrog_home}/artifactory/var"

  $base_config = {
    'configVersion' => 1,
    'shared'        => {
      'security' => undef,
      'node'     => undef,
      'database' => {},
      'user'     => 'artifactory',
    },
    'access'        => undef,
  }

  if $db_url {
    $_db_url = $db_url
  } else {
    $_db_url = $db_type ? {
      'postgresql'      => "jdbc:postgresql://${db_host}:${db_port}/${db_name}",
      /(mariadb|mysql)/ => "jdbc:${db_type}://${db_host}:${db_port}/${db_name}?characterEncoding=UTF-8&elideSetAutoCommits=true&useSSL=false",
      'mssql'           => "jdbc:sqlserver://${db_host}:${db_port};databaseName=${db_name};sendStringParametersAsUnicode=false;applicationName=Artifactory Binary Repository",
      'oracle'          => "jdbc:oracle:thin:@//[${db_host}][${db_port}]/${db_name}",
    }
  }

  $db_driver = $db_type ? {
    'postgresql' => 'org.postgresql.Driver',
    'mariadb'    => 'org.mariadb.jdbc.Driver',
    'mysql'      => 'com.mysql.jdbc.Driver',
    'mssql'      => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
    'oracle'     => 'oracle.jdbc.OracleDriver',
  }

  if $db_type == 'postgresql' {
    $allow_non_postgresql = false
  } else {
    $allow_non_postgresql = true
  }

  if $db_type == 'derby' {
    $db_config = {
      'allowNonPostgresql' => $allow_non_postgresql,
    }
  } else {
    $db_config = {
      'allowNonPostgresql' => $allow_non_postgresql,
      'type'               => $db_type,
      'driver'             => $db_driver,
      'url'                => $_db_url,
      'username'           => $db_user,
      'password'           => $db_password,
    }
  }

  $extra_java_opts = ([
    "-Xms${jvm_min_heap_size}",
    "-Xmx${jvm_max_heap_size}",
  ] + $jvm_extra_args).unique.join(' ')

  $master_key_file = "${datadir}/etc/security/master.key"

  if $master_key {
    file { "${datadir}/etc/security":
      ensure => directory,
      owner  => 'artifactory',
      group  => 'artifactory',
      mode   => '0640',
    }

    file { $master_key_file:
      ensure  => file,
      owner   => 'artifactory',
      group   => 'artifactory',
      mode    => '0640',
      content => Sensitive($master_key),
    }

    $key = $master_key
  } else {
    $key = $master_key_file
  }

  artifactory_yaml_file { "${datadir}/etc/system.yaml":
    ensure => present,
    config => Sensitive($base_config.deep_merge(
      { 'shared' => { 'database' => $db_config, 'extraJavaOpts' => $extra_java_opts } },
      $additional_system_config
    )),
    owner  => 'artifactory',
    group  => 'artifactory',
    mode   => '0640',
    key    => $key,
  }

  if $binary_store_config_xml {
    $binary_store_content = $binary_store_config_xml
  } else {
    $binary_store_content = file('artifactory/default-binarystore.xml')
  }

  file { "${datadir}/etc/artifactory/binarystore.xml":
    ensure  => file,
    owner   => 'artifactory',
    group   => 'artifactory',
    mode    => '0640',
    content => $binary_store_content,
  }

  $changes = $system_properties.map |$key, $value| {
    if $value == undef {
      "rm \"${key}\""
    } else {
      "set \"${key}\" \"${value}\""
    }
  }

  unless $changes.empty {
    augeas { 'artifactory.system.properties':
      context => "/files${datadir}/etc/artifactory/artifactory.system.properties",
      incl    => "${datadir}/etc/artifactory/artifactory.system.properties",
      lens    => 'Properties.lns',
      changes => $changes,
    }
  }

  artifactory_access_settings { "${datadir}/etc/access": }
}