diff --git a/deployment/database/mysql-container-puppet.yaml b/deployment/database/mysql-container-puppet.yaml
index 25b80a537e..bd748d379d 100644
--- a/deployment/database/mysql-container-puppet.yaml
+++ b/deployment/database/mysql-container-puppet.yaml
@@ -305,7 +305,7 @@ outputs:
               shell: |
                 {{ mysql_json.cli }} update --restart=unless-stopped mysql
                 {{ mysql_json.cli }} stop mysql
-              when: mysql_json.image != post_upgrade_mysql_image
+              when: mysql_json.image is defined and mysql_json.image != post_upgrade_mysql_image
             - name: Clean up redo log by running a transient mysql server
               shell:
                 str_replace:
@@ -316,7 +316,7 @@ outputs:
                     IMAGE: "{{ mysql_json.image }}"
                     VOLUMES: "-v {{ mysql_clean_up_volumes | join(' -v ') }}"
                     SCRIPT: "{{ mysql_clean_up_script }}"
-              when: mysql_json.image != post_upgrade_mysql_image
+              when: mysql_json.image is defined and mysql_json.image != post_upgrade_mysql_image
       post_upgrade_tasks:
         - when: step|int == 1
           import_role: