update salt cloud config if configured

This commit is contained in:
Josh Patterson
2025-11-03 14:12:19 -05:00
parent b8c2808abe
commit fa154f1a8f
2 changed files with 13 additions and 8 deletions

View File

@@ -22,7 +22,7 @@ NOTIFYCUSTOMELASTICCONFIG=false
TOPFILE=/opt/so/saltstack/default/salt/top.sls TOPFILE=/opt/so/saltstack/default/salt/top.sls
BACKUPTOPFILE=/opt/so/saltstack/default/salt/top.sls.backup BACKUPTOPFILE=/opt/so/saltstack/default/salt/top.sls.backup
SALTUPGRADED=false SALTUPGRADED=false
SALT_CLOUD_INSTALLED=false SALT_CLOUD_CONFIGURED=false
# used to display messages to the user at the end of soup # used to display messages to the user at the end of soup
declare -a FINAL_MESSAGE_QUEUE=() declare -a FINAL_MESSAGE_QUEUE=()
@@ -1266,9 +1266,9 @@ upgrade_salt() {
echo "" echo ""
# If rhel family # If rhel family
if [[ $is_rpm ]]; then if [[ $is_rpm ]]; then
# Check if salt-cloud is installed # Check if salt-cloud is configured
if rpm -q salt-cloud &>/dev/null; then if [[ -f /etc/salt/cloud.profiles.d/socloud.conf ]]; then
SALT_CLOUD_INSTALLED=true SALT_CLOUD_CONFIGURED=true
fi fi
echo "Removing yum versionlock for Salt." echo "Removing yum versionlock for Salt."
@@ -1277,7 +1277,7 @@ upgrade_salt() {
yum versionlock delete "salt-minion" yum versionlock delete "salt-minion"
yum versionlock delete "salt-master" yum versionlock delete "salt-master"
# Remove salt-cloud versionlock if installed # Remove salt-cloud versionlock if installed
if [[ $SALT_CLOUD_INSTALLED == true ]]; then if [[ $SALT_CLOUD_CONFIGURED == true ]]; then
yum versionlock delete "salt-cloud" yum versionlock delete "salt-cloud"
fi fi
echo "Updating Salt packages." echo "Updating Salt packages."
@@ -1286,7 +1286,7 @@ upgrade_salt() {
# if oracle run with -r to ignore repos set by bootstrap # if oracle run with -r to ignore repos set by bootstrap
if [[ $OS == 'oracle' ]]; then if [[ $OS == 'oracle' ]]; then
# Add -L flag only if salt-cloud is already installed # Add -L flag only if salt-cloud is already installed
if [[ $SALT_CLOUD_INSTALLED == true ]]; then if [[ $SALT_CLOUD_CONFIGURED == true ]]; then
run_check_net_err \ run_check_net_err \
"sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -X -r -L -F -M stable \"$NEWSALTVERSION\"" \ "sh $UPDATE_DIR/salt/salt/scripts/bootstrap-salt.sh -X -r -L -F -M stable \"$NEWSALTVERSION\"" \
"Could not update salt, please check $SOUP_LOG for details." "Could not update salt, please check $SOUP_LOG for details."
@@ -1308,7 +1308,7 @@ upgrade_salt() {
yum versionlock add "salt-minion-0:$NEWSALTVERSION-0.*" yum versionlock add "salt-minion-0:$NEWSALTVERSION-0.*"
yum versionlock add "salt-master-0:$NEWSALTVERSION-0.*" yum versionlock add "salt-master-0:$NEWSALTVERSION-0.*"
# Add salt-cloud versionlock if installed # Add salt-cloud versionlock if installed
if [[ $SALT_CLOUD_INSTALLED == true ]]; then if [[ $SALT_CLOUD_CONFIGURED == true ]]; then
yum versionlock add "salt-cloud-0:$NEWSALTVERSION-0.*" yum versionlock add "salt-cloud-0:$NEWSALTVERSION-0.*"
fi fi
# Else do Ubuntu things # Else do Ubuntu things
@@ -1587,7 +1587,7 @@ main() {
# ensure the mine is updated and populated before highstates run, following the salt-master restart # ensure the mine is updated and populated before highstates run, following the salt-master restart
update_salt_mine update_salt_mine
if [[ $SALT_CLOUD_INSTALLED == true && $SALTUPGRADED == true ]]; then if [[ $SALT_CLOUD_CONFIGURED == true && $SALTUPGRADED == true ]]; then
echo "Updating salt-cloud config to use the new Salt version" echo "Updating salt-cloud config to use the new Salt version"
salt-call state.apply salt.cloud.config concurrent=True salt-call state.apply salt.cloud.config concurrent=True
fi fi

View File

@@ -36,6 +36,11 @@ cloud_profiles:
SALTVERSION: {{ SALTVERSION }} SALTVERSION: {{ SALTVERSION }}
- template: jinja - template: jinja
- makedirs: True - makedirs: True
{% else %}
no_hypervisors_configured:
test.succeed_without_changes:
- name: no_hypervisors_configured
- comment: No hypervisors are configured
{% endif %} {% endif %}
{% else %} {% else %}