<commit_before>{% if grains['os_family'] == 'Debian' %}
    {% set hostname_service = 'hostname' %}
{% elif grains['os_family'] == 'RedHat' %}
    {% set hostname_service = 'network' %}
{% endif %}


# Edit the appropriate hostname file
hostname_file:
  file.replace:
{% if grains['os_family'] == 'Debian' %}
    - name: /etc/hostname
    - pattern: "^.*$"
    - repl: "{{ grains['fqdn'] }}"
{% elif grains['os_family'] == 'RedHat' %}
    - name: /etc/sysconfig/network
    - pattern: "^HOSTNAME=.*$"
    - repl: "HOSTNAME={{ grains['fqdn'] }}"
{% endif %}

# Add an IP->FQDN mapping for each machine in the stack
stack_hostnames:
  file.managed:
    - user: root
    - group: root
    - mode: 644
    - name: /etc/hosts
    - template: jinja
    - source: salt://core/etc/hosts

# Set the hostname of the machine based on the FQDN defined in a grain
set_hostname:
  cmd.run:
    - user: root
    - name: "hostname {{ grains['fqdn'] }}"
    - unless: "hostname | grep {{ grains['fqdn'] }}"
    - require:
      - file: hostname_file

# Restart the apropriate service for this change to take effect
hostname-svc:
  service.running:
    - name: {{ hostname_service }}
    - watch:
      - cmd: set_hostname
      - file: stack_hostnames
      - file: hostname_file<commit_msg>Fixed hostname setting<commit_after>{% if grains['os_family'] == 'Debian' %}
    {% set hostname_service = 'hostname' %}
{% elif grains['os_family'] == 'RedHat' %}
    {% set hostname_service = 'network' %}
{% endif %}


# Edit the appropriate hostname file
hostname_file:
  file.managed:
{% if grains['os_family'] == 'Debian' %}
    - name: /etc/hostname
    - contents:
      - "{{ grains['fqdn'] }}"
{% elif grains['os_family'] == 'RedHat' %}
    - name: /etc/sysconfig/network
    - contents:
      - "NOZEROCONF=yes"
      - "NETWORKING=yes"
      - "HOSTNAME={{ grains['fqdn'] }}"
{% endif %}

# Add an IP->FQDN mapping for each machine in the stack
stack_hostnames:
  file.managed:
    - user: root
    - group: root
    - mode: 644
    - name: /etc/hosts
    - template: jinja
    - source: salt://core/etc/hosts

# Set the hostname of the machine based on the FQDN defined in a grain
set_hostname:
  cmd.run:
    - user: root
    - name: "hostname {{ grains['fqdn'] }}"
    - unless: "hostname | grep {{ grains['fqdn'] }}"
    - require:
      - file: hostname_file

# Restart the apropriate service for this change to take effect
hostname-svc:
  service.running:
    - name: {{ hostname_service }}
    - watch:
      - cmd: set_hostname
      - file: stack_hostnames
      - file: hostname_file
{'fraction_non_alphanumeric': 0.1578743211792087, 'fraction_numerical': 0.0023273855702094647, 'mean_word_length': 2.8207407407407405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2143112', 'n_tokens_mistral': 935, 'n_tokens_neox': 885, 'n_words': 226}