Parcourir la source

Added bashrc extension to users-formula

This will ensure a given bashrc file in a users home dir.
Default it will search for a bashrc in salt://users/files/bashrc/{{ username }}/bashrc
If no file is found it will install the default from
salt://users/files/bashrc/bashrc
lookup-fix-3
Niels Abspoel il y a 9 ans
Parent
révision
29ce431151
2 fichiers modifiés avec 35 ajouts et 0 suppressions
  1. +26
    -0
      users/bashrc.sls
  2. +9
    -0
      users/files/bashrc/bashrc

+ 26
- 0
users/bashrc.sls Voir le fichier

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

extend:
{% 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) -%}

{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
{%- set user_group = user.prime_group.name -%}
{%- else -%}
{%- set user_group = name -%}
{%- endif %}
users_{{ name }}_user:
file.managed:
- name: {{ home }}/.bashrc
- owner: {{ name }}
- group: {{ user_group }}
- mode: 644
- sources:
- salt://users/files/bashrc/{{ name }}/bashrc
- salt://users/files/bashrc/bashrc
{% endfor %}

+ 9
- 0
users/files/bashrc/bashrc Voir le fichier

@@ -0,0 +1,9 @@
#
# ~/.bashrc
#
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '

Chargement…
Annuler
Enregistrer