diff --git a/README.md b/README.md index 9f32ab948..ab54d9151 100644 --- a/README.md +++ b/README.md @@ -432,6 +432,22 @@ elasticsearch::snapshot_repository { 'backups': } ``` +```elasticsearch::snapshot_repository { azure_backups: + type => 'azure', + container => 'elasticsearch_backups, + api_protocol => 'https', + api_host => $::ipaddress, + api_port => 9201, + api_timeout => 60, + api_basic_auth_username => 'admin', + api_basic_auth_password => 'adminpassword', + api_ca_file => '/etc/ssl/certs', + api_ca_path => '/etc/pki/certs', + validate_tls => false, + + } +``` + #### Delete a snapshot repository ```puppet diff --git a/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb b/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb index 9b5e6e326..d7cd8d3ad 100644 --- a/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb +++ b/lib/puppet/provider/elasticsearch_snapshot_repository/ruby.rb @@ -21,6 +21,11 @@ def self.process_body(body) :type => api_object['type'], :compress => api_object['settings']['compress'], :location => api_object['settings']['location'], + :container => api_object['settings']['container'], + :base_path => api_object['settings']['base_path'], + :client => api_object['settings']['client'], + :readonly => api_object['settigns']['readonly'], + :location_mode => api_object['settings']['location_mode'], :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,12 +41,17 @@ def generate_body body = { 'type' => resource[:type], 'settings' => { - 'compress' => resource[:compress], - 'location' => resource[:location] + 'compress' => resource[:compress] } } # Add optional values + body['settings']['location'] = resource[:location] unless resource[:location].nil? + body['settings']['container'] = resource[:container] unless resource[:container].nil? + body['settings']['base_path'] = resource[:base_path] unless resource[:base_path].nil? + body['settings']['client'] = resource[:client] unless resource[:client].nil? + body['settings']['readonly'] = resource[:readonly] unless resource[:readonly].nil? + body['settings']['location_mode'] = resource[:location_mode] unless resource[:location_mode].nil? body['settings']['chunk_size'] = resource[:chunk_size] unless resource[:chunk_size].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..9d83ab6f3 100644 --- a/lib/puppet/type/elasticsearch_snapshot_repository.rb +++ b/lib/puppet/type/elasticsearch_snapshot_repository.rb @@ -33,6 +33,29 @@ desc 'Repository location' end + newproperty(:client) do + defaultto 'default' + desc 'Azure client' + end + + newproperty(:container) do + desc 'Azure storage container' + end + + newproperty(:base_path) do + desc 'Specifies the path within container to repository data.' + end + + newproperty(:readonly) do + defaultto 'false' + desc 'Makes repository read-only.' + end + + newproperty(:location_mode) do + defaultto 'primary_only' + desc 'primary_only or secondary_only. Note that if you set it to secondary_only, it will force readonly to true.' + end + newproperty(:chunk_size) do desc 'File chunk size' end @@ -46,6 +69,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] == 'azure' + raise ArgumentError, 'Container is required.' if self[:container].nil? + end end end # of newtype diff --git a/manifests/snapshot_repository.pp b/manifests/snapshot_repository.pp index 1906194ea..32dff9040 100644 --- a/manifests/snapshot_repository.pp +++ b/manifests/snapshot_repository.pp @@ -36,8 +36,23 @@ # @param repository_type # Snapshot repository type. # -# @param location -# Location of snapshots. Mandatory +# @param location. Mandatory for type => "fs" +# Location of snapshots. +# +# @param container. Mandatory for type => "azure" +# Azure Container name. +# +# @param client +# Azure named client to use. +# +# @param base_path +# Azure path within container to repository data. +# +# @param readonly +# Makes Azure repository read-only. +# +# @param location_mode +# Azure location_mode. # # @param compress # Compress the snapshot metadata files? @@ -60,8 +75,13 @@ # @author Tyler Langlois # define elasticsearch::snapshot_repository ( - String $location, + Optional[String] $location = undef, Enum['absent', 'present'] $ensure = 'present', + Optional[String] $client = undef, + Optional[String] $container = undef, + Optional[String] $base_path = undef, + Optional[Boolean] $readonly = false, + Optional[String] $location_mode = 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 +108,7 @@ chunk_size => $chunk_size, compress => $compress, location => $location, + location => $location, max_restore_rate => $max_restore_rate, max_snapshot_rate => $max_snapshot_rate, type => $repository_type,