Browse Source

Add support for .profile file

lookup-fix-3
Andres Montalban 9 years ago
parent
commit
750f2e6345
4 changed files with 56 additions and 1 deletions
  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 View File

Ensures the bashrc file exists in the users home directory. Set manage_bashrc: Ensures the bashrc file exists in the users home directory. Set manage_bashrc:
True in pillar per user. Defaults to False 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`` ``users.vimrc``
--------------- ---------------


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


+ 1
- 0
pillar.example View File

createhome: True createhome: True
manage_vimrc: False manage_vimrc: False
manage_bashrc: False manage_bashrc: False
manage_profile: False
expire: 16426 expire: 16426
sudouser: True sudouser: True
# sudo_rules doesn't need the username as a prefix for the rule # sudo_rules doesn't need the username as a prefix for the rule

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

# ~/.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 View File

{% 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…
Cancel
Save