Defining variables in tasks

Hello together,
I’m trying with ansible since 2 days and I’m really happy with it after getting behind the idea of playbooks.

Currently I’m stuck with a situation and I’m not sure if this is a conceptual mistake.

I have defined 3 roles currently:

  • basicConfig (Containing network config, SSHd configuration, NTP and so on. Working fine).
  • mailServices (Containing postfix with tools and configuration. Still to write)
  • webServices (Containing installation of Apache, PHP and MySQL, including all applications like Dokuwiki, Roundcube Webmail and TinyTinyRSS).

For webservices I have a question. This is my directory structure:
.
├── group_vars
│ └── testcrows
├── hosts
├── host_vars
├── roles
│ └── webServices
│ ├── files
│ ├── handlers
│ │ └── main.yml
│ ├── tasks
│ │ ├── dokuwiki.yml
│ │ ├── main.yml
│ │ ├── ttrss.yml
│ │ └── webmail.yml
│ ├── templates
│ │ └── apacheSites
│ │ ├── template.j2
│ └── vars
│ └── main.yml
└── webServices.yml

I’m running webServices.yml as playbook which is then running main.yml (installation of Apache, MySQL, …) and then including dokuwiki.yml, ttrss.yml and webmail.yml.
In general the last 3 ones are doing closely the same (Downloading Installer, unziping, moving to dest directory, creating database and writing apache conf (based on template.j2).
I would like to set parameters to each of the 3 files, which are used in the template so for example:

`
ServerName {{ app_vHost }}.{{ systemDomain }}

`
This would allow me to have only one template for the easy applications, but having each on their own vHost definition. So avoiding redundancy.

So Question No. 1:
Is this an appropriate way to define the directory structure? If yes, how do I assign variables within the taks file? If I assign a vars Part, I do get syntax errors, so doesn’t seem to belong there?!

Question 2:
I would like to include these tasks only if the destination path is not yet there. I managed to write everything in static, but how can I use this then on the include part. So currently my webServices.yml is this:

`