Skip to content

Commit

Permalink
add sles to sap migration to distupgrade state
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalmer committed Oct 6, 2024
1 parent 5cfc92e commit 4a98c00
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion susemanager-utils/susemanager-sls/salt/channels/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ mgrchannels_install_products:
- mgrcompat: sync_states
{%- endif %}
{%- if salt['pillar.get']('susemanager:distupgrade', False) %}
- mgrcompat: spmigration
- spmigration
{%- endif %}
{%- endif %}
{%- endif %}
Expand Down
17 changes: 13 additions & 4 deletions susemanager-utils/susemanager-sls/salt/distupgrade/init.sls
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
include:
- channels

{% if grains['os_family'] == 'Suse' %}

{% if grains['osfullname']|upper == 'SLES' and grains['osmajorrelease']|int >= 15 and pillar.get('susemanager:distupgrade:targetbaseproduct:name', '')|lower == 'sles_sap' %}
{% if not salt['pillar.get']('susemanager:distupgrade:dryrun', False) %}
{% include 'distupgrade/sap.sls' %}
{% endif %}

{% else %}
spmigration:
mgrcompat.module_run:
- name: pkg.upgrade
Expand All @@ -11,9 +21,11 @@ spmigration:
{% endif %}
- require:
- file: mgrchannels*
{% endif %} {# grains['osfullname']|upper == 'SLES' ... #}

{% elif grains['os_family'] == 'RedHat' %}
{% if not salt['pillar.get']('susemanager:distupgrade:dryrun', False) %}
{# if pillar liberate:reinstall_packages is not set, it default to true. This is the default we want #}
{# when pillar liberate:reinstall_packages is not set, it default to true. This is the default we want #}
{% include 'liberate/init.sls' %}

{% set logname='/var/log/dnf_sll_migration.log' %}
Expand Down Expand Up @@ -42,6 +54,3 @@ mgr_release_pkg_removed:
{%- endfor %}
{% endif %}
{% endif %}

include:
- channels
36 changes: 36 additions & 0 deletions susemanager-utils/susemanager-sls/salt/distupgrade/sap.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% set sles_release_installed = (salt['pkg.info_installed']('sles-release', attr='version', failhard=False).get('sles-release', {}).get('version') != None) %}
{% if sles_release_installed and pillar.get('susemanager:distupgrade:targetbaseproduct:name', '')|lower == 'sles_sap' %}

mgr_remove_release_package:
cmd.run:
- name: "rpm -e --nodeps sles-release"

mgr_remove_flavor_package_dvd:
cmd.run:
- name: "rpm -e --nodeps sles-release-DVD"
- onlyif: rpm -q sles-release-DVD

mgr_remove_flavor_package_pool:
cmd.run:
- name: "rpm -e --nodeps sles-release-POOL"
- onlyif: rpm -q sles-release-POOL

{% set default_modules = ['SLES_SAP', 'sle-module-basesystem', 'sle-module-desktop-applications', 'sle-module-server-applications', 'sle-ha', 'sle-module-sap-applications'] %}

{% for module in default_modules %}
mgr_install_product_{{ module }}:
cmd.run:
- name: zypper --no-refresh --non-interactive install --no-recommends --auto-agree-with-product-licenses -t product {{ module }}
- require:
- cmd: mgr_remove_release_package
- cmd: mgr_remove_flavor_package_dvd
- cmd: mgr_remove_flavor_package_pool
{% endfor %}

spmigration:
test.nop:
- require:
{%- for module in default_modules %}
- mgr_install_product_{{ module }}
{%- endfor %}
{% endif %}

0 comments on commit 4a98c00

Please sign in to comment.