Need Help for REST API integration with Ansible

55 views
Skip to first unread message

Rahul Kumar

unread,
Jul 23, 2019, 8:39:06 AM7/23/19
to ansible...@googlegroups.com
There is URI module present in Ansible which lets you invoke REST End Points and it works preety well.
Currently i have lot of JSON Objects and corresponding REST end points ofcourse for each.
Is it a good practice for each and every parameter inside a JSON object (which is model object for REST service) configurable via jinja template in Ansible rather than POSTing complete Payload to a base URL from a file?
I mean it can be huge parameters if we make each service payload parameter as variable in ansible.
Customer demand is : they want each and every parameter used for REST API configurable via Ansible.
I dont know is it good or bad, for me it is not good practice.

Rahul

Rahul Kumar

unread,
Jul 30, 2019, 5:38:17 AM7/30/19
to ansible...@googlegroups.com
Any experts view on this ?

Andrew Feller

unread,
Jul 30, 2019, 5:49:02 AM7/30/19
to ansible...@googlegroups.com
You really should consider developing a plugin for this rather than twisting YAML to make it happen.  Check out https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html for writing this in Python in a way that’s callable from Ansible

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGH8rEwjeG%3DtOmDzTCGt5iZUU5%3Dbj5zSVfBrjDX2dG_-_%3DpDoQ%40mail.gmail.com.

Rahul Kumar

unread,
Jul 30, 2019, 5:51:57 AM7/30/19
to ansible...@googlegroups.com
Thanks Andrew , but is it good to make each and every parameter of Rest api response as configurable using Ansible , considering we have huge parameters?

Mark Anthony Garcia

unread,
Jul 30, 2019, 5:58:30 AM7/30/19
to Ansible Project
It is best to use jinja template to create the bosy file and call it for scalability. This is what I do using data from mssql query.

Abhijeet Kasurde

unread,
Jul 30, 2019, 6:12:32 AM7/30/19
to Ansible Project


On Tuesday, July 23, 2019 at 6:09:06 PM UTC+5:30, Rahul Kumar wrote:
There is URI module present in Ansible which lets you invoke REST End Points and it works preety well.
Currently i have lot of JSON Objects and corresponding REST end points ofcourse for each.
Is it a good practice for each and every parameter inside a JSON object (which is model object for REST service) configurable via jinja template in Ansible rather than POSTing complete Payload to a base URL from a file?

Take a look at modules in Kubernetes space for handling module parameters.

I mean it can be huge parameters if we make each service payload parameter as variable in ansible.
Customer demand is : they want each and every parameter used for REST API configurable via Ansible.

You may want to write plugin for this. Take a look at httpapi plugin for such requirement - https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/httpapi 

Rahul Kumar

unread,
Jul 30, 2019, 6:28:29 AM7/30/19
to ansible...@googlegroups.com
Thanks abhijeet .
https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/httpapi     - What this plugin does , any usage , as i dont see any readme file also? or i need to look at its code?


Regards
Rahul 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

Rahul Kumar

unread,
Sep 5, 2019, 1:14:00 AM9/5/19
to ansible...@googlegroups.com
I think purpose of httpapi plugin is different. Here I have my own API (say built in JAX-RS or Spring Boot), and list of REST ends points are of order (10-100) where each Resource have multiple parameters to deal with.
In that context , is it good to make each param configurable using ansible?
Reply all
Reply to author
Forward
0 new messages