<commit_before>#

###############################################################################
# <<<
{% if grains['os_platform_type'].startswith('rhel7') or grains['os_platform_type'].startswith('fc') %}

include:
    - bootstrap

{% set account_conf = pillar['system_accounts'][ pillar['system_hosts'][ grains['id'] ]['primary_user'] ] %}
{% set user_home_dir = account_conf['posix_user_home_dir'] %}
{% set bootstrap_files_dir = pillar['system_features']['static_bootstrap_configuration']['bootstrap_files_dir'] %}
{% set bootstrap_dir = user_home_dir + '/' + bootstrap_files_dir %}

# Note that `load_bootstrap_target_envs` is only available when Salt
# configuration (for either master or minion) contains necessary configuration.
# In addition to that, the limit on which target environments are generated
# is also placed by `enable_bootstrap_target_envs` key in pillar.
# See:
#   * docs/configs/common/this_system_keys/load_bootstrap_target_envs/readme.md
#   * docs/pillars/{# project_name #}/system_features/source_bootstrap_configuration/enable_bootstrap_target_envs/readme.md
{% set load_bootstrap_target_envs = salt['config.get']('this_system_keys:load_bootstrap_target_envs') %}
{% set project_name = salt['config.get']('this_system_keys:project_name') %}

# Download file for pretty conversion.
pretty_yaml2json_script:
    file.managed:
        - name: '{{ bootstrap_dir }}/pretty_yaml2json.py'
        - source: 'salt://bootstrap/generate_content/pretty_yaml2json.py'
        - makedirs: True
        - user: '{{ account_conf['username'] }}'
        - group: '{{ account_conf['primary_group'] }}'
        - mode: 755

{% for profile_name in load_bootstrap_target_envs.keys() %} # profile_name

{% if profile_name in pillar['system_features']['source_bootstrap_configuration']['enable_bootstrap_target_envs'].keys() %} # enabled profile_name

# Define root for pillar data.
# Note that currently selected profile_name for currently selected project
# is not loaded under `bootstrap_target_envs` pillar key.
# See:
#   * docs/configs/bootstrap/this_system_keys/load_bootstrap_target_envs/readme.md
{% set target_env_pillar = pillar['bootstrap_target_envs'][project_name + '.' + profile_name] %}

{% set target_contents_dir = bootstrap_dir + '/targets/' + project_name + '/' + profile_name %}

# Provide generated target configuration files.
# NOTE: The configuration is repeated for
#       each project_name, each profile_name, each host id even though differences
#       sometimes matter only for specific project_name.
{% for selected_host_name in target_env_pillar['system_hosts'].keys() %} # selected_host_name

{% set selected_host = target_env_pillar['system_hosts'][selected_host_name] %}

{% set requisite_config_file_id = 'target_env_conf_file_' + project_name + '_' + profile_name + '_' + selected_host_name %}
{% set requisite_config_file_path = target_contents_dir + '/conf/' + project_name + '/' + profile_name + '/' + selected_host_name + '.py' %}

{{ requisite_config_file_id }}:
    file.managed:
        - name: '{{ requisite_config_file_path }}'
        - source: 'salt://bootstrap/generate_content/bootstrap.conf.sls'
        - context:
            os_platform: '{{ selected_host['os_platform'] }}'
            project_name: '{{ project_name }}'
            profile_name: '{{ profile_name }}'
            system_host_id: '{{ selected_host_name }}'
        - makedirs: True
        - template: jinja
        - mode: 644
        {% set account_conf = pillar['system_accounts'][ pillar['system_hosts'][ grains['id'] ]['primary_user'] ] %}
        - user: '{{ account_conf['username'] }}'
        - group: '{{ account_conf['primary_group'] }}'
        - require:<commit_msg>Clean up bootstrap destination dir before start<commit_after>#

###############################################################################
# <<<
{% if grains['os_platform_type'].startswith('rhel7') or grains['os_platform_type'].startswith('fc') %}

include:
    - bootstrap

