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

[dev.icinga.com #10867] "repository add" cli command writes invalid "type" attribute #3787

Closed
icinga-migration opened this issue Dec 16, 2015 · 8 comments
Labels
area/cli Command line helpers bug Something isn't working
Milestone

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/10867

Created by ToMMy on 2015-12-16 14:31:24 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2015-12-17 09:25:03 +00:00)
Target Version: 2.4.2
Last Update: 2016-02-23 09:58:34 +00:00 (in Redmine)

Icinga Version: 2.4.1
Backport?: Already backported
Include in Changelog: 1

Hello,

Using standard Centos 7 + icinga2 2.4.1 + icingaweb2 latest from repository.

The problem shows up when you try to generate a host .conf in the repository. I'll show example to reproduce the problem but i must say that i need to do this because i need some custom vars to be added in the host object code block ( i match my custom vars with some templates and dependencies ).
Here is what i do :

# icinga2 repository host add name="NODENAME" vars.os="Centos 6" --import="satellite-host" check_command="cluster-zone"

see the vars.os ?? i need to add custom vars in this examples is one but i need many AND this is working well !
What is not working:

# *icinga2 repository commit*
Changes to be committed:

Adding host 'NODENAME'
    check_command = "cluster-zone"
    import = [ "satellite-host" ]
   * type = "Host"*         _<---- THE PROBLEM_ 
    vars.os = "Centos 6"  <-- OK !

information/cli: Writing config object 'NODENAME' to file '*/etc/icinga2/repository.d/hosts/NODENAME.conf*'

# *service icinga2 reload*

Redirecting to /bin/systemctl reload  icinga2.service
+**Job for icinga2.service failed because the control process exited with error code. See "systemctl status icinga2.service" and "journalctl -xe" for details.**+

The error detail shown by "systemctl status icinga2.service -l " is:

safe-reload[1278]: information/ApiListener: My API identity: elk-stack.micrapg.lan
safe-reload[1278]: *critical/config: Error: Error while evaluating expression: Type field cannot be set.*
safe-reload[1278]: Location: in /etc/icinga2/repository.d/hosts/NODENAME.conf: 4:2-4:14
safe-reload[1278]: /etc/icinga2/repository.d/hosts/NODENAME.conf(2):  import "satellite-host"
safe-reload[1278]: /etc/icinga2/repository.d/hosts/NODENAME.conf(3):  check_command = "cluster-zone"
safe-reload[1278]: /etc/icinga2/repository.d/hosts/NODENAME.conf(4):  type = "Host"
safe-reload[1278]: ^^^^^^^^^^^^^
safe-reload[1278]: /etc/icinga2/repository.d/hosts/NODENAME.conf(5):  vars.os = "Centos 6"
safe-reload[1278]: /etc/icinga2/repository.d/hosts/NODENAME.conf(6): }
safe-reload[1278]: critical/config: 1 error

After MANUALLY edit the /etc/icinga2/repository.d/hosts/NODENAME.conf file and removing the Type = host entry ... the reload works well....

Changesets

2015-12-17 09:20:41 +00:00 by mfriedrich af3458d

Fix that "repository add" writes invalid "type" attribute

fixes #10867

2016-02-23 08:16:47 +00:00 by mfriedrich 9de34e0

Fix that "repository add" writes invalid "type" attribute

fixes #10867

Relations:

@icinga-migration
Copy link
Author

Updated by ToMMy on 2015-12-16 14:44:02 +00:00

Also the CLI icinga2 node add NODENAME should have the possibility to append custom vars !! as the "icinga2 repository host add name="" ... let's say i would like to manually add an "host" that doesn't have the agent ... ( ES: A PFSense FW host or a Cisco router )
Then it would be nice to do : icinga2 node add MYPFSENSENODE.local.lan vars.os="PFsense" vars.hostType="NetAppliances" etc...

So the "icinga2 node update-config" just works as expected without the need to MANUALLY write confs, zones, services, etc... OR do it with the DELETE the standard file + work with "icinga2 repository host add etc... " this is just A LOT of user work that makes DIFFICULT for most people to adopt icinga2 for big envs.... nobody is going to hand-write the conf files for hundreds of VMs or Appliances...

