# Please help to design layout for ansible

**URL:** <https://forum.ansible.com/t/please-help-to-design-layout-for-ansible/18145>\
**Category:** Ansible Project\
**Created:** [May 1, 2015, 12:19pm UTC](https://forum.ansible.com/t/please-help-to-design-layout-for-ansible/18145 "2015-05-01T12:19:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serega\_Sheypak](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@Serega\_Sheypak](https://forum.ansible.com/u/Serega_Sheypak)\
**Post date:** [May 1, 2015, 12:19pm UTC](https://forum.ansible.com/t/please-help-to-design-layout-for-ansible/18145/1 "2015-05-01T12:19:35Z")

</div>

Hi, I’m trying to pick correct roles layout and can’t find solution.  
The task is to install spark.  
There are three roles:

-install-spark-base (install spark-core package)  
-install-spark-configuration (puts configuration shared by all spark services)  
-install-spark-service-XXX (where XXX master, worker, history, jobserver) (installs concrete spark service)

- hosts: sparkworkers  
user: “{{ sudoUser }}”  
sudo: True  
roles:
- install-spark-worker

install-spark-worker depends on install-spark-configuration

install-spark-configuration depends on install-spark-base

So when install-spark-worker role is played, ansible runs  
-install-spark-base  
then  
-install-spark-configuration

then  
-install-spark-worker

Looks nice, basement, configuration and concrete service are separated.  
BUT  
I want install-spark-configuration to restart services each time configuration changes. When I do first run install-spark-configuration tries to restart absent service, since concrete service is installed AFTER configuration.  
What is the right way to resolve such collision?

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [May 1, 2015, 12:55pm UTC](https://forum.ansible.com/t/please-help-to-design-layout-for-ansible/18145/2 "2015-05-01T12:55:26Z")

</div>

> Hi, I'm trying to pick correct roles layout and can't find solution.  
> The task is to install spark.  
> There are three roles:
> 
> -install-spark-base (install spark-core package)  
> -install-spark-configuration (puts configuration shared by all spark  
> services)  
> -install-spark-service-XXX (where XXX master, worker, history, jobserver)  
> (installs concrete spark service)
> 
> - hosts: sparkworkers  
> &nbsp;&nbsp;user: "{{ sudoUser }}"  
> &nbsp;&nbsp;sudo: True  
> &nbsp;&nbsp;roles:  
> &nbsp;&nbsp;&nbsp;&nbsp;- install-spark-worker
> 
> install-spark-worker depends on install-spark-configuration  
> install-spark-configuration depends on install-spark-base
> 
> So when install-spark-worker role is played, ansible runs  
> -install-spark-base  
> then  
> -install-spark-configuration  
> then  
> -install-spark-worker

I'd just have:

spark (install packages, shared configuration, etc)  
spark-master (specific packages, files, etc)  
spark-worker  
spark-jobserver  
....

> Looks nice, basement, configuration and concrete service are separated.  
> BUT  
> I want install-spark-configuration to restart services each time  
> configuration changes. When I do first run install-spark-configuration  
> tries to restart absent service, since concrete service is installed  
> AFTER  
> configuration.  
> What is the right way to resolve such collision?

I don't know how Spark works but there must be a way to trigger a  
complete restart of all the services involved.

The basic "spark" role could have a task for that. And each  
"spark-$service" role would take care of restarting only the service  
impacted.

Giovanni
