2
0

feat(package): allow for salt package version hold

This commit is contained in:
Michael Schmitt 2022-03-30 16:02:26 -06:00
parent 7af4524f22
commit 11b017e6a8
No known key found for this signature in database
GPG Key ID: 5145CC5841E00C15
9 changed files with 79 additions and 8 deletions

View File

@ -24,9 +24,11 @@ salt:
# Optional: set salt version (if install_packages is set to true)
version: 2017.7.2-1.el7
# Pin version provided under 'version' key by using apt-pinning
# available only on Debian family OS-es
pin_version: false
# These 2 options apply only to yum/dnf, apt, and zypper-based systems:
# Force the package to be held at the installed version (optional)
hold_version: false
# Allow the upgrade or downgrade of a "held" package version (optional)
update_holds: false
# to overwrite map.jinja salt packages
lookup:

View File

@ -10,6 +10,12 @@ salt-api:
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
{% endif %}
{% if salt_settings.api_service_details.state != 'ignore' %}
service.{{ salt_settings.api_service_details.state }}:

View File

@ -1,6 +1,11 @@
{%- set tplroot = tpldir.split('/')[0] %}
{% from "salt/map.jinja" import salt_settings with context %}
{% if salt_settings.hold_version is defined and salt_settings.install_packages %}
include:
- .hold
{% endif %}
{%- if salt_settings.use_pip %}
python-pip:
pkg.installed
@ -24,6 +29,12 @@ salt-cloud:
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
{%- if salt_settings.use_pip %}
- require:
- pip: salt-cloud-pip-packages

12
salt/hold.sls Normal file
View File

@ -0,0 +1,12 @@
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import salt_settings with context %}
{% if salt_settings.hold_version is defined and grains.os_family|lower == 'redhat' %}
salt-install-hold-plugin:
pkg.installed:
{% if grains.osmajorrelease > 7 %}
- name: python3-dnf-plugin-versionlock
{% else %}
- name: yum-plugin-versionlock
{% endif %}
{% endif %}

View File

@ -2,9 +2,9 @@
{%- 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' %}
{% if salt_settings.hold_version is defined and salt_settings.install_packages %}
include:
- .pin
- .hold
{% endif %}
{%- if grains.kernel != 'Windows' %}
@ -26,6 +26,12 @@ salt-master:
- name: {{ salt_settings.salt_master }}
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
{% if salt_settings.master_service_details.state != 'ignore' %}
- require_in:

View File

@ -2,9 +2,9 @@
{%- 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' %}
{% if salt_settings.hold_version is defined and salt_settings.install_packages %}
include:
- .pin
- .hold
{% endif %}
{%- if grains.os == 'MacOS' %}
@ -68,8 +68,14 @@ salt-minion:
{%- elif grains.os != 'MacOS' and "workaround https://github.com/saltstack/salt/issues/49348" %}
pkg.installed:
- name: {{ salt_settings.salt_minion }}
{%- if salt_settings.version %}
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
{% if salt_settings.minion_service_details.state != 'ignore' %}
- require_in:

View File

@ -1,6 +1,11 @@
{%- set tplroot = tpldir.split('/')[0] %}
{% from "salt/map.jinja" import salt_settings with context %}
{% if salt_settings.hold_version is defined and salt_settings.install_packages %}
include:
- .hold
{% endif %}
{% if salt_settings.install_packages %}
ensure-salt-ssh-is-installed:
pkg.installed:
@ -8,6 +13,12 @@ ensure-salt-ssh-is-installed:
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
{% endif %}
ensure-roster-config:

View File

@ -1,6 +1,11 @@
{%- set tplroot = tpldir.split('/')[0] %}
{% from "salt/map.jinja" import salt_settings with context %}
{% if salt_settings.hold_version is defined and salt_settings.install_packages %}
include:
- .hold
{% endif %}
salt-minion-standalone:
{% if salt_settings.install_packages %}
pkg.installed:
@ -8,6 +13,12 @@ salt-minion-standalone:
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
{% endif %}
file.recurse:
- name: {{ salt_settings.config_path }}/minion.d

View File

@ -9,6 +9,12 @@ salt-syndic:
- name: {{ salt_settings.salt_syndic }}
{%- if salt_settings.version is defined %}
- version: {{ salt_settings.version }}
{%- endif %}
{%- if salt_settings.hold_version is defined %}
- hold: {{ salt_settings.hold_version }}
{%- endif %}
{%- if salt_settings.update_holds is defined %}
- update_holds: {{ salt_settings.update_holds }}
{%- endif %}
- require_in:
- service: salt-syndic