#
# Managed by Puppet
#
# configuration for the JRuby interpreters
jruby-puppet: {
    # Where the puppet-agent dependency places puppet, facter, etc...
    # Puppet server expects to load Puppet from this location
    ruby-load-path: [
    <%- @server_ruby_load_paths.each do |ruby_load_path| -%>
        <%= ruby_load_path %>,
    <%- end -%>
    ]

    # This setting determines where JRuby will install gems.  It is used for loading gems,
    # and also by the `puppetserver gem` command line tool.
    gem-home: <%= @server_jruby_gem_home %>

    # This setting defines the complete "GEM_PATH" for jruby.  If set, it should include
    # the gem-home directory as well as any other directories that gems can be loaded
    # from (including the vendored gems directory for gems that ship with puppetserver)
    gem-path: [<%= @server_gem_paths.join(', ') %>]

    # PLEASE NOTE: Use caution when modifying the below settings. Modifying
    # these settings will change the value of the corresponding Puppet settings
    # for Puppet Server, but not for the Puppet CLI tools. This likely will not
    # be a problem with server-var-dir, server-run-dir, or server-log-dir unless
    # some critical setting in puppet.conf is interpolating the value of one
    # of the corresponding settings, but it is important that any changes made to
    # server-conf-dir and server-code-dir are also made to the corresponding Puppet
    # settings when running the Puppet CLI tools. See
    # https://docs.puppetlabs.com/puppetserver/latest/puppet_conf_setting_diffs.html#overriding-puppet-settings-in-puppet-server
    # for more information.

    # (optional) path to puppet conf dir; if not specified, will use
    # the puppet default
    server-conf-dir: <%= @server_dir %>

    # (optional) path to puppet code dir; if not specified, will use
    # the puppet default
    server-code-dir: <%= @codedir %>

    # (optional) path to puppet var dir; if not specified, will use
    # the puppet default
    server-var-dir: <%= @server_puppetserver_vardir %>

    # (optional) path to puppet run dir; if not specified, will use
    # the puppet default
    server-run-dir: <%= @server_puppetserver_rundir %>

    # (optional) path to puppet log dir; if not specified, will use
    # the puppet default
    server-log-dir: <%= @server_puppetserver_logdir %>

    # (optional) maximum number of JRuby instances to allow
    max-active-instances: <%= @server_max_active_instances %>

    # (optional) the number of HTTP requests a given JRuby instance will handle in its lifetime.
    max-requests-per-instance: <%= @server_max_requests_per_instance %>

    # (optional) The maximum number of requests that may be queued waiting to borrow a JRuby from the pool.
    max-queued-requests: <%= @server_max_queued_requests %>

    # (optional) Sets the upper limit for the random sleep set as a Retry-After header on 503 responses returned when max-queued-requests is enabled.
    max-retry-delay: <%= @server_max_retry_delay %>

    # (optional) enable or disable environment class cache
    environment-class-cache-enabled: <%= @server_environment_class_cache_enabled %>

    # (optional) A map of environment variables which are made visible to
    # Ruby code running within JRuby, for example, via the Ruby ENV class.
    # By default, the only environment variables whose values are set into JRuby from the shell are HOME and PATH.
    # The default value for the GEM_HOME environment variable in JRuby is set from the value provided for the
    # jruby-puppet.gem-home key.
    # Any variable set from the map for the environment-vars key overrides these defaults.
    # Avoid overriding HOME, PATH, or GEM_HOME here because these values are already configurable via the shell
    # or jruby-puppet.gem-home.
    environment-vars: {
    <%- @server_environment_vars.each do |env_key, env_val| -%>
      "<%= env_key %>" : <%= env_val %>
    <%- end -%>
    }
<%- if @compile_mode %>

    compile-mode: <%= @compile_mode %>
<%- end -%>
    multithreaded: <%= @server_multithreaded %>
}
<%- if @versioned_code_id and @versioned_code_content -%>

  versioned-code: {
    code-id-command: <%= @versioned_code_id %>
    code-content-command: <%= @versioned_code_content %>
  }
<%- end -%>

# settings related to HTTPS client requests made by Puppet Server
http-client: {
    # A list of acceptable protocols for making HTTPS requests
    ssl-protocols: [
    <%- @server_ssl_protocols.each do |protocol| -%>
        <%= protocol %>,
    <%- end -%>
    ]

    # A list of acceptable cipher suites for making HTTPS requests
    cipher-suites: [
    <%- @server_cipher_suites.each do |cipher| -%>
        <%= cipher %>,
    <%- end -%>
    ]

    # Whether to enable http-client metrics; defaults to 'true'.
    metrics-enabled: <%= @server_metrics %>

    # The amount of time, in milliseconds, that an outbound HTTP connection
    # will wait for data to be available before closing the socket. If not
    # defined, defaults to 20 minutes. If 0, the timeout is infinite and if
    # negative, the value is undefined by the application and governed by the
    # system default behavior.
    idle-timeout-milliseconds: <%= @server_idle_timeout %>

    # The amount of time, in milliseconds, that an outbound HTTP connection will
    # wait to connect before giving up. Defaults to 2 minutes if not set. If 0,
    # the timeout is infinite and if negative, the value is undefined in the
    # application and governed by the system default behavior.
    connect-timeout-milliseconds: <%= @server_connect_timeout %>
}

# settings related to profiling the puppet Ruby code
profiler: {
    # enable or disable profiling for the Ruby code;
    enabled: <%= @server_profiler %>
}

# Settings related to telemetry
dropsonde: {
    # enable or disable telemetry
    enabled: <%= @server_telemetry %>
}
