libraries/vault_config.rb
# Transforms the resource into a JSON format which matches the
# Vault service's configuration format.
# @see https://vaultproject.io/docs/config/index.html
Transforms the resource into a JSON format which matches the
Vault service's configuration format.
Transforms the resource into a JSON format which matches the Vault service ' s configuration format .
def to_json
        config_keeps = %i(cluster_name cache_size disable_cache disable_mlock default_lease_ttl log_level max_lease_ttl raw_storage_endpoint ui)
        puts to_hash.inspect()
        config = to_hash.keep_if do |k, _|
          config_keeps.include?(k.to_sym)
        end
        listener_keeps = %i(address cluster_address proxy_protocol_behavior proxy_protocol_authorized_addrs)
        tls_params = %i(tls_cert_file tls_key_file tls_min_version tls_cipher_suites tls_prefer_server_cipher_suites tls_require_and_verify_client_cert tls_client_ca_file tls_disable_client_certs)
        listener_keeps += tls_params if tls?
        listener_options = to_hash.keep_if do |k, _|
          listener_keeps.include?(k.to_sym)
        end.merge(tls_disable: tls_disable.to_s)
        config['listener'] = { 'tcp' => listener_options }
        config['service_registration'] = { service_registration_type => (service_registration_options || {}) } if service_registration_type
        config['storage'] = { storage_type => (storage_options || {}) }
        if %w(consul etcd zookeeper dynamodb).include? hastorage_type
          config['ha_storage'] = { hastorage_type => (hastorage_options || {}) }
        end
        config['telemetry'] = telemetry_options unless telemetry_options.empty?
        ha_keeps = %i(api_addr cluster_addr disable_clustering)
        config.merge!(to_hash.keep_if do |k, _|
          ha_keeps.include?(k.to_sym)
        end)
        JSON.pretty_generate(config, quirks_mode: true).gsub(/retry_join_\d+/, 'retry_join')
      end
def to_json config_keeps = %i( cluster_name cache_size disable_cache disable_mlock default_lease_ttl log_level max_lease_ttl raw_storage_endpoint ui ) puts to_hash . inspect ( ) config = to_hash . keep_if do | k , _ | config_keeps . include? ( k . to_sym ) end listener_keeps = %i( address cluster_address proxy_protocol_behavior proxy_protocol_authorized_addrs ) tls_params = %i( tls_cert_file tls_key_file tls_min_version tls_cipher_suites tls_prefer_server_cipher_suites tls_require_and_verify_client_cert tls_client_ca_file tls_disable_client_certs ) listener_keeps += tls_params if tls? listener_options = to_hash . keep_if do | k , _ | listener_keeps . include? ( k . to_sym ) end . merge ( tls_disable : tls_disable . to_s ) config [ 'listener' ] = { 'tcp' => listener_options } config [ 'service_registration' ] = { service_registration_type => ( service_registration_options || { } ) } if service_registration_type config [ 'storage' ] = { storage_type => ( storage_options || { } ) } if %w( consul etcd zookeeper dynamodb ) . include? hastorage_type config [ 'ha_storage' ] = { hastorage_type => ( hastorage_options || { } ) } end config [ 'telemetry' ] = telemetry_options unless telemetry_options . empty? ha_keeps = %i( api_addr cluster_addr disable_clustering ) config . merge! ( to_hash . keep_if do | k , _ | ha_keeps . include? ( k . to_sym ) end ) JSON . pretty_generate ( config , quirks_mode : true ) . gsub ( / retry_join_ \d + / , 'retry_join' ) end
Transforms the resource into a JSON format which matches the
Vault service's configuration format.
Transforms the resource into a JSON format which matches the Vault service ' s configuration format .
# top-level # listener # service registration # storage # ha_storage, only some storages support HA # HA config # `gsub` since we may have multiple `retry_join` stanzas: # https://www.vaultproject.io/docs/concepts/integrated-storage#retry_join-configuration
see
None