---
{%- from "samba/map.jinja" import samba with context %}
{%- from "samba/map.jinja" import users with context %}

{%- for name, user in users.items() %}
samba-user-{{ name }}:
{%- if user.enabled %}
  pdbedit.managed:
    - name: {{ name }}
    - login: {{ name }}
    - password: "{{ user.password }}"
{%- else %}
  pdbedit.absent:
    - name: {{ name }}
{%- endif %}
    - require:
      - pkg: samba-pkg
{%- endfor %}