Skip to content

Commit

Permalink
Merge pull request #120 from tdltdc/119-add-disable-netbios-param
Browse files Browse the repository at this point in the history
Add samba_disable_netbios and + split Samba services (re)starting into separate tasks
  • Loading branch information
vladgh authored Nov 19, 2023
2 parents d1ba690 + 40449e8 commit 5fc7eaa
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Alternatively, you can directly import the existing playbook:
| `samba_apple_extensions` | `no` | When yes, enables support for Apple specific SMB extensions. Required for Time Machine support to work (see below) |
| `samba_create_varwww_symlinks` | `false` | When true, symlinks are created in web docroot to the shares. (`var/www/` or `/var/www/html` depending on platform) |
| `samba_cups_server` | `localhost:631` | Value for the global option `cups server` (only needed when `samba_printer_type` is "cups") |
| `samba_enable_netbios` | `true` | When false, the NMB daemon is disabled by setting `disable netbios` to `yes`. This overrides other NetBIOS related settings. |
| `samba_domain_master` | `true` | When true, smbd enables WAN-wide browse list collation |
| `samba_global_include` | - | Samba-compatible configuration file with options to be loaded to [global] section (see below) |
| `samba_guest_account` | - | Guest account for unknown users |
Expand Down
1 change: 1 addition & 0 deletions roles/server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ samba_manage_directories: true
samba_shares: []
samba_users: []

samba_enable_netbios: 'yes'
samba_wins_support: 'yes'
samba_local_master: 'yes'
samba_domain_master: 'yes'
Expand Down
11 changes: 8 additions & 3 deletions roles/server/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
- name: Restart Samba services
- name: Restart SMB service
ansible.builtin.service:
name: "{{ item }}"
name: "{{ smb_service }}"
state: restarted
loop: "{{ samba_services }}"

- name: Restart NMB service
ansible.builtin.service:
name: "{{ nmb_service }}"
state: restarted
when: samba_enable_netbios | bool
28 changes: 20 additions & 8 deletions roles/server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
validate: 'testparm -s %s'
mode: '0644'
notify:
- Restart Samba services
- Restart SMB service
- Restart NMB service
tags: samba

- name: Install global include file
Expand All @@ -95,7 +96,8 @@
mode: '0644'
when: samba_global_include is defined and samba_global_include
notify:
- Restart Samba services
- Restart SMB service
- Restart NMB service
tags: samba

- name: Install home include file
Expand All @@ -106,7 +108,8 @@
mode: '0644'
when: samba_homes_include is defined and samba_homes_include
notify:
- Restart Samba services
- Restart SMB service
- Restart NMB service
tags: samba

- name: Install share specific include files
Expand All @@ -120,7 +123,8 @@
( item.include_file is defined and item.include_file )
loop: "{{ samba_shares }}"
notify:
- Restart Samba services
- Restart SMB service
- Restart NMB service
tags: samba

- name: Create username map file if needed
Expand All @@ -129,18 +133,26 @@
src: smbusers.j2
mode: '0644'
notify:
- Restart Samba services
- Restart SMB service
- Restart NMB service
when: samba_username_map is defined and samba_username_map
tags: samba

- name: Start Samba service(s)
- name: Start SMB service
ansible.builtin.service:
name: "{{ item }}"
name: "{{ smb_service }}"
state: started
enabled: true
loop: "{{ samba_services }}"
tags: samba

- name: Start NMB service
ansible.builtin.service:
name: "{{ nmb_service }}"
state: started
enabled: true
tags: samba
when: samba_enable_netbios | bool

- name: Create Samba users if they don't exist yet
ansible.builtin.shell: >
set -o nounset -o pipefail -o errexit &&
Expand Down
5 changes: 4 additions & 1 deletion roles/server/templates/smb.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@
interfaces = 127.0.0.1 {{ samba_interfaces | join(' ') }}

{% endif %}
# Name resolution: make sure \\NETBIOS_NAME\ works
# Name resolution
{% if not samba_enable_netbios | bool %}
disable netbios = yes
{% endif %}
wins support = {{ samba_wins_support | ternary('yes', 'no') }}
local master = {{ samba_local_master | ternary('yes', 'no') }}
domain master = {{ samba_domain_master | ternary('yes', 'no') }}
Expand Down
5 changes: 2 additions & 3 deletions roles/server/vars/os_Archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ samba_configuration_dir: /etc/samba
samba_configuration: "{{ samba_configuration_dir }}/smb.conf"
samba_username_map_file: "{{ samba_configuration_dir }}/smbusers"

samba_services:
- smb
- nmb
smb_service: smb
nmb_service: nmb

samba_www_documentroot: /var/www
5 changes: 2 additions & 3 deletions roles/server/vars/os_Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ samba_configuration_dir: /etc/samba
samba_configuration: "{{ samba_configuration_dir }}/smb.conf"
samba_username_map_file: "{{ samba_configuration_dir }}/smbusers"

samba_services:
- smbd
- nmbd
smb_service: smbd
nmb_service: nmbd

samba_www_documentroot: /var/www
5 changes: 2 additions & 3 deletions roles/server/vars/os_RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ samba_configuration_dir: /etc/samba
samba_configuration: "{{ samba_configuration_dir }}/smb.conf"
samba_username_map_file: "{{ samba_configuration_dir }}/smbusers"

samba_services:
- smb
- nmb
smb_service: smb
nmb_service: nmb

samba_www_documentroot: /var/www/html

0 comments on commit 5fc7eaa

Please sign in to comment.