When attempting to group tasks, I can’t seem to find the right logic to make
if... else... with the host’s results function inside my “parent” or “grouping” task. In the below example, I never seem to reach the
if results_object.failed logic in my debugging:
def parent_task(task, payload, headers): payload["ip"] = task.host.hostname # First try with one payload results_object = task.run( task=http_method, method="post", url="https://myfancyapi.com", json=payload, headers=headers ) if results_object.failed: # If we failed, try again with a modified payload... payload["auth"] = "new_value" results_object = task.run( task=http_method, on_good=False, on_failed=True, method="post", url="https://myfancyapi.com", json=payload, headers=headers, )
All I really want to do is attempt multiple connection methods to a device as I may not know ahead of time which one will succeed. Any suggestions?