weareinteractive / ansible-users

Ansible role which creates and manages users

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Give user permissions to directory

ndench opened this issue · comments

It would be great if you could also give the created user permissions some directories/files. At the moment I have to have another role which depends on this one which just gives permissions.

A couple of options to configure this would be to add a list of permissions to the user element of the users list:

users:
   - username: foobar
     groups:
         - foobaz
     authorized_keys:
         - "ssh-rsa ..."
     permissions:
         - path: /srv/www
           state: directory
           owner: true
           group: foobaz
           mode: 0640

Or the permissions could be another top level variable:

users:
   - username: foobar
     groups:
         - foobaz
     authorized_keys:
         - "ssh-rsa ..."

permissions:
    - path: /srv/www
      owner: foorbar
      state: directory
      group: foobaz
      mode: 0640

Do you think you will be a good fit for the role? If so, I'm happy to send through a PR.

Hi, sorry for not answering but just got back from my asia trip.
I try to keep my roles as simple as possible thus using a different role that depends on this one is a good approach. That's exactly what I did with my franklinkim.users-git and franklinkim.users-oh-my-zsh roles. They just expect data on the user object i.e.

users:
  - username: foobar
    ...
    oh_my_zsh:
        ...

The way I usually handle permissions is through roles and then using i.e. franklinkim.files to create the directories with the correct permissions

Ah awesome. I didn't find franklinkim.files when I first looked for a role to do this. Thanks for the help :)