Skip to content

Commit a511986

Browse files
committed
add s3 support for respository
1 parent d6d3bb6 commit a511986

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def self.process_body(body)
2121
:type => api_object['type'],
2222
:compress => api_object['settings']['compress'],
2323
:location => api_object['settings']['location'],
24+
:bucket => api_object['settings']['bucket'],
25+
:region => api_object['settings']['region'],
2426
:chunk_size => api_object['settings']['chunk_size'],
2527
:max_restore_rate => api_object['settings']['max_restore_rate'],
2628
:max_snapshot_rate => api_object['settings']['max_snapshot_rate'],
@@ -36,13 +38,15 @@ def generate_body
3638
body = {
3739
'type' => resource[:type],
3840
'settings' => {
39-
'compress' => resource[:compress],
40-
'location' => resource[:location]
41+
'compress' => resource[:compress]
4142
}
4243
}
4344

4445
# Add optional values
4546
body['settings']['chunk_size'] = resource[:chunk_size] unless resource[:chunk_size].nil?
47+
body['settings']['location'] = resource[:location] unless resource[:location].nil?
48+
body['settings']['bucket'] = resource[:bucket] unless resource[:bucket].nil?
49+
body['settings']['region'] = resource[:region] unless resource[:region].nil?
4650
body['settings']['max_restore_rate'] = resource[:max_restore_rate] unless resource[:max_restore_rate].nil?
4751
body['settings']['max_snapshot_rate'] = resource[:max_snapshot_rate] unless resource[:max_snapshot_rate].nil?
4852

lib/puppet/type/elasticsearch_snapshot_repository.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@
3333
desc 'Repository location'
3434
end
3535

36+
newproperty(:bucket) do
37+
desc 'S3 bucket'
38+
end
39+
40+
newproperty(:region) do
41+
desc 'S3 region'
42+
end
43+
3644
newproperty(:chunk_size) do
3745
desc 'File chunk size'
3846
end
@@ -46,6 +54,10 @@
4654
end
4755

4856
validate do
49-
raise ArgumentError, 'Location is required.' if self[:location].nil?
57+
if self[:type] == 'fs'
58+
raise ArgumentError, 'Location is required.' if self[:location].nil?
59+
elsif self[:type] == 's3'
60+
raise ArgumentError, 'Bucket is required.' if self[:bucket].nil?
61+
end
5062
end
5163
end # of newtype

manifests/snapshot_repository.pp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@
3737
# Snapshot repository type.
3838
#
3939
# @param location
40-
# Location of snapshots. Mandatory
40+
# Location of snapshots.
41+
#
42+
# @param region
43+
# The S3 region of the bucket to be used for snapshots.
44+
#
45+
# @param bucket
46+
# The S3 name of the bucket to be used for snapshots.
4147
#
4248
# @param compress
4349
# Compress the snapshot metadata files?
@@ -60,8 +66,10 @@
6066
# @author Tyler Langlois <[email protected]>
6167
#
6268
define elasticsearch::snapshot_repository (
63-
String $location,
69+
Optional[String] $location = undef,
6470
Enum['absent', 'present'] $ensure = 'present',
71+
Optional[String] $bucket = undef,
72+
Optional[String] $region = undef,
6573
Optional[String] $api_basic_auth_password = $elasticsearch::api_basic_auth_password,
6674
Optional[String] $api_basic_auth_username = $elasticsearch::api_basic_auth_username,
6775
Optional[Stdlib::Absolutepath] $api_ca_file = $elasticsearch::api_ca_file,
@@ -88,6 +96,8 @@
8896
chunk_size => $chunk_size,
8997
compress => $compress,
9098
location => $location,
99+
region => $region,
100+
bucket => $bucket,
91101
max_restore_rate => $max_restore_rate,
92102
max_snapshot_rate => $max_snapshot_rate,
93103
type => $repository_type,

0 commit comments

Comments
 (0)