camptocamp / puppet-accounts

11 stars 40 forks source link

Function Call, has_key(): expects the first argument to be a hash, got "" which is of type String #30

Open Wicaeed opened 8 years ago

Wicaeed commented 8 years ago

Hi,

I'm getting the following error after specifying some user accounts to be created:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, has_key(): expects the first argument to be a hash, got "" which is of type String at /etc/puppetlabs/code/environments/production/modules/accounts/manifests/account.pp:21:10 at /etc/puppetlabs/code/environments/production/dist/profile/manifests/users_it.pp:4 on node

The accounts themselves are specified in hiera as such:

accounts::ssh_keys:
  user1:
    type: ssh-rsa
    public:  USR1-S-RSA-PUBLIC-KEY
  user2:
    type: ssh-rsa
    public: USR2-S-RSA-PUBLIC-KEY 
accounts::users:
  olduser:
    ensure: absent
  user1:
    uid: 1051
    ensure: present
  user2:
    uid: 1052
    ensure: present
accounts::usergroups:
   itusers:
     - user1
     - user2

I've already declared the required hashes in our base.pp profile, which also calls our users_it.pp profile to create the required users:

#Class to manage user accounts, authorized keys, groups, etc
class profile::users_it {

 accounts::account { '@itusers' : }

}

Any new Puppet runs against the test environment show the error saying that the has_key() Function Call extended a hash not string. That pretty much follows the example given on the readme, any idea where I'm going wrong?

lc525 commented 7 years ago

I would second the report above, seeing the same error with a similar config. Running puppet 5.

mazilu88 commented 6 years ago

First, you have to declare your ssh_keys, users and usergroups hashes:

class { 'accounts': ssh_keys => hiera_hash('accounts::ssh_keys', {}), users => hiera_hash('accounts::users', {}), usergroups => hiera_hash('accounts::usergroups', {}), }