|
|
|
|
|
|
|
|
{%- from tplroot ~ "/map.jinja" import salt_settings with context %} |
|
|
{%- from tplroot ~ "/map.jinja" import salt_settings with context %} |
|
|
{%- from tplroot ~ "/libtofs.jinja" import files_switch 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' %} |
|
|
download-salt-minion: |
|
|
download-salt-minion: |
|
|
|
|
|
{% 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 #} |
|
|
file.managed: |
|
|
file.managed: |
|
|
- name: '/tmp/salt.pkg' |
|
|
- name: '/tmp/salt.pkg' |
|
|
- source: {{ salt_settings.salt_minion_pkg_source }} |
|
|
- 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 }} |
|
|
- source_hash: {{ salt_settings.salt_minion_pkg_hash }} |
|
|
{% else %} |
|
|
{% else %} |
|
|
- skip_verify: True |
|
|
- skip_verify: True |
|
|
|
|
|
|
|
|
- group: wheel |
|
|
- group: wheel |
|
|
- mode: 0644 |
|
|
- mode: 0644 |
|
|
- unless: |
|
|
- 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: |
|
|
- require_in: |
|
|
- macpackage: salt-minion |
|
|
- macpackage: salt-minion |
|
|
|
|
|
{%- elif "workaround https://github.com/saltstack/salt/issues/49348" %} |
|
|
|
|
|
cmd.run: |
|
|
|
|
|
- name: /usr/local/bin/brew install {{ salt_settings.salt_minion }} |
|
|
|
|
|
- onlyif: test -x /usr/local/bin/brew |
|
|
|
|
|
- runas: {{ salt_settings.rootuser }} |
|
|
|
|
|
{%- endif %} |
|
|
{% endif %} |
|
|
{% endif %} |
|
|
|
|
|
|
|
|
salt-minion: |
|
|
salt-minion: |
|
|
{% if salt_settings.install_packages %} |
|
|
{% 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: |
|
|
macpackage.installed: |
|
|
- name: '/tmp/salt.pkg' |
|
|
- name: '/tmp/salt.pkg' |
|
|
- target: / |
|
|
- target: / |
|
|
{# macpackage.installed behaves weirdly with version_check; version_check detects difference but fails to actually complete install. #} |
|
|
{# macpackage.installed behaves weirdly with version_check; version_check detects difference but fails to actually complete install. #} |
|
|
{# use force == True as workaround #} |
|
|
{# use force == True as workaround #} |
|
|
- force: True |
|
|
- 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: |
|
|
- require_in: |
|
|
- service: salt-minion |
|
|
- service: salt-minion |
|
|
{%- else %} |
|
|
|
|
|
|
|
|
- onchanges_in: |
|
|
|
|
|
- cmd: remove-macpackage-salt |
|
|
|
|
|
{%- elif grains.os != 'MacOS' and "workaround https://github.com/saltstack/salt/issues/49348" %} |
|
|
pkg.installed: |
|
|
pkg.installed: |
|
|
- name: {{ salt_settings.salt_minion }} |
|
|
- name: {{ salt_settings.salt_minion }} |
|
|
{%- if salt_settings.version is defined %} |
|
|
|
|
|
|
|
|
{%- if salt_settings.version %} |
|
|
- version: {{ salt_settings.version }} |
|
|
- version: {{ salt_settings.version }} |
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
- require_in: |
|
|
- require_in: |
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
- onchanges: |
|
|
- onchanges: |
|
|
{%- if salt_settings.install_packages %} |
|
|
{%- if salt_settings.install_packages %} |
|
|
{%- if grains.os == 'MacOS' %} |
|
|
|
|
|
|
|
|
{%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %} |
|
|
- macpackage: salt-minion |
|
|
- macpackage: salt-minion |
|
|
|
|
|
{%- elif grains.os == 'MacOS' %} |
|
|
|
|
|
- cmd: download-salt-minion |
|
|
{%- else %} |
|
|
{%- else %} |
|
|
- pkg: salt-minion |
|
|
- pkg: salt-minion |
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
- pkg: at |
|
|
- pkg: at |
|
|
- onchanges: |
|
|
- onchanges: |
|
|
{%- if salt_settings.install_packages %} |
|
|
{%- if salt_settings.install_packages %} |
|
|
{%- if grains.os == 'MacOS' %} |
|
|
|
|
|
|
|
|
{%- if grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source %} |
|
|
- macpackage: salt-minion |
|
|
- macpackage: salt-minion |
|
|
{%- else %} |
|
|
|
|
|
|
|
|
{%- elif grains.os == 'MacOS' %} |
|
|
|
|
|
- cmd: download-salt-minion |
|
|
|
|
|
{%- else %} |
|
|
- pkg: salt-minion |
|
|
- pkg: salt-minion |
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
- file: salt-minion |
|
|
- file: salt-minion |
|
|
- file: remove-old-minion-conf-file |
|
|
- file: remove-old-minion-conf-file |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% if grains.os == 'MacOS' %} |
|
|
{% if grains.os == 'MacOS' %} |
|
|
remove-macpackage-salt: |
|
|
remove-macpackage-salt: |
|
|
cmd.run: |
|
|
|
|
|
- name: 'rm -f /tmp/salt.pkg' |
|
|
|
|
|
- onchanges: |
|
|
|
|
|
- macpackage: salt-minion |
|
|
|
|
|
|
|
|
file.absent: |
|
|
|
|
|
- name: /tmp/salt.pkg |
|
|
|
|
|
- force: True |
|
|
{% endif %} |
|
|
{% endif %} |