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

Cannot customize deploymentclient.conf #394

Open
thierry-thierry opened this issue Jan 9, 2025 · 9 comments
Open

Cannot customize deploymentclient.conf #394

thierry-thierry opened this issue Jan 9, 2025 · 9 comments
Labels
enhancement New feature or request

Comments

@thierry-thierry
Copy link

thierry-thierry commented Jan 9, 2025

How to reproduce:

When trying to customize deploymentclient.conf with the following code, nothing happens:

splunk::forwarder::splunkforwarder_deploymentclient:
  target_uri:
    section: 'target-broker:deploymentServer'
    setting: 'targetUri'
    value: '<host>:<port>'

What behaviour did you expect instead

deploymentclient.conf should be written with the following:

[target-broker:deploymentServer]
targetUri = <host>:<port>

Any additional information you'd like to impart

I have not figured out how to configure deploymentclient.conf with the way the module works right now, but was able to edit the module to allow configuring deploymentclient.conf.

This could be done by adding the following code:

manifests/forwarder/config.pp L70

    $splunk::forwarder::forwarder_deploymentclient.each | String $name, Hash $options| {
      splunkforwarder_deploymentclient { $name:
        section => $options['section'],
        setting => $options['setting'],
        value   => $options['value'],
        tag     => 'splunk_forwarder',
      }
    }

manifests/forwarder.pp L117

# @param forwarder_deploymentserver
#   Used to override the default `forwarder_deploymentserver` type defined in splunk::params.
#

manifests/forwarder.pp L198

  Hash $forwarder_deploymentclient           = $splunk::params::forwarder_deploymentclient,

manifests/params.pp L283

  $forwarder_deploymentclient = {
    'target-broker_targetUri' => {
      section             => 'target-broker:deploymentServer',
      setting             => 'targetUri',
      value               => "${server}:${logging_port}",
      tag                 => 'splunk_forwarder',
    },
  }
@kenyon kenyon changed the title Cannot customize deployment.conf Cannot customize deployment.conf Jan 10, 2025
@kenyon
Copy link
Member

kenyon commented Jan 10, 2025

Nothing happens because there is no splunkforwarder_deploymentclient parameter of the splunk::forwarder class, so that's expected.

What are you trying to do? It seems like deployment.conf is deprecated: https://docs.splunk.com/Documentation/Splunk/9.4.0/Admin/Deploymentconf

This module can already manage the replacement files, deploymentclient.conf and serverclass.conf.

@kenyon kenyon added the needs-feedback Further information is requested label Jan 10, 2025
@thierry-thierry thierry-thierry changed the title Cannot customize deployment.conf Cannot customize deploymentclient.conf Jan 13, 2025
@thierry-thierry
Copy link
Author

@kenyon, my apologies, it is not deployment.conf I am trying to edit but indeed deploymentclient.conf (I have thus edited the description and title of this issue accordingly).

Why is there no splunkforwarder_deploymentclient parameter of the splunk::forwarder class?

Shouldn't we be able to manage that file's content?

That is why I am suggesting to add what I have shared in the description.

@kenyon kenyon added enhancement New feature or request and removed needs-feedback Further information is requested labels Jan 13, 2025
@kenyon
Copy link
Member

kenyon commented Jan 13, 2025

What you describe is just not the configuration pattern that this modules has implemented. I suppose it could be enhanced to work that way, if you want to create a pull request for this.

The way it is currently designed to work is shown here; https://github.com/voxpupuli/puppet-splunk/blob/master/README.md#usage

You would declare virtual splunkforwarder_deploymentclient resources, and then those are collected and realized by this line when you've tagged them splunk_forwarder:

File <| tag == 'splunk_forwarder' |> -> Splunkforwarder_deploymentclient<||> ~> Class['splunk::forwarder::service']

@thierry-thierry
Copy link
Author

Thank you. I submitted a PR: #395
I think this is needed, because deploymentclient.conf is deployed with the agent.
Shouldn't Puppet reflect what is being installed with the agent?

@kenyon
Copy link
Member

kenyon commented Jan 14, 2025

This module already can manage the config file, you just have to use it the way it was intended.

@thierry-thierry
Copy link
Author

Would you be able to tell me what I am missing, then?
I have splunkforwarder 9.3.0.
Without the config change I suggested in my PR, I was unable to get Puppet to do anything to that deploymentclient.conf file.
I have checked the Readme but it is not clear to me what is the intended way to manage it.
Once I apply the changes suggested by my PR, the file gets managed with the values of the following variables:

${server}
${logging_port}

@kenyon
Copy link
Member

kenyon commented Jan 14, 2025

@thierry-thierry you need to declare virtual resources, with the @ in front of them:

@splunkforwarder_deploymentclient { $name:
  section => $options['section'],
  setting => $options['setting'],
  value   => $options['value'],
  tag     => 'splunk_forwarder',
}

@thierry-thierry
Copy link
Author

thierry-thierry commented Jan 15, 2025

Does this mean that the module is not intended for use with hiera?

I am using the module with hiera and have yet to figure out how to manage deploymentclient.conf without any modification to the module. Here is what I have tried, based on your previous comment:

splunk::forwarder::splunkforwarder_deploymentclient:
  target_broker:
    section: 'target-broker:deploymentServer'
    setting: 'targetUri'
    value: 'foo:port'

I have also tried:

splunk::forwarder::forwarder_deploymentclient:

It just does not do anything, which I understand, since the variable splunkforwarder_deploymentclient has been declared nowhere.

The following code works without modifying the module, for outputs.conf and inputs.conf:

splunk::forwarder::forwarder_output:
  tcpout_defaultGroup:
    section: 'tcpout'
    setting: 'defaultGroup'
    value: 'default-autolb-group'

I'm sorry if I am missing anything obvious here, but I don't see any way, without modifying the module, to manage the deploymentclient.conf file without the PR that I have submitted.

I'd be happy to figure out what I am missing and manage it without touching the module.

Thank you.

@kenyon
Copy link
Member

kenyon commented Jan 15, 2025

I think if you want to use it with hiera like that, without modifying the module, you would use a wrapper/profile class. Your PR #395 seems like a reasonable enhancement too though. It just needs some work to get the checks to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants