Playbook showing as failed but actually runs successfully

When posting code, use triple tilde. Reading your output was a bit difficult.

The reason you are getting an error is because your code is expected an HTTP Status code of 204.
status_code: 204

In your output, we see that the server is giving you a status code of 201.
“msg”: “Status code was 201 and not [204]: OK (1305 bytes)”

IIRC, the status_code field in the ansible module is optional. You could try not specifying that field, and as long as the HTTP request is successful the module will mark it as changed.

OR, you could change your code to status_code: 201.

Documentation on HTTP Status Codes

4 Likes