<commit_before>include:
    - users


samba:
    pkg.installed:
        - name: samba

    file.managed:
        - name: /etc/samba/smb.conf
        - source: salt://samba/smb.conf
        - template: jinja
        - context:
            global:
                security: user
                disable netbios: "yes"
                smb ports: 445
                load printers: "no"
                unix extensions: "no"
                printing: bsd
                printcap name: /dev/null
            sections:
                {% for username, values in pillar.get('users', {}).items() %}
                {% set samba = values.get('samba') %}
                {% if samba %}
                {{ username }}:
                    public: {{ samba.get('public', 'no') }}
                    writable: {{ samba.get('writable', 'yes') }}
                    read only: {{ samba.get('read only', 'no') }}
                    valid users: {{ ' '.join(samba.get('valid users', [username])) }}
                    path: /home/{{ username }}/{{ samba.directory }}
                {% endif %}
                {% endfor %}

        - require:
            - pkg: samba

    service.running:
        - name: smbd
        - require:
            - pkg: samba
        - watch:
            - file: samba


{% for username, data in pillar.get('users', {}).items() %}

{% set samba_config = data.get('samba', {}) %}
{% if samba_config %}<commit_msg>Load samba config from dedicated pillar<commit_after>include:
    - users


samba:
    pkg.installed:
        - name: samba

    file.managed:
        - name: /etc/samba/smb.conf
        - source: salt://samba/smb.conf
        - template: jinja
        - context:
            global:
                security: user
                disable netbios: "yes"
                smb ports: 445
                load printers: "no"
                unix extensions: "no"
                printing: bsd
                printcap name: /dev/null
            {% set sections = salt['pillar.get']('samba:sections', {}) %}
            {% if sections %}
            sections:
                {% for section_name, config in sections.items() %}
                {{ section_name }}:
                    {% for key, val in config.items() %}
                    {{ key }}: {{ val }}
                    {% endfor %}
                {% endfor %}
            {% endif %}

        - require:
            - pkg: samba

    service.running:
        - name: smbd
        - require:
            - pkg: samba
        - watch:
            - file: samba


{% for username, data in pillar.get('users', {}).items() %}

{% set samba_config = data.get('samba', {}) %}
{% if samba_config %}
{'fraction_non_alphanumeric': 0.13699141470698023, 'fraction_numerical': 0.0022396416573348264, 'mean_word_length': 1.2112211221122111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2534811', 'n_tokens_mistral': 822, 'n_tokens_neox': 725, 'n_words': 176}