What a sysadmin can do is to automate some cli commands with custom scripts and work with the template design that is brilliant... ok i think i've say everything hope this is going to be solved soon !... for now i am trying to build some scripts with python to work-around the main problem of the ticket ...

Thank you !

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-12-17 09:13:18 +00:00

  • Relates set to 10690

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-12-17 09:21:32 +00:00

  • Subject changed from "icinga2 repository host add ..." breaks host file in the repository configuration adding "Type = Host" in the definition. "service icinga2 reload" doesn't work. to "repository add" cli command writes invalid "type" attribute
  • Description updated
  • Status changed from New to Feedback
  • Assigned to set to ToMMy
  • Target Version set to 2.5.0

I've updated the bug description, if you'll have additional feature requests please open separate issues. But rest assured, the "repository add" functionality won't be enhanced since we now have the REST API in place.

I've pushed a fix to master, please verify that working.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-12-17 09:25:03 +00:00

  • Status changed from Feedback to Resolved
  • Done % changed from 0 to 100

Applied in changeset af3458d.

@icinga-migration
Copy link
Author

Updated by ToMMy on 2015-12-17 13:15:29 +00:00

Thank you for the quick fix !!!

i was unable to test right now because i get errors compiling... i tried to build the RPM but it doesn't work.. i don't have much time right now to full debug my env but I'm shure the bug is fixed ...i'll just wait for an official rpm to be released .. for now i've found a work-around via self-made external script.

Ok i'll ask the new feature in a new request... i saw the REST API and i tested them .. but the files inside /etc/repository.d/ are not get modified.. the data is modified but not the files in the repo. This way... can make a lot of confusion because "half" of the conf is inside the repository.d files.. and "half" is managed by the api and as now only humans-visible via icingaweb2 ( or via api calls...wich return hard-to-read jsons )
People that are fallowing official documentation as me ...use the CLI to add new nodes to monitor....so the files in the repository are generated in all cases.

So to view the complete configuration of a monitored node you have to "MIX" what's returned by api calls WITH the comparison on what you've got in the repos files ???

For example... if i have vars.os="Centos 6" in a host file definition inside /etc/icinga2/repository.d/host/NODE.conf and the i modify this value via api ( let's say i change this var to vars.os="Windows" ) .. in the file i keep seeing "Centos 6" ... in icingaweb2 i correctly see "Windows"

WOW.... quite a lot of HARD work for standard users without a managing tool yet released....you always have to CHECK everything before make changes ... this can turn into hell for people don't have time to write an own front-end/set of scripts to manage AND CHECK ...everything

That's why i beleve it' would be simpler for now to extend the " icinga2 repository host add " possibility to append custom vars ALSO to the " icinga2 node add" command ( and include this in the official docs ) ... because as of now... i beleve people are 90% using CLI Commands or EDITING FILES to add nodes...not the api as official documentation.

Untill the release of the icinga2 module director i prefer to keep everything in the repos files ..so it's easy for collabs to interact with them and avoid as hell the use of REST-API for now... after the release of the director it will make sense then i'll want to convert everything i have in the repo files ---> to director format .. also via api calls would be ok..but an automatic import of the current conf is needed ( hope this feature WILL be included .. if not would be quite useless !! NOBODY EVER WOULD REWRITE FROM SCRATCH ALL THE CONFS USING THE NEW TOOL...make the import possibile pls (:prey:) )

Pick this just like a feedback i'll open a feature request with this later on.

Thank you very much for your work !

Tommaso

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-12-18 10:07:55 +00:00

  • Assigned to changed from ToMMy to mfriedrich
  • Target Version changed from 2.5.0 to 2.4.2

I assume it is fixed. Please use the snapshot packages in order to test it.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2015-12-18 10:08:12 +00:00

  • Duplicated set to 10889

@icinga-migration
Copy link
Author

Updated by gbeutner on 2016-02-23 09:58:34 +00:00

  • Backport? changed from Not yet backported to Already backported

@icinga-migration icinga-migration added bug Something isn't working area/cli Command line helpers labels Jan 17, 2017
@icinga-migration icinga-migration added this to the 2.4.2 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Command line helpers bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant