Closed gangsta closed 7 years ago
This is probably not the best place to ask for support, try our $theforeman irc channel @freenode. First question that I'd have is what is "/etc/puppet/environments/production/modules/profiles/manifests/manifests.pp", it does not look like something we ship.
Which foreman version are you using? I wonder if this assumes a specific API version (I'm assuming v1) while Foreman responds with another API (I'd guess v2).
Hi @ares,
Case was indeed question , but it can actually cause to have changes in file, that`s why i had asked here.
"/etc/puppet/environments/production/modules/profiles/manifests/manifests.pp" - this is manifest file which is printed in above section of first comment .
Mostly i will have a look at this file for solution :
https://github.com/theforeman/puppet-foreman/blob/master/lib/puppet/parser/functions/foreman.rb
Hi @ekohl ,
Yes you are true , there is most of time api version problem , I tried CURL command with v1 and v2 and im getting the same output . (p.s. am getting with CURL all information which i need exactly ) . Foreman version : 1.12
Kindly Regards Karen Harutyunyan
I think your use of filter_result
is incorrect. I'd first try it without filter_result
and otherwise set it to a correct value.
Hi @ekohl
Do you mean to set it true ? cause there you have`nt a lot of variants , false or true must be used . Both cases i get the same error message . I case if some one has experience with foreman.rb or tested how its work please share it with me .
thanks for collaboration Regards Karen
@Karen09 I'd try it with set to false
first but I don't recall using foreman()
myself so for me it's just guessing now.
Hi @ekohl ,
Actually there is something weird . I had changed https://github.com/theforeman/puppet-foreman/blob/master/lib/puppet/parser/functions/foreman.rb#L38 with adding require "pry"
and changing https://github.com/theforeman/puppet-foreman/blob/master/lib/puppet/parser/functions/foreman.rb#L74
(5) -> (20) seconds in order to give long time to parse . and its worked . I will create a pull request in order to solve this problem.
Regards Karen
I can reproduce this issue with the manifest above (though there's a typo, "ipaddres" should be "ipaddress").
Error: Evaluation Error: Error while evaluating a Function Call, undefined method `has_key?' for ["cobalt.example.com", {"ipaddress"=>"192.168.122.1"}]:Array at foreman.pp:10:12 on node cobalt
The response from the server is correct, it's an issue parsing the response:
2016-10-04T11:46:02 3909a397 [app] [D] Body: {
| "total": 164,
| "subtotal": 1,
| "page": 1,
| "per_page": 1000,
| "search": "fact = ipaddress",
| "sort": {
| "by": null,
| "order": null
| },
| "results": {"cobalt.example.com":{"ipaddress":"192.168.122.1"}}
| }
|
However I can't reproduce any change when adding pry
and nor would I expect one, I think that may be a red herring.
To be honest, I think this is probably a misuse of filter_result
with the fact_values API.
It was designed to extract an attribute out of the regular API output, which is {"result":[{"foo":".."}, ...]}
(result is an array of hashes), but the fact_values API is different - it's a hash of hashes.
What output would you expect from filter_result with a hash of hashes? It can't be collapsed to an array of single values without either discarding the key of the first hash (the hostname) or the key of the second hash (the fact name). You could conceivably only drop one or the other and return a hash of hostnames to a single fact, or fact names to a single host's value.
Hi @domcleal ,
Actually at first look I thought that filter_result
gives me failure , and it cant pars results as well , so i put there pry and its solve itself . so my question is how
filter_resultdepends on
pry? if we can understand what is doing pry to help pars result maybe we can find where is exactly issue . About output i would like to get hashesh with keys and values (like
{"fqdn":[{"ip": "hostname"...},....]}` )
Regards Karen
I don't think pry affects the result - if it does, you should debug on your own setup. We don't ship this modification and I can't reproduce it!
About output i would like to get hashesh with keys and values (like {"fqdn":[{"ip": "hostname"...},....]} )
This seems pretty specific to your case, I think you should probably use Puppet's iteration features (https://docs.puppet.com/puppet/latest/reference/lang_iteration.html) or a parser function of your own to transform the data that much.
@domcleal as I good understand foreman advice me to use this function to get facts from foreman as you can see in docs. https://theforeman.org/2012/01/getting-foreman-search-results-into.html so i need to get all facts without modification on this module right ? but i cant get anything untill i don`t add pry gem in to foreman.rb . so if you have experience how to get facts from foreman please share it with us.
My case is easiest . am using monitoring tools where hostname and ip is needed to create each
function in manifest file, for adding automated monitoring based ip and hostname.
Regards Karen
gem install pry Fetching: coderay-1.1.1.gem (100%) Successfully installed coderay-1.1.1 Fetching: slop-3.6.0.gem (100%) Successfully installed slop-3.6.0 Fetching: method_source-0.8.2.gem (100%) Successfully installed method_source-0.8.2 Fetching: pry-0.10.4.gem (100%) Successfully installed pry-0.10.4 invalid options: -SNw2 (invalid options are ignored) Parsing documentation for coderay-1.1.1 Installing ri documentation for coderay-1.1.1 Parsing documentation for slop-3.6.0 Installing ri documentation for slop-3.6.0 Parsing documentation for method_source-0.8.2 Installing ri documentation for method_source-0.8.2 Parsing documentation for pry-0.10.4 Installing ri documentation for pry-0.10.4 4 gems installed
is there any chance that slop
method_source
coderay
has affected for parsing instead of pry, like i have installed pry but actually it has been solved lets say by slop
?
Given we can't reproduce this and the age of the issue I'm going to close this now.
Hi,
I get some not usual error which i cant solve by my self, therefore please help me configure out whats going on.
manifests file:
Error:
Kindly Regards Karen