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

Moving away from file concat #8

Open
KZachariassen opened this issue Apr 18, 2016 · 3 comments
Open

Moving away from file concat #8

KZachariassen opened this issue Apr 18, 2016 · 3 comments
Assignees

Comments

@KZachariassen
Copy link
Collaborator

Hi,

I will soon create a new branch, where I have moved away from file concat based on erb template. The new module will be based on Puppet Hashes, merge them together and then I'm reusing this template to make a structured and sorted yaml representation out of the hash.

I will keep the same structure in the module, but I'm just not a big fan of file concatenation and erb templating. Hope you will give it a go when it's ready

@poolski
Copy link
Owner

poolski commented Apr 19, 2016

Curious - I'd be interested to see how that pans out!

@KZachariassen
Copy link
Collaborator Author

I have pushed a new branch where I have done some rework on the Filebeat part of the project.

The module is now using 100% Puppet Hashes for configuration and writing the config file is done by this piece of code:

# Filebeat config
class beats::filebeat::config{

  $shipper_data_template = {
    shipper => {
      ignore_outgoing       => true,
      name                  => $::fqdn,
      refresh_topology_freq => '10',
    }
  }
  $shipper= deep_merge($shipper_data_template, $beats::shipper_data)
  $prospectors = $beats::filebeat::prospectors
  $outputs = $beats::filebeat::outputs

  $filebeat_conf = merge($prospectors,$outputs,$shipper)

  file {'/etc/filebeat/filebeat.yml':
    ensure  => present,
    content => inline_template('<%= @filebeat_conf.to_yaml %>'),
    }
}

$shipper_data_template is a example of creating a default hash if you want some default values for pieces of your config file. The rest of the magic is provided by hash merge and <%= @filebeat_conf.to_yaml %>

This makes is really simple and remove a lot of pain regarding erb templates(spaces, newlines). Furthermore it allows us to handle changes in the Beat product, without the need to update .pp and .erb files.

I would like some feedback before I will rework the rest of the module.

@KZachariassen
Copy link
Collaborator Author

Could someone have a look and test the brance I created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants