initial commit

This commit is contained in:
pyrschtjag committed 2026-10-02 21:34:01 +04:00
commit 13eace9ce9
219 files changed
+6918

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
- name: restart samba
ansible.builtin.systemd:
name: smbd
state: restarted
enabled: true
+51
View File
@@ -0,0 +1,51 @@
---
- name: create media group
ansible.builtin.group:
name: media
gid: 1000
state: present
- name: install samba
ansible.builtin.apt:
name: samba
state: latest
update_cache: true
- name: create samba users
ansible.builtin.user:
name: "{{ hostvars[item].smb_user }}"
shell: /usr/sbin/nologin
groups: media
append: true
create_home: false
state: present
loop: "{{ smb_managed_group | default([]) }}"
loop_control:
label: "{{ item }}"
when: >
hostvars[item].smb_user is defined and
hostvars[item].smb_container is defined and
inventory_hostname in hostvars[item].smb_container
- name: set samba password for users
ansible.builtin.shell: |
printf '%s\n%s\n' "{{ hostvars[item].smb_password }}" "{{ hostvars[item].smb_password }}" | smbpasswd -s -a {{ hostvars[item].smb_user }}
loop: "{{ smb_managed_group | default([]) }}"
loop_control:
label: "{{ item }}"
when: >
hostvars[item].smb_user is defined and
hostvars[item].smb_password is defined and
hostvars[item].smb_container is defined and
inventory_hostname in hostvars[item].smb_container
changed_when: false
no_log: true
- name: deploy samba config
ansible.builtin.template:
src: "{{ inventory_hostname }}/smb.conf.j2"
dest: "/etc/samba/smb.conf"
owner: root
group: root
mode: '0644'
notify: restart samba
@@ -0,0 +1,41 @@
[global]
log file = /var/log/samba/%m.log
log level = 1
max log size = 50
smb ports = 445 139
workgroup = WORKGROUP
server string = PS2 Samba Server
server role = standalone server
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
map to guest = Never
pam password change = yes
ntlm auth = yes
lanman auth = yes
server min protocol = NT1
server signing = disabled
smb encrypt = disabled
create mask = 0664
directory mask = 0775
force group = media
socket options = TCP_NODELAY TCP_KEEPIDLE=20 IPTOS_LOWDELAY SO_KEEPALIVE
keepalive = 0
large readwrite = yes
follow symlinks = yes
idmap config * : backend = tdb
idmap config * : range = 3000-7999
[PS2]
comment = PlayStation 2
path = /mnt/media1/.ps2opl
browsable = yes
read only = no
guest ok = no
{% set users = smb_managed_group | default([]) | map('extract', hostvars) | selectattr('smb_user', 'defined') | selectattr('smb_container', 'defined') | selectattr('smb_container', 'contains', inventory_hostname) | map(attribute='smb_user') | list %}
{% if users | length > 0 %}
valid users = {{ users | join(' ') }}
{% endif %}
veto files = /._*/.apdisk/.AppleDouble/.DS_Store/.TemporaryItems/.Trashes/desktop.ini/ehthumbs.db/Network Trash Folder/Temporary Items/Thumbs.db/
delete veto files = yes