Skip to content

Commit

Permalink
use stdlib::to_toml instead of toml gem
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 14, 2023
1 parent 5de43c1 commit 1ba2350
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 54 deletions.
6 changes: 0 additions & 6 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
---
Gemfile:
optional:
':test':
- gem: 'toml-rb'
':system_tests':
- gem: 'toml-rb'
spec/spec_helper.rb:
hiera_config: "'spec/hiera.yaml'"
.puppet-lint.rc:
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ group :test do
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 3.0', :require => false
gem 'toml-rb', :require => false
end

group :development do
Expand All @@ -18,7 +17,6 @@ end

group :system_tests do
gem 'voxpupuli-acceptance', '~> 2.0', :require => false
gem 'toml-rb', :require => false
end

group :release do
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This module has the following dependencies:
for TLS-enabled repos in place. This can be achieved by installing the
`apt-transport-https` package.

This module **requires** the [toml-rb](https://github.com/eMancu/toml-rb) gem. Either install the gem using puppet's native gem provider, [puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/puppetserver_gem), [pe_gem](https://forge.puppetlabs.com/puppetlabs/pe_gem), [pe_puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/pe_puppetserver_gem), or manually using one of the following methods:
**Up to version v4.3.1** this module **requires** the [toml-rb](https://github.com/eMancu/toml-rb) gem. Either install the gem using puppet's native gem provider, [puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/puppetserver_gem), [pe_gem](https://forge.puppetlabs.com/puppetlabs/pe_gem), [pe_puppetserver_gem](https://forge.puppetlabs.com/puppetlabs/pe_puppetserver_gem), or manually using one of the following methods:
```
# apply or puppet-master
gem install toml-rb
Expand All @@ -43,6 +43,8 @@ This module **requires** the [toml-rb](https://github.com/eMancu/toml-rb) gem. E
/opt/puppet/bin/puppetserver gem install toml-rb
```

The toml-rb gem got replaced with `stdlib::to_toml`. This requires puppetlabs/stdlib 9.

In addition, for Windows, the following dependencies must be met:

* Chocolatey installed
Expand Down
2 changes: 1 addition & 1 deletion manifests/aggregator.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

file { "${telegraf::config_folder}/${name}.conf":
ensure => $_ensure,
content => inline_template("<%= require 'toml-rb'; TomlRB.dump({'aggregators'=>{'${plugin_type}'=>@options}}) %>"),
content => stdlib::to_toml({ 'aggregators'=> { $plugin_type=> $options } }),
require => Class['telegraf::config'],
notify => Class['telegraf::service'],
}
Expand Down
18 changes: 17 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@
class telegraf::config inherits telegraf {
assert_private()

$agent = {
'hostname' => $telegraf::hostname,
'omit_hostname' => $telegraf::omit_hostname,
'interval' => $telegraf::interval,
'round_interval' => $telegraf::round_interval,
'metric_batch_size' => $telegraf::metric_batch_size,
'metric_buffer_limit' => $telegraf::metric_buffer_limit,
'collection_jitter' => $telegraf::collection_jitter,
'flush_interval' => $telegraf::flush_interval,
'flush_jitter' => $telegraf::flush_jitter,
'precision' => $telegraf::precision,
'logfile' => $telegraf::logfile,
'debug' => $telegraf::debug,
'quiet' => $telegraf::quiet,
}
$config = stdlib::to_toml({ 'global_tags' => $telegraf::global_tags, 'agent' => $agent, 'outputs' => $telegraf::outputs, 'inputs' => $telegraf::inputs })
file { $telegraf::config_file:
ensure => $telegraf::ensure_file,
content => template('telegraf/telegraf.conf.erb'),
content => $config,
owner => $telegraf::config_file_owner,
group => $telegraf::config_file_group,
mode => $telegraf::config_file_mode,
Expand Down
2 changes: 1 addition & 1 deletion manifests/input.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

file { "${telegraf::config_folder}/${name}.conf":
ensure => $_ensure,
content => inline_template("<%= require 'toml-rb'; TomlRB.dump({'inputs'=>{'${plugin_type}'=>@options}}) %>"),
content => stdlib::to_toml({ 'inputs'=> { $plugin_type=> $options } }),
require => Class['telegraf::config'],
notify => Class['telegraf::service'],
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
}
} else {
if ! $telegraf::manage_archive {
ensure_packages([$telegraf::package_name],
stdlib::ensure_packages([$telegraf::package_name],
{
ensure => $telegraf::ensure,
install_options => $telegraf::install_options,
Expand Down
2 changes: 1 addition & 1 deletion manifests/output.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

file { "${telegraf::config_folder}/${name}.conf":
ensure => $_ensure,
content => inline_template("<%= require 'toml-rb'; TomlRB.dump({'outputs'=>{'${plugin_type}'=>@options}}) %>"),
content => stdlib::to_toml({ 'outputs'=> { $plugin_type=> $options } }),
require => Class['telegraf::config'],
notify => Class['telegraf::service'],
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/processor.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

file { "${telegraf::config_folder}/${name}.conf":
ensure => $_ensure,
content => inline_template("<%= require 'toml-rb'; TomlRB.dump({'processors'=>{'${plugin_type}'=>@options}}) %>"),
content => stdlib::to_toml({ 'processors'=> { $plugin_type=> $options } }),
require => Class['telegraf::config'],
notify => Class['telegraf::service'],
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"dependencies": [
{
"name": "puppetlabs-stdlib",
"version_requirement": ">= 5.0.0 < 9.0.0"
"version_requirement": ">= 9.0.0 < 10.0.0"
},
{
"name": "puppetlabs-apt",
Expand Down
4 changes: 1 addition & 3 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

require 'voxpupuli/acceptance/spec_helper_acceptance'

configure_beaker do |host|
on host, '/opt/puppetlabs/puppet/bin/gem install toml-rb'
end
configure_beaker
35 changes: 0 additions & 35 deletions templates/telegraf.conf.erb

This file was deleted.

0 comments on commit 1ba2350

Please sign in to comment.