Sfoglia il codice sorgente

Add support for .profile file

tags/v0.45.0
Andres Montalban 9 anni fa
parent
commit
750f2e6345
4 ha cambiato i file con 56 aggiunte e 1 eliminazioni
  1. +6
    -1
      README.rst
  2. +1
    -0
      pillar.example
  3. +22
    -0
      users/files/profile/profile
  4. +27
    -0
      users/profile.sls

+ 6
- 1
README.rst Vedi File

@@ -34,10 +34,15 @@ is configured.
Ensures the bashrc file exists in the users home directory. Set manage_bashrc:
True in pillar per user. Defaults to False

``users.profile``
----------------

Ensures the profile file exists in the users home directory. Set manage_profile:
True in pillar per user. Defaults to False

``users.vimrc``
---------------

Ensures the vimrc file exists in the users home directory. Set manage_vimrc:
True in pillar per user. Defaults to False
This depends on the vim-formula to be installed


+ 1
- 0
pillar.example Vedi File

@@ -12,6 +12,7 @@ users:
createhome: True
manage_vimrc: False
manage_bashrc: False
manage_profile: False
expire: 16426
sudouser: True
# sudo_rules doesn't need the username as a prefix for the rule

+ 22
- 0
users/files/profile/profile Vedi File

@@ -0,0 +1,22 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

+ 27
- 0
users/profile.sls Vedi File

@@ -0,0 +1,27 @@
{% from "users/map.jinja" import users with context %}
include:
- users

{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
{%- if user == None -%}
{%- set user = {} -%}
{%- endif -%}
{%- set home = user.get('home', "/home/%s" % name) -%}
{%- set manage = user.get('manage_profile', False) -%}
{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
{%- set user_group = user.prime_group.name -%}
{%- else -%}
{%- set user_group = name -%}
{%- endif %}
{%- if manage -%}
users_{{ name }}_user_profile:
file.managed:
- name: {{ home }}/.profile
- user: {{ name }}
- group: {{ user_group }}
- mode: 644
- source:
- salt://users/files/profile/{{ name }}/profile
- salt://users/files/profile/profile
{% endif %}
{% endfor %}

Loading…
Annulla
Salva