Skip to content

Commit

Permalink
fix(macos): fix package name for homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 31, 2019
1 parent 6a31254 commit e6939bd
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions salt/minion.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
{%- from tplroot ~ "/map.jinja" import salt_settings with context %}
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
{% if salt_settings.install_packages and grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source != '' and salt_settings.version != '' %}
{# only download IF we know where to get the pkg from and if we know what version to check the current install (if installed) against #}
{# e.g. don't download unless it appears as though we're about to try and upgrade the minion #}
{% if salt_settings.install_packages and grains.os == 'MacOS' %}
{%- if salt_settings.salt_minion_pkg_source %}
{# only download IF we know where to get the pkg from and what version to check the current install (if installed) against #}
{# e.g. don't download unless it appears as though we're about to try and upgrade the minion #}
download-salt-minion:
file.managed:
- name: '/tmp/salt.pkg'
Expand All @@ -18,23 +19,30 @@ download-salt-minion:
- group: wheel
- mode: 0644
- unless:
- '/opt/salt/bin/salt-minion --version | grep {{ salt_settings.version }}'
- test -n "{{ salt_settings.version }}" && /opt/salt/bin/salt-minion --version=.*{{ salt_settings.version }}.*
- require_in:
- macpackage: salt-minion
{% endif %}
{%- else %}
{# homebrew package name #}
{%- do salt_settings.update({'salt_minion': 'salt'}) %}
{%- endif %}
{%- endif %}
salt-minion:
{% if salt_settings.install_packages %}
{%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source != '' and salt_settings.version != '' %}
{%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %}
macpackage.installed:
- name: '/tmp/salt.pkg'
- target: /
{# macpackage.installed behaves weirdly with version_check; version_check detects difference but fails to actually complete install. #}
{# use force == True as workaround #}
- force: True
- version_check: /opt/salt/bin/salt-minion --version=.*{{ salt_settings.version }}.*
- unless:
- test -n "{{ salt_settings.version }}" && /opt/salt/bin/salt-minion --version=.*{{ salt_settings.version }}.*
- require_in:
- service: salt-minion
- onchanges_in:
- cmd: remove-macpackage-salt
{%- else %}
pkg.installed:
- name: {{ salt_settings.salt_minion }}
Expand Down Expand Up @@ -89,7 +97,7 @@ salt-minion:
{%- endif %}
- onchanges:
{%- if salt_settings.install_packages %}
{%- if grains.os == 'MacOS' %}
{%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %}
- macpackage: salt-minion
{%- else %}
- pkg: salt-minion
Expand All @@ -113,7 +121,7 @@ restart-salt-minion:
- pkg: at
- onchanges:
{%- if salt_settings.install_packages %}
{%- if grains.os == 'MacOS' %}
{%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %}
- macpackage: salt-minion
{%- else %}
- pkg: salt-minion
Expand Down Expand Up @@ -144,10 +152,8 @@ remove-old-minion-conf-file:
file.absent:
- name: {{ salt_settings.config_path }}/minion.d/_defaults.conf
{% if grains.os == 'MacOS' %}
{% if salt_settings.install_packages and grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %}
remove-macpackage-salt:
cmd.run:
- name: 'rm -f /tmp/salt.pkg'
- onchanges:
- macpackage: salt-minion
{% endif %}
{% endif %}

0 comments on commit e6939bd

Please sign in to comment.