<commit_before>{% set PAYARA_INSTALL_DIR='/opt/payara' %}
{% set PAYARA_VERSION='172.16.31.10.1' %}
{% set PAYARA_ARTIFACT='payara-4.1.1.171.1.zip' %}
{% set ASADMIN='/opt/payara/bin/asadmin' %}
{% set ADMIN_PWD='/<PASSWORD>' %}
{% set TMP_ADMIN_PWD='/<PASSWORD>' %}

download-payara:
  cmd.run:
    - name: curl -o /opt/{{ PAYARA_ARTIFACT }} -L https://search.maven.org/remotecontent?filepath=fish/payara/distributions/payara/{{ PAYARA_VERSION }}/{{ PAYARA_ARTIFACT }}
    - creates: /opt/{{ PAYARA_ARTIFACT }}

install-systemctl-unitfile:
   file.managed:
    - name: /usr/lib/systemd/system/payara.service
    - source: salt://files/payara/payara.service

# If there is a new Payara zip file:
#  stop Payara
#  remove old installation
#  extract new zip file and symlink it
payara-installed:
  service.dead:
    - name: payara
    - onchanges:
      - download-payara
  cmd.run:
    - name: rm -rf {{ PAYARA_INSTALL_DIR }}
    - onchanges:
      - download-payara
  archive.extracted:
    - name: /opt
    - source: /opt/{{ PAYARA_ARTIFACT }}
    - archive_format: zip
    - if_missing: {{ PAYARA_INSTALL_DIR }}
  file.rename:
    - source: /opt/payara41
    - name: /opt/payara-{{ PAYARA_VERSION }}

{{ PAYARA_INSTALL_DIR }}:
  file.symlink:
    - target: /opt/payara41

payara-running:
  service.running:
    - name: payara
    - require: 
       - payara-installed<commit_msg>rename fixed<commit_after>{% set PAYARA_INSTALL_DIR='/opt/payara' %}
{% set PAYARA_VERSION='4.1.1.171.1' %}
{% set PAYARA_ARTIFACT='payara-4.1.1.171.1.zip' %}
{% set ASADMIN='/opt/payara/bin/asadmin' %}
{% set ADMIN_PWD='/<PASSWORD>' %}
{% set TMP_ADMIN_PWD='/<PASSWORD>' %}

download-payara:
  cmd.run:
    - name: curl -o /opt/{{ PAYARA_ARTIFACT }} -L https://search.maven.org/remotecontent?filepath=fish/payara/distributions/payara/{{ PAYARA_VERSION }}/{{ PAYARA_ARTIFACT }}
    - creates: /opt/{{ PAYARA_ARTIFACT }}

install-systemctl-unitfile:
   file.managed:
    - name: /usr/lib/systemd/system/payara.service
    - source: salt://files/payara/payara.service

# If there is a new Payara zip file:
#  stop Payara
#  remove old installation
#  extract new zip file and rename extracted directory sensibly
payara-installed:
  service.dead:
    - name: payara
    - onchanges:
      - download-payara
  cmd.run:
    - name: rm -rf {{ PAYARA_INSTALL_DIR }}
    - onchanges:
      - download-payara
  archive.extracted:
    - name: /opt
    - source: /opt/{{ PAYARA_ARTIFACT }}
    - archive_format: zip
    - if_missing: {{ PAYARA_INSTALL_DIR }}
  file.rename:
    - source: /opt/payara41
    - name: /opt/payara-{{ PAYARA_VERSION }}

{{ PAYARA_INSTALL_DIR }}:
  file.symlink:
    - target: /opt/payara-{{ PAYARA_VERSION }}

payara-running:
  service.running:
    - name: payara
    - require: 
       - payara-installed
{'fraction_non_alphanumeric': 0.155848787446505, 'fraction_numerical': 0.013195435092724679, 'mean_word_length': 3.0476190476190474, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '883965', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1064, 'n_words': 187}