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

Only last empty hash is stored #308

Closed
linuxmail opened this issue May 26, 2017 · 3 comments
Closed

Only last empty hash is stored #308

linuxmail opened this issue May 26, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@linuxmail
Copy link

Hello,

I try create a host template for the mysql_health_check ... and I have problems to get a syntax like:

vars.check["foo"] = {} 
vars.check["bar"] = {}
....

With the following code:

  @@icinga2::object::host { 'mysql-database':
    template      => true,
    check_command => 'mysql',
    vars          => {
        'mysql_health'       => {
         'bufferpool-hitrate'  => { },
         'bufferpool-wait-free'  => { },
      },
...
}

The last line wins.

I have a similar config for my interfaces or blockdevices, but thy exists in my hiera YAML config and I get the correct output:

  vars.blockdevices["sda"] = {
    path = "/dev/sda"
    iostats_disk = "sda"
  }
  vars.blockdevices["sdb"] = {
    path = "/dev/sdb"
    iostats_disk = "sdb"
  }

My Yaml

icinga2::host:
  vars:
    blockdevices:
      'sda':
        'path': '/dev/sda'
        'iostats_disk': 'sda'
      'sdb':
        'path': '/dev/sdb'
        'iostats_disk': 'sdb'

So it looks like, that my Puppet syntax is wrong. Can someone point me in the right direction ?

cu denny

@lbetz lbetz added the question label May 29, 2017
@lbetz lbetz self-assigned this May 29, 2017
@lbetz
Copy link
Contributor

lbetz commented May 29, 2017

Hi Denny,
I cannot see any errors. Please try the example 'example_config' this will apply the whole example config in /etc/icinga2/example.d and a host NodeName in hosts.conf with vars.disks["disks"] = {}.

Bye Lenn.

@linuxmail
Copy link
Author

Hi @lbetz

the error is, that I expecting:

vars.check["1"] = {} 
vars.check["2"] = {}
vars.check["3"] = {}

but I get

vars.check["3"] = {}

So all other lines above are lost/overwritten. I tried the complete example:

  ::icinga2::object::host { 'template-foo':
      template           => true,
      target             => "${templates}/template-foo.conf",
      check_interval     => '1m',
      retry_interval     => '30s',
      max_check_attempts => 3,
      check_command      => 'hostalive',
    vars => {
        foo              => {
        bar             => {},
        '1'         => {},
        '2'         => {},
        '3'         => {},
        '4'         => {},
        },
      },
    }

the result is:

 ~$ cat /etc/icinga2/zones.d/global-templates/templates.d/template-foo.conf
# This file is managed by Puppet. DO NOT EDIT.

template Host "template-foo"  {
  check_command = "hostalive"
  max_check_attempts = 3
  check_interval = 1m
  retry_interval = 30s
  vars.foo["4"] = {}
}

I think, it makes a difference if I put the syntax into a classical manifest, or use hiera_hash. I use for disks the same logic, but in a yaml and it works.
Maybe it has somthing todo with: #223.

cu denny

@lbetz lbetz added bug and removed question labels May 31, 2017
@lbetz
Copy link
Contributor

lbetz commented May 31, 2017

Ah, ok. That's a bug. I will have a look on friday I hope.

@lbetz lbetz added this to the v1.3.0 milestone May 31, 2017
@lbetz lbetz changed the title Question: vars -> - vars.check["foo"] = {} vars.check["bar"] = {} Only last empty hash is stored Jun 1, 2017
@lbetz lbetz closed this as completed in 0eecf4c Jun 1, 2017
n00by pushed a commit to n00by/puppet-icinga2 that referenced this issue Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants