refactor(salt-master): move to subcomponents
Add a verifier in each sls to exclude windows platform.
This commit is contained in:
parent
ede1942d98
commit
928b1a7c29
@ -1,89 +0,0 @@
|
|||||||
{%- set tplroot = tpldir.split('/')[0] %}
|
|
||||||
{%- from tplroot ~ "/map.jinja" import salt_settings with context %}
|
|
||||||
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
|
|
||||||
|
|
||||||
{% if salt_settings.pin_version and salt_settings.version and grains.os_family|lower == 'debian' %}
|
|
||||||
include:
|
|
||||||
- .pin
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- if grains.kernel != 'Windows' %}
|
|
||||||
|
|
||||||
{%- if grains.os == 'MacOS' %}
|
|
||||||
salt-master-macos:
|
|
||||||
file.managed:
|
|
||||||
- name: /Library/LaunchDaemons/com.saltstack.salt.master.plist
|
|
||||||
- source: https://raw.githubusercontent.com/saltstack/salt/master/pkg/osx/scripts/com.saltstack.salt.master.plist
|
|
||||||
- source_hash: {{ salt_settings.salt_master_macos_plist_hash }}
|
|
||||||
- retry: {{ salt_settings.retry_options | json }}
|
|
||||||
- require_in:
|
|
||||||
- service: salt-master
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
salt-master:
|
|
||||||
{% if salt_settings.install_packages %}
|
|
||||||
pkg.installed:
|
|
||||||
- name: {{ salt_settings.salt_master }}
|
|
||||||
{%- if salt_settings.version is defined %}
|
|
||||||
- version: {{ salt_settings.version }}
|
|
||||||
{%- endif %}
|
|
||||||
{% if salt_settings.master_service_details.state != 'ignore' %}
|
|
||||||
- require_in:
|
|
||||||
- service: salt-master
|
|
||||||
- watch_in:
|
|
||||||
- service: salt-master
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
file.recurse:
|
|
||||||
- name: {{ salt_settings.config_path }}/master.d
|
|
||||||
{%- if salt_settings.master_config_use_TOFS %}
|
|
||||||
- template: ''
|
|
||||||
- source: {{ files_switch(['master.d'],
|
|
||||||
lookup='salt-master'
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
{%- else %}
|
|
||||||
- template: jinja
|
|
||||||
- source: salt://{{ tplroot }}/files/master.d
|
|
||||||
{%- endif %}
|
|
||||||
- clean: {{ salt_settings.clean_config_d_dir }}
|
|
||||||
- exclude_pat:
|
|
||||||
- _*
|
|
||||||
- raas.conf
|
|
||||||
{% if salt_settings.master_service_details.state != 'ignore' %}
|
|
||||||
service.{{ salt_settings.master_service_details.state }}:
|
|
||||||
- enable: {{ salt_settings.master_service_details.enabled }}
|
|
||||||
- name: {{ salt_settings.master_service }}
|
|
||||||
{%- if grains.os_family == 'FreeBSD' %}
|
|
||||||
- retry: {{ salt_settings.retry_options | json }}
|
|
||||||
{%- endif %}
|
|
||||||
- watch:
|
|
||||||
{%- if grains.kernel|lower == 'darwin' %}
|
|
||||||
- file: salt-master-macos
|
|
||||||
{%- else %}
|
|
||||||
- file: salt-master
|
|
||||||
{%- endif %}
|
|
||||||
- file: remove-old-master-conf-file
|
|
||||||
- order: last
|
|
||||||
{% endif %}
|
|
||||||
{% if salt_settings.master_remove_config %}
|
|
||||||
remove-default-master-conf-file:
|
|
||||||
file.absent:
|
|
||||||
- name: {{ salt_settings.config_path }}/master
|
|
||||||
- watch_in:
|
|
||||||
- service: salt-master
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# clean up old _defaults.conf file if they have it around
|
|
||||||
remove-old-master-conf-file:
|
|
||||||
file.absent:
|
|
||||||
- name: {{ salt_settings.config_path }}/master.d/_defaults.conf
|
|
||||||
|
|
||||||
{%- else %}
|
|
||||||
|
|
||||||
salt-master-install-skip:
|
|
||||||
test.show_notification:
|
|
||||||
- text: |
|
|
||||||
No salt-master state for Windows
|
|
||||||
|
|
||||||
{%- endif %}
|
|
60
salt/master/config/files.sls
Normal file
60
salt/master/config/files.sls
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split("/")[0] %}
|
||||||
|
{%- set sls_windows_excluded = tplroot ~ ".windows-excluded" %}
|
||||||
|
{%- set sls_package_install = tplroot ~ ".master.package.install" %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import salt_settings with context %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- {{ sls_windows_excluded }}
|
||||||
|
- {{ sls_package_install }}
|
||||||
|
|
||||||
|
{%- if salt_settings.master_config_use_TOFS %}
|
||||||
|
{%- set source = files_switch(["master.d"],
|
||||||
|
lookup="salt-master"
|
||||||
|
) %}
|
||||||
|
{%- set template = "" %}
|
||||||
|
{%- else %}
|
||||||
|
{%- set source = "salt://" ~ tplroot ~ "/files/master.d" %}
|
||||||
|
{%- set template = "jinja" %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
salt-master-config-files-file.recurse:
|
||||||
|
file.recurse:
|
||||||
|
- name: {{ salt_settings.config_path }}/master.d
|
||||||
|
- source: {{ source }}
|
||||||
|
- template: {{ template }}
|
||||||
|
- clean: {{ salt_settings.clean_config_d_dir }}
|
||||||
|
- exclude_pat:
|
||||||
|
- _*
|
||||||
|
- raas.conf
|
||||||
|
- require:
|
||||||
|
- sls: {{ sls_windows_excluded }}
|
||||||
|
- sls: {{ sls_package_install }}
|
||||||
|
|
||||||
|
{%- if salt_settings.master_remove_config %}
|
||||||
|
salt-master-config-files-remove-old-master-conf-file.absent:
|
||||||
|
file.absent:
|
||||||
|
- name: {{ salt_settings.config_path }}/master
|
||||||
|
- require:
|
||||||
|
- sls: {{ sls_windows_excluded }}
|
||||||
|
- sls: {{ sls_package_install }}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
# clean up old _defaults.conf file if they have it around
|
||||||
|
salt-master-config-files-remove-old-default-master-conf-file.absent:
|
||||||
|
file.absent:
|
||||||
|
- name: {{ salt_settings.config_path }}/master.d/_defaults.conf
|
||||||
|
|
||||||
|
{%- if grains.os == "MacOS" %}
|
||||||
|
salt-master-config-files-macos-LaunchDaemons-file.managed:
|
||||||
|
file.managed:
|
||||||
|
- name: /Library/LaunchDaemons/com.saltstack.salt.master.plist
|
||||||
|
- source: https://raw.githubusercontent.com/saltstack/salt/master/pkg/osx/scripts/com.saltstack.salt.master.plist
|
||||||
|
- source_hash: {{ salt_settings.salt_master_macos_plist_hash }}
|
||||||
|
- retry: {{ salt_settings.retry_options | json }}
|
||||||
|
- require:
|
||||||
|
- sls: {{ sls_package_install }}
|
||||||
|
{%- endif %}
|
5
salt/master/config/init.sls
Normal file
5
salt/master/config/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .files
|
7
salt/master/init.sls
Normal file
7
salt/master/init.sls
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .package
|
||||||
|
- .config
|
||||||
|
- .service
|
5
salt/master/package/init.sls
Normal file
5
salt/master/package/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .install
|
26
salt/master/package/install.sls
Normal file
26
salt/master/package/install.sls
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- set sls_windows_excluded = tplroot ~ '.windows-excluded' %}
|
||||||
|
{%- set sls_pin_version = tplroot ~ '.pin' %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import salt_settings with context %}
|
||||||
|
|
||||||
|
{#- `salt-master` cannot be installed on Windows machines #}
|
||||||
|
{%- set sls_dependencies = [sls_windows_excluded] %}
|
||||||
|
|
||||||
|
{%- if salt_settings.pin_version and salt_settings.version and grains.os_family|lower == 'debian' %}
|
||||||
|
{%- do sls_dependencies.append(sls_pin_version) %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
include: {{ sls_dependencies }}
|
||||||
|
|
||||||
|
{%- if salt_settings.install_packages %}
|
||||||
|
salt-master-package-install-pkg.installed:
|
||||||
|
pkg.installed:
|
||||||
|
- name: {{ salt_settings.salt_master }}
|
||||||
|
- version: {{ salt_settings.version | default('~') }}
|
||||||
|
- require:
|
||||||
|
- sls: {{ sls_windows_excluded }}
|
||||||
|
{%- endif %}
|
28
salt/master/service/init.sls
Normal file
28
salt/master/service/init.sls
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- set sls_windows_excluded = tplroot ~ ".windows-excluded" %}
|
||||||
|
{%- set sls_config_files = tplroot ~ '.master.config.files' %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import salt_settings with context %}
|
||||||
|
|
||||||
|
{%- if salt_settings.master_service_details.state != 'ignore' %}
|
||||||
|
include:
|
||||||
|
- {{ sls_windows_excluded }}
|
||||||
|
- {{ sls_config_files }}
|
||||||
|
|
||||||
|
{%- set wanted_state = salt_settings.master_service_details.state %}
|
||||||
|
{%- set retry = {
|
||||||
|
'darwin': salt_settings.retry_options | json,
|
||||||
|
}.get(grains.kernel|lower, '')
|
||||||
|
%}
|
||||||
|
|
||||||
|
salt-master-service-{{ wanted_state }}:
|
||||||
|
service.{{ wanted_state }}:
|
||||||
|
- enable: {{ salt_settings.master_service_details.enabled }}
|
||||||
|
- name: {{ salt_settings.master_service }}
|
||||||
|
- retry: {{ retry }}
|
||||||
|
- watch:
|
||||||
|
- sls: {{ sls_config_files }}
|
||||||
|
{%- endif %}
|
15
salt/windows-excluded.sls
Normal file
15
salt/windows-excluded.sls
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{%- if grains.kernel == 'Windows' %}
|
||||||
|
salt-windows-excluded-test.fail_without_changes:
|
||||||
|
test.fail_without_changes:
|
||||||
|
- name: Verify that current platform is not Windows
|
||||||
|
- comment: Platform Windows is not supported
|
||||||
|
{%- else %}
|
||||||
|
{#- Workaround https://github.com/saltstack/salt/issues/10852 #}
|
||||||
|
salt-windows-excluded-test.succeed_without_changes:
|
||||||
|
test.succeed_without_changes:
|
||||||
|
- name: Verify that current platform is not Windows
|
||||||
|
- comment: Platform {{ grains.kernel }} is supported
|
||||||
|
{%- endif %}
|
Loading…
Reference in New Issue
Block a user