From 03a1920252e7e020c13ea694bd4478162a7dd00c Mon Sep 17 00:00:00 2001 From: Bert Van Vreckem Date: Sat, 22 Jun 2019 17:16:09 +0200 Subject: [PATCH] Fix #37 by removing inconsistencies in variable naming of `samba_homes_include` --- README.md | 64 +++++++++++++++++++++---------------------- tasks/main.yml | 11 +++++--- templates/smb.conf.j2 | 4 +-- 3 files changed, 41 insertions(+), 38 deletions(-) mode change 100755 => 100644 templates/smb.conf.j2 diff --git a/README.md b/README.md index 44bf1d5..3c8b2d5 100644 --- a/README.md +++ b/README.md @@ -31,38 +31,38 @@ No specific requirements ## Role Variables -| Variable | Default | Comments | -| :--- | :--- | :--- | -| `samba_apple_extensions` | no | When yes, enables support for Apple specific SMB extensions. Required for Time Machine support to work (see below) | +| Variable | Default | Comments | +| :--- | :--- | :--- | +| `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_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 | -| `samba_home_include` | - | Samba-compatible configuration file with options to be loaded to [home] section (see below) | -| `samba_interfaces` | [] | List of network interfaces used for browsing, name registration, etc. | -| `samba_load_homes` | false | When true, user home directories are accessible. | -| `samba_load_printers` | false | When true, printers attached to the host are shared | -| `samba_local_master` | true | When true, nmbd will try & become local master of the subnet | -| `samba_log` | - | Set the log file. If left undefined, logging is done through syslog. | -| `samba_log_size` | 5000 | Set the maximum size of the log file. | -| `samba_log_level` | 0 | Set Samba log level, 0 is least verbose and 10 is a flood of debug output. | -| `samba_map_to_guest` | `bad user` | Behaviour when unregistered users access the shares. | -| `samba_mitigate_cve_2017_7494` | true | CVE-2017-7494 mitigation breaks some clients, such as macOS High Sierra. | -| `samba_netbios_name` | `{{ ansible_hostname }}` | The NetBIOS name of this server. | -| `samba_passdb_backend` | `tdbsam` | Password database backend. | -| `samba_preferred_master` | true | When true, indicates nmbd is a preferred master browser for workgroup | -| `samba_realm` | - | Realm domain name | -| `samba_printer_type` | cups | value for the global option `printing` and `printcap name` | -| `samba_security` | `user` | Samba security setting | -| `samba_server_max_protocol` | - | Specify a maximum protocol version offered by the server. | -| `samba_server_min_protocol` | - | Specify a minimum protocol version offered by the server. | -| `samba_server_string` | `fileserver %m` | Comment string for the server. | -| `samba_shares_root` | `/srv/shares` | Directories for the shares are created under this directory. | -| `samba_shares` | [] | List of dicts containing share definitions. See below for details. | -| `samba_users` | [] | List of dicts defining users that can access shares. | -| `samba_wins_support` | true | When true, Samba will act as a WINS server | -| `samba_workgroup` | `WORKGROUP` | Name of the server workgroup. | +| `samba_cups_server` | localhost:631 | Value for the global option `cups server` (only needed when `samba_printer_type` is "cups") | +| `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 | +| `samba_homes_include` | - | Samba-compatible configuration file with options to be loaded to [homes] section (see below) | +| `samba_interfaces` | [] | List of network interfaces used for browsing, name registration, etc. | +| `samba_load_homes` | false | When true, user home directories are accessible. | +| `samba_load_printers` | false | When true, printers attached to the host are shared | +| `samba_local_master` | true | When true, nmbd will try & become local master of the subnet | +| `samba_log` | - | Set the log file. If left undefined, logging is done through syslog. | +| `samba_log_size` | 5000 | Set the maximum size of the log file. | +| `samba_log_level` | 0 | Set Samba log level, 0 is least verbose and 10 is a flood of debug output. | +| `samba_map_to_guest` | `bad user` | Behaviour when unregistered users access the shares. | +| `samba_mitigate_cve_2017_7494` | true | CVE-2017-7494 mitigation breaks some clients, such as macOS High Sierra. | +| `samba_netbios_name` | `{{ ansible_hostname }}` | The NetBIOS name of this server. | +| `samba_passdb_backend` | `tdbsam` | Password database backend. | +| `samba_preferred_master` | true | When true, indicates nmbd is a preferred master browser for workgroup | +| `samba_realm` | - | Realm domain name | +| `samba_printer_type` | cups | value for the global option `printing` and `printcap name` | +| `samba_security` | `user` | Samba security setting | +| `samba_server_max_protocol` | - | Specify a maximum protocol version offered by the server. | +| `samba_server_min_protocol` | - | Specify a minimum protocol version offered by the server. | +| `samba_server_string` | `fileserver %m` | Comment string for the server. | +| `samba_shares_root` | `/srv/shares` | Directories for the shares are created under this directory. | +| `samba_shares` | [] | List of dicts containing share definitions. See below for details. | +| `samba_users` | [] | List of dicts defining users that can access shares. | +| `samba_wins_support` | true | When true, Samba will act as a WINS server | +| `samba_workgroup` | `WORKGROUP` | Name of the server workgroup. | ### Defining users @@ -174,7 +174,7 @@ The values for `valid_users` and `write_list` should be a comma separated list o ## Adding arbitrary configuration files -You can add settings that are not supported by this role out-of-the-box through custom configuration files that will be included from the main configuration file. There are three types of include files: for the global section, for the homes section, and for individual shares. Put your custom configuration files in a subdirectory `templates`, relative to your master playbook location. Then, specify them in the variables `samba_global_include`, `samba_home_include`, or `include_file` in the `samba_shares` definition. +You can add settings that are not supported by this role out-of-the-box through custom configuration files that will be included from the main configuration file. There are three types of include files: for the global section, for the homes section, and for individual shares. Put your custom configuration files in a subdirectory `templates`, relative to your master playbook location. Then, specify them in the variables `samba_global_include`, `samba_homes_include`, or `include_file` in the `samba_shares` definition. Your custom configuration files are considered to be Jinja templates, so you can use Ansible variables inside them. The configuration files will be validated to ensure they are syntactically correct. diff --git a/tasks/main.yml b/tasks/main.yml index cf0a26c..1fbccc6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -85,7 +85,7 @@ notify: - Restart Samba services tags: samba - + - name: Install global include file template: src: "{{ samba_global_include }}" @@ -94,8 +94,9 @@ when: samba_global_include is defined notify: - Restart Samba services - -- name: Install homes include file + tags: samba + +- name: Install home include file template: src: "{{ samba_homes_include }}" dest: "{{ samba_configuration_dir }}" @@ -103,6 +104,7 @@ when: samba_homes_include is defined notify: - Restart Samba services + tags: samba - name: Install share specific include files template: @@ -113,6 +115,7 @@ notify: - Restart Samba services with_items: "{{ samba_shares }}" + tags: samba - name: Create username map file if needed template: @@ -120,8 +123,8 @@ src: smbusers.j2 notify: - Restart Samba services - tags: samba when: samba_username_map is defined + tags: samba - name: Start Samba service(s) service: diff --git a/templates/smb.conf.j2 b/templates/smb.conf.j2 old mode 100755 new mode 100644 index 39a14c0..5b6bc7a --- a/templates/smb.conf.j2 +++ b/templates/smb.conf.j2 @@ -90,8 +90,8 @@ writable = yes {% endif %} -{% if samba_home_include is defined %} - include = {{ samba_configuration_dir }}/{{ samba_home_include }} +{% if samba_homes_include is defined %} + include = {{ samba_configuration_dir }}/{{ samba_homes_include }} {% endif %} {% if samba_shares|length > 0 %}