Skip to content

Commit

Permalink
refactor(salt-minion): incorporate pr 416
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 31, 2019
1 parent fd88b5e commit d2544a7
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions salt/minion.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
{%- 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' %}
{%- 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 #}
{#- 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'
- source: {{ salt_settings.salt_minion_pkg_source }}
{% if salt_settings.salt_minion_pkg_hash %}
{%- if salt_settings.salt_minion_pkg_hash != '' %}
- source_hash: {{ salt_settings.salt_minion_pkg_hash }}
{% else %}
{%- else %}
- skip_verify: True
{% endif %}
{%- endif %}
- user: root
- group: wheel
- mode: '0644'
Expand All @@ -23,9 +23,9 @@ download-salt-minion:
- require_in:
- macpackage: salt-minion
{%- else %}
{# homebrew package name #}
{#- homebrew package name #}
{%- do salt_settings.update({'salt_minion': 'salt'}) %}
{# workaround https://github.com/saltstack/salt/issues/49348 #}
{#- workaround https://github.com/saltstack/salt/issues/49348 #}
salt-minion-brew-workaround:
cmd.run:
- name: /usr/local/bin/brew install {{ salt_settings.salt_minion }}
Expand All @@ -35,13 +35,13 @@ salt-minion-brew-workaround:
{%- endif %}
salt-minion:
{% if salt_settings.install_packages %}
{%- if salt_settings.install_packages %}
{%- 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 #}
{#- macpackage.installed behaves weirdly with version_check; version_check detects difference but fails to actually complete install. #}
{#- use force == True as workaround #}
- force: True
- unless:
- test -n "{{ salt_settings.version }}" && /opt/salt/bin/salt-minion --version=.*{{ salt_settings.version }}.*
Expand All @@ -59,7 +59,7 @@ salt-minion:
- service: salt-minion
- runas: {{ salt_settings.rootuser }}
{%- endif %}
{% endif %}
{%- endif %}
file.recurse:
- name: {{ salt_settings.config_path }}/minion.d
{%- if salt_settings.minion_config_use_TOFS %}
Expand Down Expand Up @@ -116,8 +116,8 @@ salt-minion:
- file: remove-old-minion-conf-file
{%- else %}
{% if grains.os != 'MacOS' %}
{# MacOS has 'at' command; but there's no package to install #}
{%- if grains.os != 'MacOS' %}
{#- MacOS has 'at' command; but there's no package to install #}
at:
pkg.installed: []
{% endif %}
Expand All @@ -142,29 +142,29 @@ restart-salt-minion:
- file: remove-old-minion-conf-file
{%- endif %}
{% if 'inotify' in salt_settings.get('minion', {}).get('beacons', {}) and salt_settings.get('pyinotify', False) %}
{%- if 'inotify' in salt_settings.get('minion', {}).get('beacons', {}) and salt_settings.get('pyinotify', False) %}
salt-minion-beacon-inotify:
pkg.installed:
- name: {{ salt_settings.pyinotify }}
- require_in:
- service: salt-minion
- watch_in:
- service: salt-minion
{% endif %}
{%- endif %}
{% if salt_settings.minion_remove_config %}
{%- if salt_settings.minion_remove_config %}
remove-default-minion-conf-file:
file.absent:
- name: {{ salt_settings.config_path }}/minion
{% endif %}
{%- endif %}
# clean up old _defaults.conf file if they have it around
remove-old-minion-conf-file:
file.absent:
- name: {{ salt_settings.config_path }}/minion.d/_defaults.conf
{% if salt_settings.install_packages and grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %}
{%- 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'
{% endif %}
{%- endif %}

0 comments on commit d2544a7

Please sign in to comment.