Ask Your Question

How to get the new structured data functionality working?

asked 2014-05-07 09:17:02 -0600

stresler gravatar image

I am working on a manifest that utilizes the puppetforge mysql module and want to generate a custom fact that returns a list of databases, users, and grants from the agent to the puppetmaster which then compiles the catalog and ensures that the databases match the requirements.

I was looking forward a lot to puppet 3.5 and Facter 2.0 to get the 'Early version of structured data'. However, I cannot for the life of me get it working nor can I find anything in the docs that indicates why.

master: Puppet v3.5.1, facterversion => 2.0.1 agent Puppet v3.5.1, facterversion => 2.0.1

Agent and master in puppet.conf has this line in [main] stringify_facts = false

I have set my facts terminus to yaml, not puppetdb, which I see isn't ready to handle structured data.

I then in my custom fact do something that I think is relatively simple:

    Facter.add("mysql_dbs") do
            setcode do
                    dbs = db.execute( "SELECT name FROM dbs" )
                   mysql_dbs =
                   dbs.each { |x| 
                           x.each { |y| 
                        , y)
                   pp mysqldbs

And I get this hash from the pp:

{"TEST3"=>"TEST3", "TEST2"=>"TEST2", "TEST1"=>"TEST1"}

But it is still stubbornly stuck as a long string when it gets to the manifest.

I can parse it manually, but I'm hoping someone here sees an obvious thing that I am doing incorrectly.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-05-07 09:49:56 -0600

stresler gravatar image

Nevermind..... the error it was throwing was not related to this. It is converting the data to a hash, but I need a hash of hashes, not a hash of strings. Blah.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-05-07 09:17:02 -0600

Seen: 69 times

Last updated: May 07 '14