struggling to understand roles and conditional execution

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/)

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

I have tried the following

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.

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

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

thanks for the responses