Compare commits
4 Commits
b8297efac6
...
master_abr
| Author | SHA1 | Date | |
|---|---|---|---|
| 68929bc91d | |||
| 47b37fbcc8 | |||
| 1456280ca8 | |||
| e37afec5a6 |
38
Readme.md
38
Readme.md
@@ -1,17 +1,31 @@
|
|||||||
# Solution (proposition)
|
## Includes et import
|
||||||
|
|
||||||
Plutôt que de conditionner chaque tâche en fonction de la distribution (ce qui sera pénible et difficile à maintenir), la solution consistant à inclure un fichier de variables propre à chaque OS cible est plus élégante.
|
**Tâche**: écrire des playbooks modulaires
|
||||||
|
|
||||||
|
**Condition**: selon besoin
|
||||||
|
|
||||||
|
**Norme**: includes et import
|
||||||
|
|
||||||
|
**Préparation**:
|
||||||
|
|
||||||
|
** Pratique **
|
||||||
|
|
||||||
|
Récupérer la solution de l'atelier handler
|
||||||
|
|
||||||
|
Identifier dans le playbook et le fichier vhost.conf toutes les spécificités de RedHat (qui vont empécher le playbook de fonctionner)
|
||||||
|
|
||||||
|
Trouver la solution à cette problématique (exécution conditionnelle, variabilisation ...)
|
||||||
|
|
||||||
|
Implémenter la solution
|
||||||
|
|
||||||
|
Sur la debian, la configuration par défaut entre en conflit avec la notre:
|
||||||
|
|
||||||
|
Modifier le playbook pour que le fichier /etc/apache2/sites-enabled/000-default.conf soit supprimé UNIQUEMENT sur la debian, avec redémarrage du service apache si besoin
|
||||||
|
|
||||||
|
|
||||||
Autre cas d'utilisation des includes:
|
** Validation:
|
||||||
|
|
||||||
```yaml
|
```bash
|
||||||
- name: ensure bootstrap role has been applied
|
curl debian1
|
||||||
include_role:
|
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
|
||||||
name: bootstrap
|
|
||||||
when: apply_bootstrap_role
|
|
||||||
- include: bash.yml
|
|
||||||
tags: bash
|
|
||||||
- include: local_repo.yml
|
|
||||||
when: ansible_distribution=='CentOS' and use_local_repo
|
|
||||||
```
|
```
|
||||||
18
apache.yml
18
apache.yml
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install apache via ansible playbook
|
|
||||||
hosts: cibles
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: import OS Specific variables
|
|
||||||
include_vars: "{{ ansible_distribution | lower }}.yml"
|
|
||||||
|
|
||||||
- name: install apache
|
|
||||||
package:
|
|
||||||
name: "{{ apache_package_name }}"
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: activate apache
|
|
||||||
service:
|
|
||||||
name: "{{ apache_service_name }}"
|
|
||||||
enabled: yes
|
|
||||||
state: started
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
apache_package_name: httpd
|
|
||||||
apache_service_name: httpd
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
apache_package_name: apache2
|
|
||||||
apache_service_name: apache2
|
|
||||||
Reference in New Issue
Block a user