项目作者: notpixxl

项目描述 :
Ansible role to create user for formation purpose
高级语言:
项目地址: git://github.com/notpixxl/ansible-role-formationuser.git
创建时间: 2020-05-06T09:52:09Z
项目社区:https://github.com/notpixxl/ansible-role-formationuser

开源协议:

下载


Ansible Role User Formation

Role For create users on Linux Server, this role is only use for formation pupose, do not use it in production environnement

Requirements

  • Ansible user module

Creating users

Add a users variable containing the list of users to add. A good place to put
this is in group_vars/all or group_vars/groupname if you only want the
users to be on certain machines.

The following attributes are required for each user:

  • username - The user’s username.
  • name - The full name of the user (gecos field).
  • home - The home directory of the user to create (optional, defaults to /home/username).
  • uid - The numeric user id for the user (optional). This is required for uid consistency
    across systems.
  • gid - The numeric group id for the group (optional). Otherwise, the
    uid will be used.
  • password - If a hash is provided then that will be used, but otherwise the
    account will be locked.
  • update_password - This can be either ‘always’ or ‘on_create’
    • ‘always’ will update passwords if they differ. (default)
    • ‘on_create’ will only set the password for newly created users.
  • group - Optional primary group override.
  • groups - A list of supplementary groups for the user.
  • append - If yes, will only add groups, not set them to just the list in groups (optional).
  • profile - A string block for setting custom shell profiles.
  • ssh_key - This should be a list of SSH keys for the user (optional). Each SSH key
    should be included directly and should have no newlines.
  • generate_ssh_key - Whether to generate a SSH key for the user (optional, defaults to no).

In addition, the following items are optional for each user:

  • shell - The user’s shell. This defaults to /bin/bash. The default is
    configurable using the users_default_shell variable if you want to give all
    users the same shell, but it is different than /bin/bash.

Example:

  1. ---
  2. users:
  3. - username: foo
  4. name: Foo Barrington
  5. groups: ['wheel','systemd-journal']
  6. uid: 1001
  7. home: /local/home/foo
  8. profile: |
  9. alias ll='ls -lah'
  10. ssh_key:
  11. - "ssh-rsa AAAAA.... foo@machine"
  12. - "ssh-rsa AAAAB.... foo2@machine"
  13. groups_to_create:
  14. - name: developers
  15. gid: 10000
  16. users_deleted:
  17. - username: bar
  18. name: Bar User
  19. uid: 1002

Dependencies

None.

Example Playbook

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

  1. - hosts: servers
  2. roles:
  3. - { role: username.rolename, x: 42 }

License

BSD

Author Information

christophepiv@gmail.com
trololo.com