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

Fail to return facts with Puppet 5.5 #163

Closed
smortex opened this issue Mar 25, 2018 · 3 comments
Closed

Fail to return facts with Puppet 5.5 #163

smortex opened this issue Mar 25, 2018 · 3 comments

Comments

@smortex
Copy link
Member

smortex commented Mar 25, 2018

As reported in choria-legacy/mcollective-choria#455 , after updating to Puppet 5.5, facts reporting got broken:

λ mco inventory example.com
[...]
   Facts:
      No facts known
λ mco facts puppetversion
No values found for fact puppetversion

Finished processing 8 / 8 hosts in 272.56 ms

The logging system reports a problem related to aliasing:

I, [2018-03-25T15:50:44.428484+02:00 #56352]  INFO -- : choria.rb:221:in `validrequest?' Received valid request 8613664f66325aae9f7d7bb8db8a309b from choria=romain.mcollective
I, [2018-03-25T15:50:44.429182+02:00 #56352]  INFO -- : runner.rb:216:in `agentmsg' Handling message 8613664f66325aae9f7d7bb8db8a309b for agent 'rpcutil' in collective 'mcollective' from choria=romain.mcollective@example.com: {:agent=>"rpcutil", :action=>"get_fact", :caller=>"choria=romain.mcollective", :data=>{:fact=>"puppetversion", :process_results=>true}}
E, [2018-03-25T15:50:44.445924+02:00 #56352] ERROR -- : yaml_facts.rb:35:in `rescue in block in load_facts_from_source' Failed to load yaml facts from /usr/local/etc/mcollective/generated-facts.yaml: Psych::BadAlias: Unknown alias: 1
E, [2018-03-25T15:50:44.446053+02:00 #56352] ERROR -- : base.rb:46:in `rescue in block in get_fact' Failed to load facts: RuntimeError: Got empty facts

In my generated-facts.yaml file, mcollective::server::libdir is aliased to the value of mcollective::client::libdir.

smortex added a commit to smortex/puppet-mcollective that referenced this issue Mar 25, 2018
With Puppet 5.5, the refresh_facts.rb produce a YAML file containing
aliases, which are not properly processed (choria-legacy/mcollective-choria#455).

This workaround prevents the same object to be assigned to
mcollective::client::libdir and mcollective::server::libdir by
duplicating them.  The Psych serializer then consider them as two
distinct objects and does not emit an alias.
@law
Copy link

law commented Mar 25, 2018

Confirmed, I suffer from this issue, and this patch works for me (Ubuntu 16.04, Puppet 5.5, etc). Making the suggested change on the host and restarting the 'mcollective' service makes all my facts magically come back. Thanks so much!

@mateusz-gozdek-sociomantic

Cool that it is fixed here as well. However keep in mind guys, that any other modules or custom facts may break too.

This bug is fixed upstream already (puppetlabs/marionette-collective#474), but if someone needs more flexible workaround, here it is:

        file_line { 'mcollective_allow_aliases_in_yaml':
                ensure             => present,
                path               => '/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/mcollective/facts/yaml_facts.rb',
                match              => '\s*facts.merge!\(YAML.safe_load\(File.read\(file\)(|, \[\], \[\], true)\)\)',   #lint:ignore:Unrecognized escape sequence
                line               => '                facts.merge!(YAML.safe_load(File.read(file), [Symbol], [], true))',
                append_on_no_match => false,
                notify             => Service['mcollective'],
        }

@ripienaar
Copy link
Member

soonish I'll update the fact export script to write a JSON file as well and switch to JSON :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants