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:
---
# File: webServices.yml
# Playing everything for web services
- hosts: testcrows
remote_user: ansible
sudo: yes
roles:
- role: webServices
tasks:
- name: Check if Dokuwiki is already deployed
stat: path={{ apache_subDomainPath }}/{{ dokuwiki_dirSubPath }}
register: dokuwiki
- include: roles/webServices/tasks/dokuwiki.yml
when: dokuwiki.stat.exists == False
- name: Check if TinyTiny RSS is already deployed
stat: path={{ apache_subDomainPath }}/{{ app_dirSubPath }}
register: ttr
- include: roles/webServices/tasks/ttrss.yml
when: ttr.stat.exists == False
- name: Check if Webmail is already deployed
stat: path={{ apache_subDomainPath }}/{{ app_dirSubPath }}
register: dokuwiki
- include: roles/webServices/tasks/webmail.yml
when: webmail.stat.exists == False
I thought, I don't want to have 30 Roles for each web application, whereas
many of them doing closely the same, except some minor differences. But
Download, extract, moving, creating database is always the same...
And still with different roles for each web application, I would need to
have x copies of the same Apache config templates...
Thanks in advance!
Kind Regards
Dirk
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/530b8cab-41a1-44fc-b394-03b56979add1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.