Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add s3 support for repository #1083

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def self.process_body(body)
:type => api_object['type'],
:compress => api_object['settings']['compress'],
:location => api_object['settings']['location'],
:bucket => api_object['settings']['bucket'],
:region => api_object['settings']['region'],
:chunk_size => api_object['settings']['chunk_size'],
:max_restore_rate => api_object['settings']['max_restore_rate'],
:max_snapshot_rate => api_object['settings']['max_snapshot_rate'],
Expand All @@ -36,13 +38,15 @@ def generate_body
body = {
'type' => resource[:type],
'settings' => {
'compress' => resource[:compress],
'location' => resource[:location]
'compress' => resource[:compress]
}
}

# Add optional values
body['settings']['chunk_size'] = resource[:chunk_size] unless resource[:chunk_size].nil?
body['settings']['location'] = resource[:location] unless resource[:location].nil?
body['settings']['bucket'] = resource[:bucket] unless resource[:bucket].nil?
body['settings']['region'] = resource[:region] unless resource[:region].nil?
body['settings']['max_restore_rate'] = resource[:max_restore_rate] unless resource[:max_restore_rate].nil?
body['settings']['max_snapshot_rate'] = resource[:max_snapshot_rate] unless resource[:max_snapshot_rate].nil?

Expand Down
14 changes: 13 additions & 1 deletion lib/puppet/type/elasticsearch_snapshot_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
desc 'Repository location'
end

newproperty(:bucket) do
desc 'S3 bucket'
end

newproperty(:region) do
desc 'S3 region'
end

newproperty(:chunk_size) do
desc 'File chunk size'
end
Expand All @@ -46,6 +54,10 @@
end

validate do
raise ArgumentError, 'Location is required.' if self[:location].nil?
if self[:type] == 'fs'
raise ArgumentError, 'Location is required.' if self[:location].nil?
elsif self[:type] == 's3'
raise ArgumentError, 'Bucket is required.' if self[:bucket].nil?
end
end
end # of newtype
14 changes: 12 additions & 2 deletions manifests/snapshot_repository.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@
# Snapshot repository type.
#
# @param location
# Location of snapshots. Mandatory
# Location of snapshots.
#
# @param region
# The S3 region of the bucket to be used for snapshots.
#
# @param bucket
# The S3 name of the bucket to be used for snapshots.
#
# @param compress
# Compress the snapshot metadata files?
Expand All @@ -60,8 +66,10 @@
# @author Tyler Langlois <[email protected]>
#
define elasticsearch::snapshot_repository (
String $location,
Optional[String] $location = undef,
Enum['absent', 'present'] $ensure = 'present',
Optional[String] $bucket = undef,
Optional[String] $region = undef,
Optional[String] $api_basic_auth_password = $elasticsearch::api_basic_auth_password,
Optional[String] $api_basic_auth_username = $elasticsearch::api_basic_auth_username,
Optional[Stdlib::Absolutepath] $api_ca_file = $elasticsearch::api_ca_file,
Expand All @@ -88,6 +96,8 @@
chunk_size => $chunk_size,
compress => $compress,
location => $location,
region => $region,
bucket => $bucket,
max_restore_rate => $max_restore_rate,
max_snapshot_rate => $max_snapshot_rate,
type => $repository_type,
Expand Down