# struggling to understand roles and conditional execution

**URL:** <https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842>\
**Category:** Ansible Developer\
**Tags:** galaxy-ng\
**Created:** [March 11, 2016, 3:05pm UTC](https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842 "2016-03-11T15:05:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Davies1](https://avatars.discourse-cdn.com/v4/letter/p/a88e4f/32.png) [@Paul\_Davies1](https://forum.ansible.com/u/Paul_Davies1)\
**Post date:** [March 11, 2016, 3:05pm UTC](https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842/1 "2016-03-11T15:05:05Z")

</div>

Hi

I’m having a bumpy start to my Ansilble journey

I am trying to install apache on a Centos host and a Solaris host and trying to use roles for he first time

I am trying to use geerlingguy’s apache role on Galaxy ([https://galaxy.ansible.com/geerlingguy/apache/](https://galaxy.ansible.com/geerlingguy/apache/))

for tasks\main.yml I assume I need to add something to tell Ansible what I want to run?

I have tried the following

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 11, 2016, 3:32pm UTC](https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842/2 "2016-03-11T15:32:07Z")

</div>

There is a 1 to 1 mapping between module execution and tasks. You have 2 module executions within a single task. For each `include` you need an individual task.

---

<div class="post-metadata">

**Author:** ![Paul\_Davies1](https://avatars.discourse-cdn.com/v4/letter/p/a88e4f/32.png) [@Paul\_Davies1](https://forum.ansible.com/u/Paul_Davies1)\
**Post date:** [March 11, 2016, 3:41pm UTC](https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842/3 "2016-03-11T15:41:05Z")

</div>

ah ok - so do I need 2 x main.yml files - main-Solaris.yml and main.Centos.yml for example?

---

<div class="post-metadata">

**Author:** ![Adam\_Lemanski](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@Adam\_Lemanski](https://forum.ansible.com/u/Adam_Lemanski)\
**Post date:** [March 22, 2016, 12:54pm UTC](https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842/4 "2016-03-22T12:54:29Z")

</div>

just saw your question, maybe to late to answer…

I’m pretty sure that Matt meant this:

- name: “setup Solaris apache”  
include: setup\_Solaris.yml  
when: ansible\_os\_family == “Solaris”

- name: “configure Solaris apache”  
include: configure-Solaris.yml  
when: ansible\_os\_family == “Solaris”

- name: “setup Centos apache”  
include: setup\_RedHat.yml  
when: ansible\_os\_family == “RedHat”

- name: “configure Centos apache”

include: configure-RedHat.yml  
when: ansible\_os\_family == “RedHat”

cheers

---

<div class="post-metadata">

**Author:** ![Paul\_Davies1](https://avatars.discourse-cdn.com/v4/letter/p/a88e4f/32.png) [@Paul\_Davies1](https://forum.ansible.com/u/Paul_Davies1)\
**Post date:** [March 29, 2016, 9:33am UTC](https://forum.ansible.com/t/struggling-to-understand-roles-and-conditional-execution/20842/5 "2016-03-29T09:33:37Z")

</div>

thanks for the responses