{% set account_conf = pillar['system_accounts'][ pillar['system_hosts'][ grains['id'] ]['primary_user'] ] %}
{% set user_home_dir = account_conf['posix_user_home_dir'] %}
{% set bootstrap_files_dir = pillar['system_features']['static_bootstrap_configuration']['bootstrap_files_dir'] %}
{% set bootstrap_dir = user_home_dir + '/' + bootstrap_files_dir %}

# Note that `load_bootstrap_target_envs` is only available when Salt
# configuration (for either master or minion) contains necessary configuration.
# In addition to that, the limit on which target environments are generated
# is also placed by `enable_bootstrap_target_envs` key in pillar.
# See:
#   * docs/configs/common/this_system_keys/load_bootstrap_target_envs/readme.md
#   * docs/pillars/{# project_name #}/system_features/source_bootstrap_configuration/enable_bootstrap_target_envs/readme.md
{% set load_bootstrap_target_envs = salt['config.get']('this_system_keys:load_bootstrap_target_envs') %}
{% set project_name = salt['config.get']('this_system_keys:project_name') %}

# Download file for pretty conversion.
pretty_yaml2json_script:
    file.managed:
        - name: '{{ bootstrap_dir }}/pretty_yaml2json.py'
        - source: 'salt://bootstrap/generate_content/pretty_yaml2json.py'
        - makedirs: True
        - user: '{{ account_conf['username'] }}'
        - group: '{{ account_conf['primary_group'] }}'
        - mode: 755

{% for profile_name in load_bootstrap_target_envs.keys() %} # profile_name

{% if profile_name in pillar['system_features']['source_bootstrap_configuration']['enable_bootstrap_target_envs'].keys() %} # enabled profile_name

# Define root for pillar data.
# Note that currently selected profile_name for currently selected project
# is not loaded under `bootstrap_target_envs` pillar key.
# See:
#   * docs/configs/bootstrap/this_system_keys/load_bootstrap_target_envs/readme.md
{% set target_env_pillar = pillar['bootstrap_target_envs'][project_name + '.' + profile_name] %}

{% set target_contents_dir = bootstrap_dir + '/targets/' + project_name + '/' + profile_name %}

# Provide generated target configuration files.
# NOTE: The configuration is repeated for
#       each project_name, each profile_name, each host id even though differences
#       sometimes matter only for specific project_name.
{% for selected_host_name in target_env_pillar['system_hosts'].keys() %} # selected_host_name

{% set selected_host = target_env_pillar['system_hosts'][selected_host_name] %}

{% set requisite_config_file_id = 'target_env_conf_file_' + project_name + '_' + profile_name + '_' + selected_host_name %}
{% set requisite_config_file_path = target_contents_dir + '/conf/' + project_name + '/' + profile_name + '/' + selected_host_name + '.py' %}

cleanup_{{ target_contents_dir }}_{{ selected_host_name }}:
    file.absent:
        - name: '{{ target_contents_dir }}/{{ selected_host_name }}'

{{ requisite_config_file_id }}:
    file.managed:
        - name: '{{ requisite_config_file_path }}'
        - source: 'salt://bootstrap/generate_content/bootstrap.conf.sls'
        - context:
            os_platform: '{{ selected_host['os_platform'] }}'
            project_name: '{{ project_name }}'
            profile_name: '{{ profile_name }}'
            system_host_id: '{{ selected_host_name }}'
        - makedirs: True
        - template: jinja
        - mode: 644
        {% set account_conf = pillar['system_accounts'][ pillar['system_hosts'][ grains['id'] ]['primary_user'] ] %}
        - user: '{{ account_conf['username'] }}'
        - group: '{{ account_conf['primary_group'] }}'
        - require:
{'fraction_non_alphanumeric': 0.15001973943939992, 'fraction_numerical': 0.0026319252533228057, 'mean_word_length': 4.740181268882175, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4111636', 'n_tokens_mistral': 2393, 'n_tokens_neox': 2240, 'n_words': 444}