mirror of
https://github.com/saltstack-formulas/salt-formula.git
synced 2026-02-09 10:14:47 +01:00
Merge 121b62803a94f2816c7e1864719bd261b0eff09f into bf52207a9bcdfcba7abe27013c082594a8ae139d
This commit is contained in:
commit
f98c26da89
@ -62,6 +62,39 @@ Install a minion
|
||||
|
||||
Install a master.
|
||||
|
||||
This state can't be run on Windows OS, the ``salt.windows-excluded``
|
||||
is used as a safeguard dependency.
|
||||
|
||||
``salt.master.package``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Install the master package.
|
||||
|
||||
This state can't be run on Windows OS, the ``salt.windows-excluded``
|
||||
is used as a safeguard dependency.
|
||||
|
||||
``salt.master.config``
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Configure the master service.
|
||||
|
||||
This state can't be run on Windows OS, the ``salt.windows-excluded``
|
||||
is used as a safeguard dependency.
|
||||
|
||||
``salt.master.service``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Manage the salt master service if
|
||||
``salt_settings.master_service_details.state`` is not ``ignore``:
|
||||
|
||||
- enable and start the salt master service if
|
||||
``salt_settings.master_service_details.state`` is ``running``, the default.
|
||||
- stop and disable the salt master service if
|
||||
``salt_settings.master_service_details.state`` is ``dead``.
|
||||
|
||||
This state can't be run on Windows OS, the ``salt.windows-excluded``
|
||||
is used as a safeguard dependency.
|
||||
|
||||
``salt.syndic``
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
@ -159,6 +192,14 @@ If you configure the state to download the formulas from repositories that
|
||||
you control, then you can safely enable the
|
||||
``salt_formulas:git_opts:default:update`` pillar setting to ``True``.
|
||||
|
||||
``salt.windows-excluded``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Safeguard state to exclude Windows OS, used by ``salt.master`` states
|
||||
and sub states.
|
||||
|
||||
It fails using ``test.fail_without_changes`` on Windows OS and succeed
|
||||
with ``test.succeed_without_changes`` on others.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
@ -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 in ['FreeBSD', 'Gentoo'] %}
|
||||
- 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.installed" %}
|
||||
{%- 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
|
||||
12
salt/master/init.sls
Normal file
12
salt/master/init.sls
Normal file
@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{%- set sls_windows_excluded = tplroot ~ ".windows-excluded" %}
|
||||
|
||||
include:
|
||||
- {{ sls_windows_excluded }}
|
||||
- .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:
|
||||
- .installed
|
||||
26
salt/master/package/installed.sls
Normal file
26
salt/master/package/installed.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-installed-pkg.installed:
|
||||
pkg.installed:
|
||||
- name: {{ salt_settings.salt_master }}
|
||||
- version: {{ salt_settings.version | default('~') }}
|
||||
- require:
|
||||
- sls: {{ sls_windows_excluded }}
|
||||
{%- endif %}
|
||||
29
salt/master/service/init.sls
Normal file
29
salt/master/service/init.sls
Normal file
@ -0,0 +1,29 @@
|
||||
# -*- 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 = {
|
||||
'FreeBSD': salt_settings.retry_options | json,
|
||||
'Gentoo': salt_settings.retry_options | json,
|
||||
}.get(grains.os_family, '')
|
||||
%}
|
||||
|
||||
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-testfail_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…
x
Reference in New Issue
Block a user