From 8be1f8d305befaa3e371c0575d71b33938b9a9d3 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Mon, 10 Oct 2022 10:17:01 +0200 Subject: [PATCH] updated samba state --- states/samba/config.sls | 5 ++++- states/samba/service.sls | 11 +++++++++++ states/samba/users.sls | 10 +++++----- 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 states/samba/service.sls diff --git a/states/samba/config.sls b/states/samba/config.sls index 2f44ebf..acf6d7f 100644 --- a/states/samba/config.sls +++ b/states/samba/config.sls @@ -1,6 +1,9 @@ --- {%- from "samba/map.jinja" import samba with context %} samba-config: - ini_manage.options_present: + ini.options_present: - name: /etc/samba/smb.conf - sections: {{ samba.config }} + - watch_in: + - service: samba-service-smbd + - service: samba-service-nmbd diff --git a/states/samba/service.sls b/states/samba/service.sls new file mode 100644 index 0000000..64aff8d --- /dev/null +++ b/states/samba/service.sls @@ -0,0 +1,11 @@ +--- +{%- from "samba/map.jinja" import samba with context %} +samba-service-smbd: + service.running: + - name: smbd + - reload: True + +samba-service-nmbd: + service.running: + - name: nmbd + - restart: True diff --git a/states/samba/users.sls b/states/samba/users.sls index 138a796..4638cca 100644 --- a/states/samba/users.sls +++ b/states/samba/users.sls @@ -2,16 +2,16 @@ {%- from "samba/map.jinja" import samba with context %} {%- from "samba/map.jinja" import users with context %} -{%- for user in users %} -samba-user-{{ user.name }}: +{%- for name, user in users.items() %} +samba-user-{{ name }}: {%- if user.enabled %} pdbedit.managed: - - name: {{ user.name }} - - login: {{ user.name }} + - name: {{ name }} + - login: {{ name }} - password: "{{ user.password }}" {%- else %} pdbedit.absent: - - name: {{ user.name }} + - name: {{ name }} {%- endif %} - require: - pkg: samba-pkg