diff --git a/states/users/defaults.yaml b/states/users/defaults.yaml index 778d161..5133c68 100644 --- a/states/users/defaults.yaml +++ b/states/users/defaults.yaml @@ -1,3 +1,3 @@ --- -users: [] -groups: [] +users: {} +groups: {} diff --git a/states/users/groups.sls b/states/users/groups.sls index 38e9e74..f3235a5 100644 --- a/states/users/groups.sls +++ b/states/users/groups.sls @@ -1,12 +1,12 @@ --- {%- from "users/map.jinja" import groups with context -%} -{%- for group in groups %} -group-{{ group.name }}: +{%- for name,group in groups.items() %} +group-{{ name }}: {%- if group.enabled %} group.present: {%- else %} group.absent: {%- endif %} - - name: {{ group.name }} + - name: {{ name }} {% endfor %} diff --git a/states/users/ssh-keys.sls b/states/users/ssh-keys.sls index d50c520..b5a9f99 100644 --- a/states/users/ssh-keys.sls +++ b/states/users/ssh-keys.sls @@ -1,16 +1,16 @@ --- {%- from "users/map.jinja" import users with context -%} -{%- for user in users %} +{%- for username,user in users.items() %} {%- if user.sshkeys is defined %} {%- for key in user.sshkeys %} -ssh-key-{{ user.name }}-{{ key.name }}: +ssh-key-{{ username }}-{{ key.name }}: ssh_auth.{{ key.state }}: - - user: {{ user.name }} + - user: {{ username }} - names: - {{ key.value }} - require: - - user: user-{{ user.name }} + - user: user-{{ username }} {% endfor %} {%- endif -%} {% endfor %} diff --git a/states/users/users.sls b/states/users/users.sls index 941fc96..a55c84d 100644 --- a/states/users/users.sls +++ b/states/users/users.sls @@ -1,18 +1,18 @@ --- {%- from "users/map.jinja" import users with context -%} -{%- for user in users %} - -{%- if not user.enabled %} -user-{{ user.name }}: - user.absent: - - name: {{ user.name }} +{%- for name, user in users.items() %} + +{%- if not user.enabled %} +user-{{ name }}: + user.absent: + - name: {{ name }} {%- endif %} - + {%- if user.enabled %} -user-{{ user.name }}: +user-{{ name }}: user.present: - - name: {{ user.name }} + - name: {{ name }} - fullname: {{ user.fullname }} - shell: {{ user.shell }} - home: {{ user.home }} diff --git a/states/zsh/defaults.yaml b/states/zsh/defaults.yaml index 0f835ff..3f86edb 100644 --- a/states/zsh/defaults.yaml +++ b/states/zsh/defaults.yaml @@ -5,4 +5,4 @@ zsh: minimal: false golang: true rust: true - android: false \ No newline at end of file + android: false diff --git a/states/zsh/map.jinja b/states/zsh/map.jinja index 803a4ec..3495d29 100644 --- a/states/zsh/map.jinja +++ b/states/zsh/map.jinja @@ -3,4 +3,4 @@ {%- set defaults = salt['grains.filter_by'](default_settings, default='zsh') -%} {%- set zsh = salt['pillar.get']('zsh', default=defaults, merge=True) -%} -{%- set users = salt['pillar.get']('users', default=defaults, merge=True) -%} \ No newline at end of file +{%- set users = salt['pillar.get']('users') -%} \ No newline at end of file diff --git a/states/zsh/users.sls b/states/zsh/users.sls index faf1e1d..4c4b0b7 100644 --- a/states/zsh/users.sls +++ b/states/zsh/users.sls @@ -1,17 +1,17 @@ --- {%- from "zsh/map.jinja" import users with context %} -{%- for user in users %} +{%- for name, user in users.items() %} {%- if user.enabled %} -zshrc-user-{{ user.name }}: +zshrc-user-{{ name }}: file.managed: - name: {{ user.home }}/.zshrc - source: salt://zsh/zshrc.j2 - - user: {{ user.name }} + - user: {{ name }} - group: {{ user.gid }} - mode: 0644 - template: jinja - require: - pkg: zsh-pkg - - user: user-{{ user.name }} + - user: user-{{ name }} {%- endif %} {%- endfor %} \ No newline at end of file diff --git a/states/zsh/zprofile.j2 b/states/zsh/zprofile.j2 index 2f4f548..f5e257a 100644 --- a/states/zsh/zprofile.j2 +++ b/states/zsh/zprofile.j2 @@ -53,7 +53,11 @@ then source $ZSH/oh-my-zsh.sh fi -alias vim=nvim +# Neovim aliases +for i in v vi vim +do + alias $i=nvim +done alias weather="curl -s wttr.in/caen" # Misc settings