Compare commits
4 Commits
master
...
master_abr
| Author | SHA1 | Date | |
|---|---|---|---|
| 13f20ad7a7 | |||
| dfa9b53b00 | |||
| 2da29d1c8e | |||
| b5dde24374 |
24
Readme
24
Readme
@@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
Tâche: Utiliser des conditions
|
|
||||||
Condition: très souvent ;)
|
|
||||||
Norme: éditeur de texte, modules template
|
|
||||||
|
|
||||||
Objectif: Ajouter le support de php à la demande
|
|
||||||
|
|
||||||
Rajouter une variable booleenne apache_use_php.
|
|
||||||
|
|
||||||
Positionnée à "true", cette variable entraîne:
|
|
||||||
- l'installation du paquet php-fpm
|
|
||||||
- le lancement et l'activation du service php-fpm
|
|
||||||
- l'ajout dans la configuration apache des directives suivantes:
|
|
||||||
<code>
|
|
||||||
<FilesMatch \.php$>
|
|
||||||
SetHandler proxy:fcgi://localhost:9000
|
|
||||||
</FilesMatch>
|
|
||||||
</code>
|
|
||||||
|
|
||||||
Prérequis:
|
|
||||||
* On peut se baser sur l'exercice précédent.
|
|
||||||
|
|
||||||
Validation: le playbook s'exécute correctement sur nos cibles.
|
|
||||||
Chaque cible héberge plusieurs sites différents.
|
|
||||||
26
Readme.md
Normal file
26
Readme.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Conditions
|
||||||
|
|
||||||
|
## Prérequis:
|
||||||
|
|
||||||
|
Récupérer les ressources du jour:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd
|
||||||
|
git clone https://infra.opendoor.fr/git/tom/abr_day4.git
|
||||||
|
```
|
||||||
|
|
||||||
|
## Atelier 1: Ajouter le support de php à la demande
|
||||||
|
|
||||||
|
Rajouter une variable booleenne apache_use_php.
|
||||||
|
|
||||||
|
Positionnée à "true", cette variable entraîne:
|
||||||
|
- l'installation du paquet php-fpm
|
||||||
|
- le lancement et l'activation du service php-fpm
|
||||||
|
- l'ajout dans le répertoire de configuration apache le fichier php-fpm.conf contenant des directives suivantes:
|
||||||
|
|
||||||
|
```apache
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
SetHandler proxy:fcgi://localhost:9000
|
||||||
|
</FilesMatch>
|
||||||
|
```
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install apache via ansible playbook
|
|
||||||
hosts: test
|
|
||||||
user: ansible
|
|
||||||
become: true
|
|
||||||
roles:
|
|
||||||
- myapache4
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
Role Name
|
|
||||||
=========
|
|
||||||
|
|
||||||
Rôle de deploiement apache sur une centos.
|
|
||||||
|
|
||||||
1 seul vhost
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Role Variables
|
|
||||||
--------------
|
|
||||||
apache_user_php - default False
|
|
||||||
http_port: 80
|
|
||||||
servername: orsys.fr
|
|
||||||
serveralias: "www.{{ servername }}"
|
|
||||||
documentroot: /var/www/html/orsys.fr
|
|
||||||
accesslog: /var/log/httpd/access_orsys.fr_log
|
|
||||||
errorlog: /var/log/httpd/error_orsys.fr_log
|
|
||||||
|
|
||||||
Dependencies
|
|
||||||
------------
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Example Playbook
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
|
||||||
|
|
||||||
- hosts: servers
|
|
||||||
roles:
|
|
||||||
- { myapache }
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
BSD
|
|
||||||
|
|
||||||
Author Information
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Thomas Constans <thomas@opendoor.fr>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for myapache
|
|
||||||
http_port: 80
|
|
||||||
use_php: false
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<h1>hello World</h1>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
echo phpinfo() ;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for myapache
|
|
||||||
- name: reload httpd
|
|
||||||
service:
|
|
||||||
name: httpd
|
|
||||||
state: reloaded
|
|
||||||
|
|
||||||
- name: reload firewalld
|
|
||||||
service:
|
|
||||||
name: firewalld
|
|
||||||
state: reloaded
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
galaxy_info:
|
|
||||||
author: your name
|
|
||||||
description: your description
|
|
||||||
company: your company (optional)
|
|
||||||
|
|
||||||
# If the issue tracker for your role is not on github, uncomment the
|
|
||||||
# next line and provide a value
|
|
||||||
# issue_tracker_url: http://example.com/issue/tracker
|
|
||||||
|
|
||||||
# Some suggested licenses:
|
|
||||||
# - BSD (default)
|
|
||||||
# - MIT
|
|
||||||
# - GPLv2
|
|
||||||
# - GPLv3
|
|
||||||
# - Apache
|
|
||||||
# - CC-BY
|
|
||||||
license: license (GPLv2, CC-BY, etc)
|
|
||||||
|
|
||||||
min_ansible_version: 1.2
|
|
||||||
|
|
||||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
|
||||||
# min_ansible_container_version:
|
|
||||||
|
|
||||||
# Optionally specify the branch Galaxy will use when accessing the GitHub
|
|
||||||
# repo for this role. During role install, if no tags are available,
|
|
||||||
# Galaxy will use this branch. During import Galaxy will access files on
|
|
||||||
# this branch. If Travis integration is configured, only notifications for this
|
|
||||||
# branch will be accepted. Otherwise, in all cases, the repo's default branch
|
|
||||||
# (usually master) will be used.
|
|
||||||
#github_branch:
|
|
||||||
|
|
||||||
#
|
|
||||||
# platforms is a list of platforms, and each platform has a name and a list of versions.
|
|
||||||
#
|
|
||||||
# platforms:
|
|
||||||
# - name: Fedora
|
|
||||||
# versions:
|
|
||||||
# - all
|
|
||||||
# - 25
|
|
||||||
# - name: SomePlatform
|
|
||||||
# versions:
|
|
||||||
# - all
|
|
||||||
# - 1.0
|
|
||||||
# - 7
|
|
||||||
# - 99.99
|
|
||||||
|
|
||||||
galaxy_tags: []
|
|
||||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
|
||||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
|
||||||
# remove the '[]' above, if you add tags to this list.
|
|
||||||
#
|
|
||||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
|
||||||
# Maximum 20 tags per role.
|
|
||||||
|
|
||||||
dependencies: []
|
|
||||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
|
||||||
# if you add dependencies to this list.
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
---
|
|
||||||
# tasks file for myapache
|
|
||||||
- name: import distribution specific variables
|
|
||||||
include_vars: "{{ ansible_distribution|lower }}.yml"
|
|
||||||
|
|
||||||
- name: install apache
|
|
||||||
tags: httpd
|
|
||||||
package:
|
|
||||||
name: "{{ package_name }}"
|
|
||||||
state: latest
|
|
||||||
|
|
||||||
- name: conf httpd
|
|
||||||
tags: httpd
|
|
||||||
notify: reload httpd
|
|
||||||
template:
|
|
||||||
src: vhost.conf.jj
|
|
||||||
dest: "{{ apache_conf_dir }}/vhost.conf"
|
|
||||||
mode: 0640
|
|
||||||
owner: root
|
|
||||||
group: "{{ apache_group }}"
|
|
||||||
|
|
||||||
- name: activate apache
|
|
||||||
tags: httpd
|
|
||||||
service:
|
|
||||||
name: "{{ service_name }}"
|
|
||||||
enabled: yes
|
|
||||||
|
|
||||||
- name: open firewall port
|
|
||||||
tags: httpd
|
|
||||||
firewalld:
|
|
||||||
service: http
|
|
||||||
permanent: yes
|
|
||||||
immediate: yes
|
|
||||||
state: enabled
|
|
||||||
ignore_errors: yes
|
|
||||||
notify: reload firewalld
|
|
||||||
when: ansible_distribution|lower != "debian"
|
|
||||||
|
|
||||||
- name: create documentroot
|
|
||||||
tags: httpd
|
|
||||||
file:
|
|
||||||
name: "{{ item.documentroot }}"
|
|
||||||
state: directory
|
|
||||||
with_items:
|
|
||||||
- "{{ apache_vhosts }}"
|
|
||||||
|
|
||||||
- name: create index file
|
|
||||||
tags: httpd
|
|
||||||
copy:
|
|
||||||
src: index.html
|
|
||||||
dest: "{{ item.documentroot }}/index.html"
|
|
||||||
mode: 0644
|
|
||||||
with_items:
|
|
||||||
- "{{ apache_vhosts }}"
|
|
||||||
|
|
||||||
- name: include php stuff
|
|
||||||
include_tasks: php.yml
|
|
||||||
when: use_php
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install php-fpm
|
|
||||||
yum:
|
|
||||||
name: php-fpm
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: start php-fpm
|
|
||||||
service:
|
|
||||||
name: php-fpm
|
|
||||||
state: started
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
- name: create info file
|
|
||||||
copy:
|
|
||||||
src: info.php
|
|
||||||
dest: "{{ item.documentroot }}/info.php"
|
|
||||||
mode: 0644
|
|
||||||
with_items:
|
|
||||||
- "{{ apache_vhosts }}"
|
|
||||||
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
{% for vhost in apache_vhosts %}
|
|
||||||
<VirtualHost *:{{ http_port }}>
|
|
||||||
ServerName {{ vhost.servername|lower }}
|
|
||||||
ServerAlias {{ vhost.serveralias }}
|
|
||||||
DocumentRoot {{ vhost.documentroot }}
|
|
||||||
CustomLog {{ vhost.accesslog }} combined
|
|
||||||
ErrorLog {{ vhost.errorlog }}
|
|
||||||
<Directory />
|
|
||||||
Options none
|
|
||||||
Allowoverride none
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
{% if use_php %}
|
|
||||||
<FilesMatch \.php$>
|
|
||||||
SetHandler proxy:fcgi://localhost:9000
|
|
||||||
</FilesMatch>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<Directory {{ vhost.documentroot }}>
|
|
||||||
Options {{ vhost.documentrootoptions|default( "none" ) }}
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
||||||
{% endfor %}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
localhost
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: localhost
|
|
||||||
remote_user: root
|
|
||||||
roles:
|
|
||||||
- myapache
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
redhat.yml
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
apache_conf_dir: /etc/apache2/sites-enabled
|
|
||||||
apache_log_dir: /var/log/apache2
|
|
||||||
package_name: apache2
|
|
||||||
service_name: apache2
|
|
||||||
apache_user: www-data
|
|
||||||
apache_group: www-data
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for myapache
|
|
||||||
http_port: 80
|
|
||||||
apache_vhosts:
|
|
||||||
- servername: ORSYS.Fr
|
|
||||||
serveralias: www.orsys.fr
|
|
||||||
documentroot: /var/www/html/orsys.fr
|
|
||||||
accesslog: "{{ apache_log_dir }}/access_orsys.fr_log"
|
|
||||||
errorlog: "{{ apache_log_dir }}/error_orsys.fr_log"
|
|
||||||
- servername: thomas.fr
|
|
||||||
serveralias: www.thomas.fr
|
|
||||||
documentroot: /var/www/html/thomas.fr
|
|
||||||
accesslog: "{{ apache_log_dir }}/access_thomas.fr_log"
|
|
||||||
errorlog: "{{ apache_log_dir }}/error_thomas.fr_log"
|
|
||||||
documentrootoptions: indexes
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
apache_conf_dir: /etc/httpd/conf.d/
|
|
||||||
apache_log_dir: /var/log/httpd
|
|
||||||
package_name: httpd
|
|
||||||
service_name: httpd
|
|
||||||
apache_user: apache
|
|
||||||
apache_group: apache
|
|
||||||
Reference in New Issue
Block a user