<commit_before>{% from 'macros.sls' import user, group with context %}

# Get the latest and current version.
{% set latest_version = salt['cmd.run']('bash -c \'curl -s "https://www.packer.io/downloads.html" | grep darwin_amd64.zip | sed "s/.*packer_//;s/_darwin_amd64.*//"\'') %}
{% set current_version = salt['cmd.run']('bash -c \'packer --version 2>&1 | cut -d" " -f2\'') %}

# Set a variable to indicate if plugins should be installed.
{% set install_plugins = false %}

{% if latest_version != current_version %}

Install Packer:
    archive.extracted:
        - name: {{ salt['environ.get']('HOME') }}/bin
        - enforce_toplevel: False
{% if grains['kernel'] == 'Darwin' %}
        - source: https://releases.hashicorp.com/packer/{{ latest_version }}/packer_{{ latest_version }}_darwin_amd64.zip
{% elif grains['kernel'] == 'Linux' %}
        - source: https://releases.hashicorp.com/packer/{{ latest_version }}/packer_{{ latest_version }}_linux_amd64.zip
{% endif %}
        {{ user() }}
        {{ group() }}
        - skip_verify: True
        - if_missing: {{ salt['environ.get']('HOME') }}/bin/packer

{% endif %}<commit_msg>add packer fixes for centos<commit_after>{% from 'macros.sls' import user, group with context %}

# Get the latest and current version.
{% set latest_version = salt['cmd.run']('bash -c \'curl -s "https://www.packer.io/downloads.html" | grep darwin_amd64.zip | sed "s/.*packer_//;s/_darwin_amd64.*//"\'') %}
{% if grains['os'] == 'CentOS' %}
{% set current_version = salt['cmd.run']('bash -c \'packer.io --version 2>&1 | cut -d" " -f2\'') %}
{% else %}
{% set current_version = salt['cmd.run']('bash -c \'packer --version 2>&1 | cut -d" " -f2\'') %}
{% endif %}

# Set a variable to indicate if plugins should be installed.
{% set install_plugins = false %}

{% if latest_version != current_version %}

{% if grains['os'] == 'CentOS' %}

Install Packer:
    archive.extracted:
        - name: {{ salt['environ.get']('HOME') }}/bin
        - enforce_toplevel: False
        - source: https://releases.hashicorp.com/packer/{{ latest_version }}/packer_{{ latest_version }}_linux_amd64.zip
        {{ user() }}
        {{ group() }}
        - skip_verify: True
        - if_missing: {{ salt['environ.get']('HOME') }}/bin/packer.io

Rename packer to packer.io:
    cmd.run:
        - name: mv {{ salt['environ.get']('HOME') }}/bin/packer {{ salt['environ.get']('HOME') }}/bin/packer.io
        - onlyif: test -f {{ salt['environ.get']('HOME') }}/bin/packer

{% else %}

Install Packer:
    archive.extracted:
        - name: {{ salt['environ.get']('HOME') }}/bin
        - enforce_toplevel: False
{% if grains['kernel'] == 'Darwin' %}
        - source: https://releases.hashicorp.com/packer/{{ latest_version }}/packer_{{ latest_version }}_darwin_amd64.zip
{% elif grains['kernel'] == 'Linux' %}
        - source: https://releases.hashicorp.com/packer/{{ latest_version }}/packer_{{ latest_version }}_linux_amd64.zip
{% endif %}
        {{ user() }}
        {{ group() }}
        - skip_verify: True
        - if_missing: {{ salt['environ.get']('HOME') }}/bin/packer

{% endif %}

{% endif %}
{'fraction_non_alphanumeric': 0.20409468969929623, 'fraction_numerical': 0.008637236084452975, 'mean_word_length': 3.2142857142857144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 7, 'lorem ipsum': 0, 'www.': 2, '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': '6397169', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1061, 'n_words': 233}