Deploy multiple copies of an application to a single host

Hey all,

I’m coming from the Puppet world and learning (and loving!) more about Ansible. I’m curious how others would go about deploying a variable number of copies of an application to a given host?

In the Puppet world, I’ve solved this by leveraging the create_resources() function with a dictionary of dictionaries:

host1.yml:

app_instances: instance1: port: 1234 param: foo optional_param: true instance2: port: 5678 param: bar

host2.yml:

app_instances: instance1: port: 9000 param: baz

Puppet class:

create_resouces(my_application_class, $app_instances)

This works by invoking my_application_class once for each instance defined in the datastructure. It looks like I can accomplish something akin to this in Ansible by utilizing with_items/with_dict and looping over a boiler-plate role N times.

Has anyone successfully accomplished this, am I headed in the right direction? How did you do it?

Thanks!