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

Update documentation about += operator #352

Closed
baurmatt opened this issue Aug 16, 2017 · 3 comments
Closed

Update documentation about += operator #352

baurmatt opened this issue Aug 16, 2017 · 3 comments
Assignees
Milestone

Comments

@baurmatt
Copy link
Contributor

Expected Behavior

Generate a configuration like this with Puppet:

apply Service for (http_vhost => config in host.vars.http_vhosts) to Host {
  import "generic-service"

  check_command = "http"

  vars += config
}

The vars += config part is the part i'm missing.

Current Behavior

As stated in https://github.com/Icinga/puppet-icinga2/blob/master/README.md#what-isnt-supported this is currently not possible as the icinga2_attributes/Puppet::Icinga2::Utils.attributes function doesn't support it.

Possible Solution

Fix icinga2_attributes/Puppet::Icinga2::Utils.attributes

I suggest a solution like this:

icinga2::object::service { 'foo-service':
  ...
  vars => {
    '+=' => 'config'
  },
  ...
}

Do you already have talked about this internally? Was where already some playing around with this feature/idea?

Your Environment

  • Module version (puppet module list): Forked master with enhancements
  • Puppet version (puppet -V): 4.10.1
  • Operating System and version: Ubuntu 16.04
@baurmatt
Copy link
Contributor Author

From documentation of icinga2::object::service (https://github.com/Icinga/puppet-icinga2/blob/master/manifests/object/service.pp#L152)

#   ::icinga2::object::service { 'linux_disks':
#     import           => ['generic-service'],
#     apply            =>  'disk_name =>config in host.vars.disks',
#     check_command    => 'disk',
#     command_endpoint => 'host.name',
#     vars             => 'vars + config',
#     assign           => ['host.vars.os == Linux'],
#     ignore           => ['host.vars.noagent'],
#     target           => '/etc/icinga2/zones.d/global-templates/services.conf',
#   }

Does this actually work? This would generate a configuration like this:

...
vars = vars + config
...

Is this the same as?

...
vars += config
...

@lbetz
Copy link
Contributor

lbetz commented Aug 17, 2017

Correct. vars += config is the short syntax for vars = vars + config. Both is correct Icinga syntax. The module supports only the long version.

@lbetz lbetz closed this as completed Aug 17, 2017
@lbetz lbetz reopened this Aug 17, 2017
@baurmatt
Copy link
Contributor Author

Ha, alright this was easier then i thought. Thanks! :) Could this please be documented? Perhaps somewhere around https://github.com/Icinga/puppet-icinga2/blob/master/README.md#parsing-configuration? Because the following sounds like its just not possible:

Assignments other than simple attribution are not currently possible either, e.g. building something like
vars += config

@bobapple bobapple changed the title Allow += operator Update documentation about += operator Aug 31, 2017
@lbetz lbetz added this to the v1.3.1 milestone Sep 23, 2017
@bobapple bobapple added the docs label Sep 27, 2017
@lbetz lbetz self-assigned this Sep 27, 2017
@lbetz lbetz closed this as completed in 1ff191e Sep 27, 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
Projects
None yet
Development

No branches or pull requests

3 participants