Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration settings for generated config file #14

Merged
merged 1 commit into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
samba_config:
section_order: [global, homes, printers]
include_skeleton: no

samba_sections:
global:
workgroup: MYGROUP
Expand Down
35 changes: 24 additions & 11 deletions samba/files/smb.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
{% set samba_sections = pillar.get('samba_sections', {}) %}
#
# This file is managed by salt. Manual changes risk being overwritten.
# The contents of the original skeleton smb.conf are kept at the bottom
# as a quick reference to the default option values.
#
{%- set samba_sections = pillar.get('samba_sections', {}) %}
{%- set conf_generator_settings = pillar.get('samba_config', {}) %}

{%- for section in samba_sections.keys() %}
{%- macro config_section(section) %}
{%- set options = samba_sections.get(section, {}) -%}
[{{ section }}]
{%- for option, value in samba_sections.get(section, {}).items() %}
{%- for option, value in options.items() %}
{{ option }} = {{ value }}
{%- endfor %}
{%- endfor%}
{%- endmacro -%}

#
# This file is managed by salt. Manual changes risk being overwritten.
# If so configured, the contents of the original skeleton smb.conf are stored
# at the bottom as a quick reference to the default option values.
#
{%- set ordered_sections = conf_generator_settings.get('section_order', []) %}
{%- for k in ordered_sections %}
{{ config_section(k) }}
{%- endfor -%}
{%- for k in samba_sections.keys() %}
{%- if k not in ordered_sections %}
{{ config_section(k) }}
{%- endif %}
{%- endfor -%}

{%- if conf_generator_settings.get('include_skeleton', True) %}

# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
Expand Down Expand Up @@ -296,5 +310,4 @@
; writable = yes
; printable = no
; create mask = 0765


{%- endif %}