camptocamp / puppet-accounts

11 stars 40 forks source link

User isn't added into groups. #36

Closed ngoduykhanh closed 8 years ago

ngoduykhanh commented 8 years ago

Hi,

I am using this module for my Ubuntu Server 14.04, I've defined the heiradata below

accounts::ssh_keys:
  my-username:
    type: ssh-rsa
    public: my-public-key-here

accounts::users:
  my-username:
    uid: 1010
    shell: /bin/bash

accounts::usergroups:
  sudo:
    - my-username

The user my-username is created as expected but it doesn't belong to sudo group. Do you have any idea how to add a user into group?

For my reason, I am using accounts::account { '@sudo': } to create accounts which belong to a group. My current class:

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

    accounts::account { '@sudo': }
}
johnzimm commented 8 years ago

"usergroups" isn't actually groups on the server. It is "groups of users" to provision on the server. You'll need to specify which groups a user belongs to in the hash of accounts::users.

https://github.com/camptocamp/puppet-accounts/blob/master/manifests/account.pp

So in your case the example might look like...

accounts::users:
  my-username:
    uid: 1010
    shell: /bin/bash
    groups:
      - 'sudo'
      - 'anothergroup'

accounts::usergroups:
  provision-this-group-of-users:
    - my-username

Then

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

    accounts::account { '@provision-this-group-of-users': }
}

I found it confusing at first as well.

ngoduykhanh commented 8 years ago

Yes, it makes me confused. Adding groups in accounts::users: helped. Thank you!.