Initial Lab Setup
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
- name: Restart Samba
|
||||
ansible.builtin.service:
|
||||
name: smbd
|
||||
state: restarted
|
||||
@@ -0,0 +1,47 @@
|
||||
- name: Install Samba packages
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- samba
|
||||
- samba-common-bin
|
||||
- smbclient
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: yes
|
||||
|
||||
- name: Ensure Samba shared directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
loop: "{{ samba_shares }}"
|
||||
become: yes
|
||||
|
||||
- name: Deploy Samba configuration from template
|
||||
ansible.builtin.template:
|
||||
src: smb.conf.template
|
||||
dest: /etc/samba/smb.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
become: yes
|
||||
notify: Restart Samba
|
||||
|
||||
|
||||
#- name: Ensure Samba shared directories exist
|
||||
# ansible.builtin.file:
|
||||
# path: "{{ item.path }}"
|
||||
# state: directory
|
||||
# loop: "{{ samba_shares }}"
|
||||
# owner: "{{ item.force_user | default('volker') }}"
|
||||
# group: "{{ item.group | default('volker') }}"
|
||||
# mode: "{{ item.mode | default('0775') }}"
|
||||
# loop: "{{ samba_shares }}"
|
||||
# ignore_errors: yes # <-- Das fängt den chown-Fehler bei externen Mounts ab
|
||||
|
||||
#- name: Ensure Samba services are started and enabled
|
||||
# ansible.builtin.service:
|
||||
# name: "{{ item }}"
|
||||
# state: started
|
||||
# enabled: yes
|
||||
# loop:
|
||||
# - smbd
|
||||
# - nmbd
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: Install and Configure Samba
|
||||
hosts: samba_servers
|
||||
become: yes
|
||||
tasks:
|
||||
- name: Install Samba
|
||||
package:
|
||||
name: samba
|
||||
state: present
|
||||
- name: Ensure NFS utilities are installed.
|
||||
apt:
|
||||
name:
|
||||
- nfs-common
|
||||
- nfs-kernel-server
|
||||
state: present
|
||||
- name: Configure smb.conf
|
||||
template:
|
||||
src: smb.conf.template
|
||||
dest: /etc/samba/smb.conf
|
||||
notify: restart samba
|
||||
|
||||
# handlers:
|
||||
# - name: restart samba
|
||||
# service:
|
||||
# name: smbd
|
||||
# state: restarted
|
||||
# state: present
|
||||
@@ -0,0 +1,40 @@
|
||||
[global]
|
||||
workgroup = WORKGROUP
|
||||
netbios name = {{ inventory_hostname }}
|
||||
server string = %h server (Samba, Ubuntu)
|
||||
log file = /var/log/samba/log.%m
|
||||
max log size = 1000
|
||||
logging = file
|
||||
panic action = /usr/share/samba/panic-action %d
|
||||
server role = standalone server
|
||||
obey pam restrictions = yes
|
||||
unix password sync = yes
|
||||
passwd program = /usr/bin/passwd %u
|
||||
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
|
||||
pam password change = yes
|
||||
map to guest = bad user
|
||||
usershare allow guests = yes
|
||||
# --- macOS Optimization (Fruit) ---
|
||||
vfs objects = fruit streams_xattr recycle
|
||||
fruit:model = MacPro7,1@ECOLOR=226,226,224
|
||||
fruit:metadata = stream
|
||||
fruit:veto_appledouble = no
|
||||
fruit:posix_rename = yes
|
||||
|
||||
# --- Recycle Bin Logic ---
|
||||
recycle:touch = yes
|
||||
recycle:keeptree = yes
|
||||
recycle:versions = yes
|
||||
|
||||
# Dynamic Shares Loop
|
||||
{% for share in samba_shares %}
|
||||
[{{ share.name }}]
|
||||
path = {{ share.path }}
|
||||
browseable = {{ share.browseable | default('yes') }}
|
||||
read only = {{ share.read_only | default('no') }}
|
||||
guest ok = {{ share.guest_ok | default('yes') }}
|
||||
{% if share.force_user is defined %}
|
||||
force user = {{ share.force_user }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user