- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- How to force an instance into a failed state durin...
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2024 04:22 AM
04-24-2024 04:22 AM
How to force an instance into a failed state during provisioning phase based on certain conditions
In certain scenarios, you may wish to transition the instance provision to a failed state based on specific conditions within your workflow tasks. The following examples demonstrate various task types where this can be accomplished by exiting with code 1.
Shell
#!/bin/bash
myVar='pass'
if [ "$myVar" = "fail" ]; then
exit 1
fi
Python
import sys
myVar ='pass'
if myVar == 'fail':
sys.exit(1)
PowerShell
$myVar = 'pass'
if ($myVar -eq 'fail') {
exit 1
}
With Ansible playbooks we can use the built-in fail module to achieve the same.
Ansible Playbook
---
- hosts: all
vars:
myVar: pass
tasks:
- name: Fail Ansible Task
ansible.builtin.fail:
msg: The task will fail based on the value of the myVar
when: myVar == "fail"
Here is an example where I’m demonstrating the Ansible Tower task type utilizing the above ansible.builtin.fail module during the post-provision phase of the operational workflow.
When the task is put into a failed state the provision will fail as shown below.