Merge pull request #71 from aboe76/improve_bashrc_vimrc
Enable/disable bashrc/vimrc per user
This commit is contained in:
commit
b64401c6b2
@ -31,11 +31,13 @@ is configured.
|
|||||||
``users.bashrc``
|
``users.bashrc``
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Ensures the bashrc file exists in the users home directory
|
Ensures the bashrc file exists in the users home directory. Set manage_bashrc:
|
||||||
|
True in pillar per user. Defaults to False
|
||||||
|
|
||||||
``users.vimrc``
|
``users.vimrc``
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Ensures the vimrc file exists in the users home directory.
|
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
|
This depends on the vim-formula to be installed
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ users:
|
|||||||
password: $6$w.............
|
password: $6$w.............
|
||||||
home: /custom/buser
|
home: /custom/buser
|
||||||
createhome: True
|
createhome: True
|
||||||
|
manage_vimrc: False
|
||||||
|
manage_bashrc: False
|
||||||
expire: 16426
|
expire: 16426
|
||||||
sudouser: True
|
sudouser: True
|
||||||
sudo_rules:
|
sudo_rules:
|
||||||
|
@ -2,25 +2,26 @@
|
|||||||
include:
|
include:
|
||||||
- users
|
- users
|
||||||
|
|
||||||
extend:
|
|
||||||
{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
|
{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
|
||||||
{%- if user == None -%}
|
{%- if user == None -%}
|
||||||
{%- set user = {} -%}
|
{%- set user = {} -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- set home = user.get('home', "/home/%s" % name) -%}
|
{%- set home = user.get('home', "/home/%s" % name) -%}
|
||||||
|
{%- set manage = user.get('manage_bashrc', False) -%}
|
||||||
{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
|
{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
|
||||||
{%- set user_group = user.prime_group.name -%}
|
{%- set user_group = user.prime_group.name -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- set user_group = name -%}
|
{%- set user_group = name -%}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
users_{{ name }}_user:
|
{%- if manage -%}
|
||||||
file.managed:
|
users_{{ name }}_user_bashrc:
|
||||||
- name: {{ home }}/.bashrc
|
file.managed:
|
||||||
- owner: {{ name }}
|
- name: {{ home }}/.bashrc
|
||||||
- group: {{ user_group }}
|
- user: {{ name }}
|
||||||
- mode: 644
|
- group: {{ user_group }}
|
||||||
- source:
|
- mode: 644
|
||||||
- salt://users/files/bashrc/{{ name }}/bashrc
|
- source:
|
||||||
- salt://users/files/bashrc/bashrc
|
- salt://users/files/bashrc/{{ name }}/bashrc
|
||||||
|
- salt://users/files/bashrc/bashrc
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -3,25 +3,26 @@ include:
|
|||||||
- users
|
- users
|
||||||
- vim
|
- vim
|
||||||
|
|
||||||
extend:
|
|
||||||
{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
|
{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
|
||||||
{%- if user == None -%}
|
{%- if user == None -%}
|
||||||
{%- set user = {} -%}
|
{%- set user = {} -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- set home = user.get('home', "/home/%s" % name) -%}
|
{%- set home = user.get('home', "/home/%s" % name) -%}
|
||||||
|
{%- set manage = user.get('manage_vimrc', False) -%}
|
||||||
{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
|
{%- if 'prime_group' in user and 'name' in user['prime_group'] %}
|
||||||
{%- set user_group = user.prime_group.name -%}
|
{%- set user_group = user.prime_group.name -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- set user_group = name -%}
|
{%- set user_group = name -%}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
users_{{ name }}_user:
|
{%- if manage -%}
|
||||||
file.managed:
|
users_{{ name }}_user_vimrc:
|
||||||
- name: {{ home }}/.vimrc
|
file.managed:
|
||||||
- owner: {{ name }}
|
- name: {{ home }}/.vimrc
|
||||||
- group: {{ user_group }}
|
- user: {{ name }}
|
||||||
- mode: 644
|
- group: {{ user_group }}
|
||||||
- source:
|
- mode: 644
|
||||||
- salt://users/files/vimrc/{{ name }}/vimrc
|
- source:
|
||||||
- salt://users/files/vimrc/vimrc
|
- salt://users/files/vimrc/{{ name }}/vimrc
|
||||||
|
- salt://users/files/vimrc/vimrc
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user