Skip to content

Commit 8e1200b

Browse files
committed
make gpg key configurable
1 parent 4b20fc0 commit 8e1200b

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

REFERENCE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ The following parameters are available in the `elastic_stack::repo` class:
3232
* [`proxy`](#-elastic_stack--repo--proxy)
3333
* [`version`](#-elastic_stack--repo--version)
3434
* [`base_repo_url`](#-elastic_stack--repo--base_repo_url)
35+
* [`gpg_key_source`](#-elastic_stack--repo--gpg_key_source)
36+
* [`apt_keyring_name`](#-elastic_stack--repo--apt_keyring_name)
3537

3638
##### <a name="-elastic_stack--repo--oss"></a>`oss`
3739

@@ -81,3 +83,21 @@ The base url for the repo path
8183

8284
Default value: `undef`
8385

86+
##### <a name="-elastic_stack--repo--gpg_key_source"></a>`gpg_key_source`
87+
88+
Data type: `Stdlib::Filesource`
89+
90+
The gpg key for the repo
91+
92+
Default value: `'https://artifacts.elastic.co/GPG-KEY-elasticsearch'`
93+
94+
##### <a name="-elastic_stack--repo--apt_keyring_name"></a>`apt_keyring_name`
95+
96+
Data type: `String[1]`
97+
98+
The keyring filename to create (APT only)
99+
The filename extention is important here.
100+
Use `.asc` if the key is armored and `.gpg` if it's unarmored
101+
102+
Default value: `'elastic-keyring.asc'`
103+

manifests/repo.pp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@
1111
# @param proxy The URL of a HTTP proxy to use for package downloads (YUM only)
1212
# @param version The (major) version of the Elastic Stack for which to configure the repo
1313
# @param base_repo_url The base url for the repo path
14+
# @param gpg_key_source The gpg key for the repo
15+
# @param apt_keyring_name The keyring filename to create (APT only)
16+
# The filename extention is important here.
17+
# Use `.asc` if the key is armored and `.gpg` if it's unarmored
1418
class elastic_stack::repo (
15-
Boolean $oss = false,
16-
Boolean $prerelease = false,
17-
Optional[Integer] $priority = undef,
18-
String $proxy = 'absent',
19-
Integer $version = 7,
20-
Optional[String] $base_repo_url = undef,
19+
Boolean $oss = false,
20+
Boolean $prerelease = false,
21+
Optional[Integer] $priority = undef,
22+
String $proxy = 'absent',
23+
Integer $version = 7,
24+
Stdlib::Filesource $gpg_key_source = 'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
25+
String[1] $apt_keyring_name = 'elastic-keyring.asc',
26+
Optional[String] $base_repo_url = undef,
2127
) {
2228
if $prerelease {
2329
$version_suffix = '.x-prerelease'
@@ -60,7 +66,6 @@
6066
}
6167

6268
$base_url = "${_repo_url}/${version_prefix}${version}${version_suffix}/${_repo_path}"
63-
$key_source='https://artifacts.elastic.co/GPG-KEY-elasticsearch'
6469
$description='Elastic package repository.'
6570

6671
case $facts['os']['family'] {
@@ -73,8 +78,8 @@
7378
release => 'stable',
7479
repos => 'main',
7580
key => {
76-
'name' => 'elastic.asc',
77-
'source' => $key_source,
81+
'name' => $apt_keyring_name,
82+
'source' => $gpg_key_source,
7883
},
7984
pin => $priority,
8085
}
@@ -84,7 +89,7 @@
8489
descr => $description,
8590
baseurl => $base_url,
8691
gpgcheck => 1,
87-
gpgkey => $key_source,
92+
gpgkey => $gpg_key_source,
8893
enabled => 1,
8994
proxy => $proxy,
9095
priority => $priority,
@@ -100,10 +105,10 @@
100105
'Suse': {
101106
# Older versions of SLES do not ship with rpmkeys
102107
if $facts['os']['name'] == 'SLES' and versioncmp($facts['os']['release']['major'], '11') <= 0 {
103-
$_import_cmd = "rpm --import ${key_source}"
108+
$_import_cmd = "rpm --import ${gpg_key_source}"
104109
}
105110
else {
106-
$_import_cmd = "rpmkeys --import ${key_source}"
111+
$_import_cmd = "rpmkeys --import ${gpg_key_source}"
107112
}
108113

109114
exec { 'elastic_suse_import_gpg':
@@ -120,7 +125,7 @@
120125
autorefresh => 1,
121126
name => 'elastic',
122127
gpgcheck => 1,
123-
gpgkey => $key_source,
128+
gpgkey => $gpg_key_source,
124129
type => 'yum',
125130
priority => $priority,
126131
}

0 commit comments

Comments
 (0)