Closed Datadigital123 closed 3 years ago
Hi!
Thanks very much for your interest in Ansible. It sincerely means a lot to us.
This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.
If you can stop by there, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.
Thank you once again and we look forward to seeing you on the list or IRC. Thanks!
Hello,
I am trying to run a PUT API call via Ansible URI module for a particular API Endpoint in my application, using a dictionary that contains the json files and that is defined as:
example: { 'example1' : 'v1', 'example2': 'v2''}
name: Update endpoint uri: url: "{{url}}/api/v1/{{item.key}}/" method: PUT body: "{{ lookup('file', '{{item.key}}/{{item.value}}.json') }}" status_code: 200 body_format: json headers: Content-Type: "application/json" Authorization: "Token {{ token.json.token }}" with_dict: "{{ example }}" register: updated
Given the task fails and I get a 4xx error when the api endpoint for the item does not exist, I want to run a POST command for that same json file or same {{item.key}} and {{item.value}} in reference to my specific JSON file.
How can I do this in ansible, to retry a task that failed but only specifically for that {{item.key}} and {{item.value}} in dictionary?
or
Is there a better way to do this to retry a failed PUT with a POST command
I want to use the ansible URI module
Thanks!