diff --git a/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb b/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb index 9b5e6e326..713b28409 100644 --- a/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb +++ b/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb @@ -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'], @@ -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? diff --git a/lib/puppet/type/elasticsearch_snapshot_repository.rb b/lib/puppet/type/elasticsearch_snapshot_repository.rb index 17357a912..c4b7fe0d4 100644 --- a/lib/puppet/type/elasticsearch_snapshot_repository.rb +++ b/lib/puppet/type/elasticsearch_snapshot_repository.rb @@ -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 @@ -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 diff --git a/manifests/snapshot_repository.pp b/manifests/snapshot_repository.pp index 1906194ea..004ef8aaa 100644 --- a/manifests/snapshot_repository.pp +++ b/manifests/snapshot_repository.pp @@ -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? @@ -60,8 +66,10 @@ # @author Tyler Langlois # 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, @@ -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,