Exported Resource - Could not evaluate: Field 'key' is required

asked 2017-06-14 21:11:42 -0500

andrew91 gravatar image

updated 2017-06-15 13:09:13 -0500

Hello beginner here. I'm trying to do the classic distribute ssh keys to every server in the puppet environment, but I seem to be running into a issue as I'm receiving the error: Error: /Stage[main]/Ssh/Sshkey[puppet-dev]: Could not evaluate: Field 'key' is required

Puppet code that I borrowed from the puppet documentation:

class ssh {
    #Declare
    @@sshkey { $::hostname:
        type => dsa,
        key  => $::sshdsakey, 
        }
    # Collect:

    Sshkey <<| |>>
}

Running puppet agent:

 [root@puppet-dev modules]# puppet agent -t
 Info: Using configured environment 'production'
 Info: Retrieving pluginfacts
 Info: Retrieving plugin
 Info: Loading facts
 Info: Caching catalog for puppet-dev.esxi.com
 Info: Applying configuration version '1497521436'
 Notice: /Stage[main]/Ssh/Sshkey[puppet-dev]/ensure: created
 Error: /Stage[main]/Ssh/Sshkey[puppet-dev]: Could not evaluate: Field 'key' is required
Notice: Applied catalog in 0.23 seconds

Update 1:

I've commented out the "key" and added a notice resource, but I am still receiving the same error.

class ssh {
    #Declare
    @@sshkey { $::hostname:
        type => dsa,
        #key  => $::sshdsakey, 
        }
    # Collect:

    notice($::sshdsakey)

    Sshkey <<| |>>
}

Running puppet agent:

[root@puppet-dev ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet-dev.esxi.com
Info: Applying configuration version '1497578863'
Notice: /Stage[main]/Ssh/Sshkey[puppet-dev]/ensure: created
Error: /Stage[main]/Ssh/Sshkey[puppet-dev]: Could not evaluate: Field 'key' is required
Notice: /Stage[main]/Ssh/Sshkey[puppetdb]/ensure: created
Error: /Stage[main]/Ssh/Sshkey[puppetdb]: Could not evaluate: Field 'key' is required
Notice: /Stage[main]/Ssh/Sshkey[canary]/ensure: created
Error: /Stage[main]/Ssh/Sshkey[canary]: Could not evaluate: Field 'key' is required
Notice: Applied catalog in 0.33 seconds
edit retag flag offensive close merge delete

Comments

Are you sure that the value of $::sshdakey is populated? try putting it in an echo/notify statement, and comment out the line that prevents your catalog from compliling. To me, it seems like the variable isn't populated.

DarylW gravatar imageDarylW ( 2017-06-15 11:59:43 -0500 )edit

@DarylW I've updated the above per your comment, but I am still receiving complaints in regards to the Field key.

andrew91 gravatar imageandrew91 ( 2017-06-15 13:11:52 -0500 )edit