Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Alert Auto remediation issue using Ansible

Community Alums
Not applicable

Hello All,

I have built the subflow for alert auto remediation using ansible. I am able to reach the ansible successfully, however extra argument (Alert Node) values are not passing to ansible. Please let me know how we can resolve it. Below snapshot for reference.

 

chandrakumarabs_0-1747405635456.png

 

#Itom 

Regards,

Chandrakumara BS

 

2 REPLIES 2

Community Alums
Not applicable

Can someone help me to resolve this. Thanks in advance. 

amit_bt
Tera Contributor

When your extra variables, like the Alert Node, are not passing from a ServiceNow subflow to Ansible, the issue is typically a mismatch between how ServiceNow sends the data and how Ansible receives and expects it. 
1. Verify variable mapping in the ServiceNow subflow
Locate the Ansible action: In your ServiceNow Flow Designer subflow, find the Ansible action step. This could be "Run Job Template" or "Run Workflow" from the Ansible Spoke.
Check the Extra Vars field: Within this action step, there will be an input field for Extra Variables or Extra Vars.
Use the Data Pill Picker: Use the data pill picker to select the "Alert Node" variable from the subflow's data panel. Drag and drop this pill directly into the Extra Vars field.
Format as JSON: Ensure the variable is formatted as a valid JSON object within the Extra Vars field. Ansible expects extra variables in this format. The syntax should look like this:
{ "alert_node": "{{Your_Alert_Record.Node}}"}

2. Confirm the variable in your Ansible job template
Examine the Job Template: In your Ansible Automation Platform (formerly Tower/AWX), open the Job Template that your ServiceNow subflow is executing.
Set the variable as a prompt: Go to the Job Template details and check the Extra Variables field. The field should be set to "Prompt on Launch". This ensures that the job is prepared to receive variables passed in from the calling application (ServiceNow). If you are using a Survey instead of prompting, the variable must be defined there.
Check for conflicts: The hierarchy of variable precedence in Ansible is important. Variables passed via the --extra-vars flag (which is what the ServiceNow spoke does) have the highest precedence, so they will override any variables defined elsewhere (like in the inventory or the playbook itself). Ensure you don't have conflicting variables with a lower precedence that are being used instead.