Giter Club home page Giter Club logo

ansible-role-users's Introduction

Ansible role - users

Maintainer License Release Status Ansible version Ansible Galaxy

⭐ Star us on GitHub — it motivates us a lot!

Create groups, users and set users's dotfiles.

⚠️ Requirements

Ansible >= 2.10

⚡ Installation

ansible-galaxy install claranet.users

⚙️ Role variables

Users

Users supported attributes are name, append, shell, createhome, home, password, uid, group, groups, update_password, state, remove and comment. More informations

Variable Default value Description
users {} Create groups, users and enable bashrc, ssh/config, vimrc and profile files

Please note that we need to chattr -a the .bash_history file in order to manage groups changes !

Packages

Variable Default value Description
users_packages ["bash","bash-completion","vim","e2fsprogs"] List of required packages for users

Global variables

Variable Default value Description
users_umask 022 Default umask for files created by users
users_lang POSIX Default lang variable
users_editor vim Default editor is vim
users_ls_options --color=auto Default ls options

Dotfiles

Variable Default value Description
users_default_bashrc defaults/main.yml Manage .bashrc file content
users_default_vimrc defaults/main.yml Manage .vimrc file content
users_default_profile defaults/main.yml Manage .profile file content
users_bashrc_histcontrol ignoreboth Set HISTCONTROL variable
users_bashrc_histsize 5000 Set HISTSIZE variable
users_bashrc_histfilesize 20000 Set HISTFILESIZE variable
users_bashrc_histtimeformat %d-%m-%y %T Set HISTTIMEFORMAT variable
users_bashrc_template users/bashrc.j2 Configures ~/.bashrc
users_ssh_config_template users/ssh_config.j2 Configures ~/.ssh/config
users_vimrc_template users/vimrc.j2 Configures ~/.vimrc
users_profile_template users/profile.j2 Configures ~/.profile

Dotfiles (bashrc, ssh/config, vimrc, profile) are not enabled by default. You need to define them explicitly in the wanted user. (See example below).

🔄 Dependencies

See tasks/install.yml.

✏️ Example Playbook

---
- hosts: all
  become: true
  become_user: root
  roles:
    - claranet.users
  vars:
    users:
      root:
        home: /root
        group: wheel
        password: "*"
        authorized_keys: ["ssh-rsa xxx"]
        bashrc:
          - 'export PS1=''\[\033[01;31m\]\u\[\033[00m\]@$(hostname -f) \[\033[01;34m\]\w \$\[\033[00m\] '''
        vimrc:
          - "color desert"
        profile: {}
        ssh_config:
          'mysrv*':
            identityFile: /home/user/.ssh/user
        ssh_keys:
          id_rsa:
            public: 'ssh-rsa '
            private: "{{ lookup('community.hashi_vault.hashi_vault', 'secret/ssh:private_key') }}"
        update_password: "on_create"         # default is always

©️ License

Mozilla Public License Version 2.0

ansible-role-users's People

Contributors

bngameni avatar dkmatt0 avatar eliedeloumeau avatar nicolasvion avatar pdecat avatar tchernomax avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

muraliv21

ansible-role-users's Issues

[Bashrc] items not added to file

It seems to be that the bashrc configuration isn't working

Ex:

vars:
users:
root:
bashrc:
- "alias myalias='mycmd'"

Tasks doesn't seems to be skipped :

TASK [claranet.users : configure_bash | ~root/.bashrc] ******************************************************************************************************************************************************************************[60/1011]
Tuesday 28 September 2021 08:46:00 +0000 (0:00:00.067) 0:00:05.651 *****
ok: [centos]

Expected Behavior

[root@c9531f5a57bb ~]# grep myalias .bashrc
[root@c9531f5a57bb ~]#

Current Behavior

[root@c9531f5a57bb ~]# grep myalias .bashrc
[root@c9531f5a57bb ~]# alias myalias='mycmd'

Hardening (discussion)

Hello,

Here is an issue to talk about users hardening.

I think that we should add this in profile :

shopt -s histappend
readonly PROMPT_COMMAND=”history -a”
readonly HISTFILESIZE
readonly HISTSIZE
readonly HISTCMD
readonly HISTCONTROL
readonly HISTIGNORE

Do you have other suggestions?

Can't remove user

Expected Behavior

We can't remove a user

Current Behavior

State is not taken into account

Possible Solution

Add

state:  '{{ state|default("present") }}'

Context

Delete a user that was created with ansible-roles-users

Some empty vars seems to be required

It seems to be that we must set up the following vars :
home: /root
ssh_keys: {}
authorized_keys:

Expected Behavior

If these vars are empty, we should not have to defined them ?
If home var is required, maybe we should define it to /root for the root user and /home/$user by default for others users ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.