Skip to content
Snippets Groups Projects
Commit 6b0c4d38 authored by Vladimír Štill's avatar Vladimír Štill
Browse files

ansible: Add rudimentary samba role

parent bb21cd8b
No related branches found
No related tags found
No related merge requests found
homes: false
printers: false
import jinja2.runtime
def yesno(value, default="no") -> str:
if isinstance(value, jinja2.runtime.Undefined) or value is None:
return default
if value is True:
return "yes"
if value is False:
return "no"
raise ValueError(f"Value {value} not valid boolean")
def smb_list(value) -> str:
if isinstance(value, list):
assert all(map(lambda x: isinstance(x, str), value)), "values must be strings"
return ", ".join(value)
if isinstance(value, str):
return value
if isinstance(value, jinja2.runtime.Undefined) or value is None:
return ""
raise ValueError(f"Value {value} is neither list of strings nor a string (or undefined)")
class FilterModule(object):
def filters(self):
return {"yesno": yesno, "smb_list": smb_list}
- name: Install Samba
apt:
pkg:
- samba
- name: Samba public group
group:
name: smb
system: true
- name: Samba public user
user:
name: smb
group: smb
shell: /usr/sbin/nologin
home: /var/empty
system: true
create_home: false
- name: Samba config
template:
dest: /etc/samba/smb.conf
src: smb.conf.j2
validate: testparm -s %s
register: samba_config
- name: Reload Samba
systemd:
name: '{{item}}'
state: '{{"restarted" if samba_config.changed else "started"}}'
enabled: true
loop:
- smbd
- nmbd
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment