{"action":"created","issue":{"url":"https://api.github.com/repos/rnelson0/puppet-local_user/issues/39","repository_url":"https://api.github.com/repos/rnelson0/puppet-local_user","labels_url":"https://api.github.com/repos/rnelson0/puppet-local_user/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/rnelson0/puppet-local_user/issues/39/comments","events_url":"https://api.github.com/repos/rnelson0/puppet-local_user/issues/39/events","html_url":"https://github.com/rnelson0/puppet-local_user/issues/39","id":132254402,"number":39,"title":"Deeper merge: ssh_authorized_keys in two locations results in duplicate resources","user":{"login":"bbriggs","id":2350379,"avatar_url":"https://avatars.githubusercontent.com/u/2350379?v=3","gravatar_id":"","url":"https://api.github.com/users/bbriggs","html_url":"https://github.com/bbriggs","followers_url":"https://api.github.com/users/bbriggs/followers","following_url":"https://api.github.com/users/bbriggs/following{/other_user}","gists_url":"https://api.github.com/users/bbriggs/gists{/gist_id}","starred_url":"https://api.github.com/users/bbriggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbriggs/subscriptions","organizations_url":"https://api.github.com/users/bbriggs/orgs","repos_url":"https://api.github.com/users/bbriggs/repos","events_url":"https://api.github.com/users/bbriggs/events{/privacy}","received_events_url":"https://api.github.com/users/bbriggs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-08T20:55:08Z","updated_at":"2016-02-08T21:00:41Z","closed_at":null,"body":"Error:\r\n```\r\nError: Duplicate declaration: Ssh_authorized_key[bar_ssh-rsa_bar@localhost] is already declared in file /etc/puppet/modules/local_user/manifests/ssh_authorized_keys.pp:32; cannot redeclare at /etc/puppet/modules/local_user/manifests/ssh_authorized_keys.pp:32 on node node.example.com\r\n```\r\n\r\nhiera.yaml:\r\n```yaml\r\n---\r\n:backends:\r\n  - yaml\r\n  - json\r\n:yaml:\r\n  :datadir: /etc/puppet/hieradata\r\n:json:\r\n  :datadir: /etc/puppet/hieradata\r\n:hierarchy:\r\n  - \"node/%{::fqdn}\"\r\n  - \"%{::operatingsystem}\"\r\n  - \"common\"\r\n:merge_behavior: deeper\r\n```\r\nnode.yaml:\r\n```\r\nlocal_users:\r\n    bar:\r\n        state:            'present'\r\n        home:             '/home/bar'\r\n        managehome:       true\r\n        comment:          'bar'\r\n        groups:\r\n            - wheel\r\n        gid:              'bar'\r\n        password:         ''\r\n        password_max_age: '1000'\r\n        ssh_authorized_keys:\r\n            - 'ssh-rsa AAAA...1234 bar@localhost'\r\n```\r\n\r\ncommon.yaml:\r\n```yaml\r\n    bar:\r\n        state:            'absent'\r\n        home:             '/home/bar'\r\n        managehome:       true\r\n        comment:          'bar'\r\n        groups:\r\n            - wheel\r\n        gid:              'bar'\r\n        password:         ''\r\n        password_max_age: '1000'\r\n        ssh_authorized_keys:\r\n            - 'ssh-rsa AAAA..1234 bar@localhost'\r\n```\r\n\r\nsite.pp:\r\n```puppet\r\n$users  = hiera_hash('local_users', undef)\r\nif ($users != undef) {\r\n    create_resources('local_user', $users)\r\n}\r\n```\r\n\r\nhash:\r\n```\r\nbar\"=>\r\n  {\"state\"=>\"present\",\r\n   \"home\"=>\"/home/bar\",\r\n   \"managehome\"=>true,\r\n   \"comment\"=>\"bar\",\r\n   \"groups\"=>[\"wheel\"],\r\n   \"gid\"=>\"bar\",\r\n   \"password\"=>\"\",\r\n   \"password_max_age\"=>\"1000\",\r\n   \"ssh_authorized_keys\"=>\r\n    [\"ssh-rsa AAAA...1234 bar@localhost\"]}\r\n``` \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rnelson0/puppet-local_user/issues/comments/181565714","html_url":"https://github.com/rnelson0/puppet-local_user/issues/39#issuecomment-181565714","issue_url":"https://api.github.com/repos/rnelson0/puppet-local_user/issues/39","id":181565714,"user":{"login":"bbriggs","id":2350379,"avatar_url":"https://avatars.githubusercontent.com/u/2350379?v=3","gravatar_id":"","url":"https://api.github.com/users/bbriggs","html_url":"https://github.com/bbriggs","followers_url":"https://api.github.com/users/bbriggs/followers","following_url":"https://api.github.com/users/bbriggs/following{/other_user}","gists_url":"https://api.github.com/users/bbriggs/gists{/gist_id}","starred_url":"https://api.github.com/users/bbriggs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbriggs/subscriptions","organizations_url":"https://api.github.com/users/bbriggs/orgs","repos_url":"https://api.github.com/users/bbriggs/repos","events_url":"https://api.github.com/users/bbriggs/events{/privacy}","received_events_url":"https://api.github.com/users/bbriggs/received_events","type":"User","site_admin":false},"created_at":"2016-02-08T21:00:41Z","updated_at":"2016-02-08T21:00:41Z","body":"It seems that the [array behavior of deeper merge](https://docs.puppetlabs.com/hiera/1/lookup_types.html#deep-merging-in-hiera--120) is in play here:\r\n\"…an array and exists in two or more source hashes, the values from each source are merged into a single array and de-duplicated (but not automatically flattened, as in an array merge lookup).\"\r\n\r\nIt doesn't appear that the de-duplication is happening for some reason. "}}