<commit_before>{% from 'nginx/map.jinja' import nginx with context %}
{% set install_from_source = nginx['install_from_source'] %}


nginx-systemuser:
    user.present:
        - name: nginx
        - fullname: nginx worker
        - system: True
        - createhome: False
        - shell: /usr/sbin/nologin
        - groups:
            - shadow
        - optional_groups:
            - phpworker


include:
    - .pillar_check
{% if install_from_source %}
    - nginx.source
{% else %}
    - nginx.package
{% endif %}
{% if nginx.get('dump_to_s3', False) %}
    - s3-uploader
{% endif %}


# Install ca-certificates to let nginx verify upstream certificates
nginx-ca-certificates:
    test.succeed_without_changes:
        - name: ca-certificates

    cmd.run:
        - name: existing_digest=$(sha1sum /etc/nginx/ssl/all-certs.pem 2>/dev/null
                                  | cut -d" " -f1 || echo 'no existing file');
                new_digest=$(find /etc/ssl/certs/ -type f
                             | sort
                             | xargs cat
                             | sha1sum
                             | cut -d" " -f1);
                if [ "$new_digest" != "$existing_digest" ]; then
                    find /etc/ssl/certs/ -type f
                    | sort
                    | xargs cat
                    > /etc/nginx/ssl/all-certs.pem;
                    echo "changed=yes";
                fi
        - stateful: True
        - require:
            - file: nginx-conf
        - watch_in:
            - service: nginx


nginx-conf:
    file.managed:
        - name: /etc/nginx/nginx.conf
        - source: salt://nginx/nginx.conf
        - template: jinja
        - mode: 640
        - user: root
        - group: nginx
        - context:
            keepalive_timeout: {{ nginx.keepalive_timeout }}
            log_formats:
                {% for log_format, format in nginx.log_formats.items() %}
                {{ log_format }}: '{{ format }}'
                {% endfor %}
            log_files:
                {% for log_file, format in nginx.log_files.items() %}<commit_msg>Make nginx.conf world readable<commit_after>{% from 'nginx/map.jinja' import nginx with context %}
{% set install_from_source = nginx['install_from_source'] %}


nginx-systemuser:
    user.present:
        - name: nginx
        - fullname: nginx worker
        - system: True
        - createhome: False
        - shell: /usr/sbin/nologin
        - groups:
            - shadow
        - optional_groups:
            - phpworker


include:
    - .pillar_check
{% if install_from_source %}
    - nginx.source
{% else %}
    - nginx.package
{% endif %}
{% if nginx.get('dump_to_s3', False) %}
    - s3-uploader
{% endif %}


# Install ca-certificates to let nginx verify upstream certificates
nginx-ca-certificates:
    test.succeed_without_changes:
        - name: ca-certificates

    cmd.run:
        - name: existing_digest=$(sha1sum /etc/nginx/ssl/all-certs.pem 2>/dev/null
                                  | cut -d" " -f1 || echo 'no existing file');
                new_digest=$(find /etc/ssl/certs/ -type f
                             | sort
                             | xargs cat
                             | sha1sum
                             | cut -d" " -f1);
                if [ "$new_digest" != "$existing_digest" ]; then
                    find /etc/ssl/certs/ -type f
                    | sort
                    | xargs cat
                    > /etc/nginx/ssl/all-certs.pem;
                    echo "changed=yes";
                fi
        - stateful: True
        - require:
            - file: nginx-conf
        - watch_in:
            - service: nginx


nginx-conf:
    file.managed:
        - name: /etc/nginx/nginx.conf
        - source: salt://nginx/nginx.conf
        - template: jinja
        - mode: 644
        - user: root
        - group: nginx
        - context:
            keepalive_timeout: {{ nginx.keepalive_timeout }}
            log_formats:
                {% for log_format, format in nginx.log_formats.items() %}
                {{ log_format }}: '{{ format }}'
                {% endfor %}
            log_files:
                {% for log_file, format in nginx.log_files.items() %}
{'fraction_non_alphanumeric': 0.11398354876615746, 'fraction_numerical': 0.004700352526439483, 'mean_word_length': 1.2943396226415094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2087382', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1239, 'n_words': 263}