camptocamp / puppet-accounts

11 stars 40 forks source link

Merge group arrays instead of rightmost precedence #65

Closed kobybr closed 5 years ago

raphink commented 5 years ago

Could you provide an example of what you're trying to achieve here, or ideally a collection of unit tests this PR allows to pass?

kobybr commented 5 years ago

Yes, I can add some unit tests.

Basically, I have two yaml files. One managed locally and one acquired via hiera-http backend. Hashes are merged via hiera lookup function.

The end result I am looking for is that user1 is created and added to groups group1 and group2. With the existing code, user1 is only added to group2 to due to the merge functions right order precedence

hiera1.yaml

profile::core::groups:
  group1:
    gid: 30000

profile::core::users:
  user1:
    groups: 
      - group1

hiera2.yaml

profile::core::groups:
  group2:
    gid: 30001

profile::core::users:
  user1:
     comments: User 1
  user2:
     comments: User 2

profile::core::usergroups:
    groupsofusers:
       - user1
       - user2

profile::core::accounts:
    '@groupsofusers':
         groups:
           - group2
kobybr commented 5 years ago

Unit test added.

raphink commented 5 years ago

OK I get the idea. Could you separate the system parameter in a different PR and add some doc maybe?

raphink commented 5 years ago

Thanks. @mcanevet care to give me a second opinion?

kobybr commented 5 years ago

Any word on this?