# Ansible pattern for API-based config management

**URL:** <https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982>\
**Category:** Ansible Project\
**Created:** [April 9, 2014, 6:11pm UTC](https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982 "2014-04-09T18:11:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salman\_Haq](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Salman\_Haq](https://forum.ansible.com/u/Salman_Haq)\
**Post date:** [April 9, 2014, 6:11pm UTC](https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982/1 "2014-04-09T18:11:33Z")

</div>

I am exploring automation of a Hadoop cluster.

The vendor (Cloudera) requires that all configuration happen through a REST API. See [1] for Cloudera Python API client.

My question is: Is there a prior example of an Ansible playbook that wraps an HTTP api?

Thanks!  
Salman

[1] [http://cloudera.github.io/cm\_api/docs/python-client/](http://cloudera.github.io/cm_api/docs/python-client/)

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [April 10, 2014, 4:14pm UTC](https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982/2 "2014-04-10T16:14:24Z")

</div>

The type of work you're looking to do is best handled by writing a Cloudera  
module. I don't want to imagine how one might wrap a REST API in a  
playbook -- that does not sound fun or reasonable. 🙂

---

<div class="post-metadata">

**Author:** ![Drew\_Northup](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@Drew\_Northup](https://forum.ansible.com/u/Drew_Northup)\
**Post date:** [April 10, 2014, 5:37pm UTC](https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982/3 "2014-04-10T17:37:25Z")

</div>

> The type of work you’re looking to do is best handled by writing a Cloudera module. I don’t want to imagine how one might wrap a REST API in a playbook – that does not sound fun or reasonable. 🙂

Paul,  
It has already been done…

> > I am exploring automation of a Hadoop cluster.
> > 
> > The vendor (Cloudera) requires that all configuration happen through a REST API. See [1] for Cloudera Python API client.
> > 
> > My question is: Is there a prior example of an Ansible playbook that wraps an HTTP api?

Salman,  
Look at this module’s doc page: [http://docs.ansible.com/uri\_module.html](http://docs.ansible.com/uri_module.html)  
(Romeo even provided some examples, prior to the existence of a JIRA module).

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [April 10, 2014, 6:05pm UTC](https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982/4 "2014-04-10T18:05:39Z")

</div>

Hi Drew,

You’re right, the URI module is available. I didn’t mention it because Salman mention he was going to be coordinating the automation for an entire cluster. The URI module is useful, yes, but interacting with a large API for complex tasks? That’s what I meant when I said that I don’t want to know what such a playbook might look like.

So, yes, that functionality exists, but it’s way less than ideal for working repeatedly with complex APIs. This functionality really deserves to be in a module.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 15, 2014, 9:00pm UTC](https://forum.ansible.com/t/ansible-pattern-for-api-based-config-management/14982/5 "2014-04-15T21:00:53Z")

</div>

Yeah it depends on what you need to do.

I would hope the vendor also exposes a CLI that talks to their REST API, so you could call to that without needing a module, but if a module makes sense and one is built, this is something we could possibly consider for core inclusion.

The uri module is quite useful for some simple things, though registering a lot of results and using a lot of conditionals quickly gets into programming territory – which is to say a module could be used, or even the script module could be used to call a small script too.
