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

Unable to use constants in templates or commands #1075

Closed
heino-vdbh opened this issue Aug 12, 2017 · 10 comments
Closed

Unable to use constants in templates or commands #1075

heino-vdbh opened this issue Aug 12, 2017 · 10 comments

Comments

@heino-vdbh
Copy link

Director 1.3.1

When I use constants in commands or command templates the constants always get quoted and dont get expanded

When I edit the the conf file by hand and remove the quotes and reload icinga2 the constants get expanded.

@dgoetz
Copy link
Contributor

dgoetz commented Aug 16, 2017

This also hurts me when I want to define a commandline like [ "/usr/bin/sudo" , PluginDir + "/command" ], which I did not manage to create at all. If I could hardcode the path instead of using PluginDir, it would be doable, but requiring the flexibility of PluginDir because of different os families in use I failed.

@cflinspach
Copy link

cflinspach commented Aug 16, 2017

@dgoetz Absolute paths are accepted as provided, relative paths are prefixed with "PluginDir + ", similar Constant prefixes are allowed. If you use the full path it won't add PluginDir so you can define your own. Here's two screenshots of one of our commands that we use sudo with.

director-sudo2
director-sudo

@dgoetz
Copy link
Contributor

dgoetz commented Aug 16, 2017

@cflinspach: Thanks, but the problem is that I need PluginDir because of the different os families used here.

@cflinspach
Copy link

@dgoetz so PluginDir would resolve to different paths based on the check source?

@dgoetz
Copy link
Contributor

dgoetz commented Aug 16, 2017

@cflinspach: Yes, SLES uses arch-independent /usr/lib/nagios/plugins and RHEL uses arch-dependent /usr/lib64/nagios/plugins.

@gody01
Copy link

gody01 commented Jun 21, 2018

+1 for use of Constants. Big problem with secure information. Now usernames/passwords has to be in the DB - not good.

@NeverUsedID
Copy link

+1 :)

I think a rather easy solution would be to add some special syntax like {{{mystring}}} to avoid that the director placing quotes around that "string".

In my case i need that for auto creating the display_name:

display_name = vars.location + "_" + vars.devicetype + "_" + vars.hostname

Never found a way to configure this with the director.

@widhalmt
Copy link
Member

ref/NC/589957

@Linuxfabrik
Copy link

Is there any news on this issue? Or is there another way of supporting different plugin directories on different operating systems?

@Thomas-Gelf
Copy link
Contributor

Hi @Linuxfabrik,

that's perfectly possible, has been fixed a long time ago. You can use PluginDir or other external constants:

director_plugindir

@cflinspach showed how to use sudo. What is not possible is having a constant "in the middle", like BinDir + /sudo + Plugindir + /check_plugin. I'm not unhappy about this, as such a command is dangerous and should be the absolute exception and not the rule. You are forced to specify the plugin path in your sudoers file, so it shouldn't hurt to write the full path in the Icinga config too.

In case you really need a solution for that specific use-case please open a dedicated issue. I'll close this one for now - as what has originally been asked for has been implemented.

Cheers,
Thomas

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

7 participants