commit c4efc2c3315b20761e377cbd4745028006a95799 Author: Thomas Constans Date: Tue Sep 22 15:42:05 2020 +0200 initial commit diff --git a/Readme b/Readme new file mode 100644 index 0000000..4806bc9 --- /dev/null +++ b/Readme @@ -0,0 +1,24 @@ + +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: + + + SetHandler proxy:fcgi://localhost:9000 + + + +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. \ No newline at end of file diff --git a/apache.yml b/apache.yml new file mode 100644 index 0000000..f82b6b0 --- /dev/null +++ b/apache.yml @@ -0,0 +1,7 @@ +--- +- name: install apache via ansible playbook + hosts: test + user: ansible + become: true + roles: + - myapache4 diff --git a/myapache4/README.md b/myapache4/README.md new file mode 100644 index 0000000..f41bd0d --- /dev/null +++ b/myapache4/README.md @@ -0,0 +1,45 @@ +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 diff --git a/myapache4/defaults/main.yml b/myapache4/defaults/main.yml new file mode 100644 index 0000000..465f508 --- /dev/null +++ b/myapache4/defaults/main.yml @@ -0,0 +1,4 @@ +--- +# defaults file for myapache +http_port: 80 +use_php: false \ No newline at end of file diff --git a/myapache4/files/index.html b/myapache4/files/index.html new file mode 100644 index 0000000..416474e --- /dev/null +++ b/myapache4/files/index.html @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/myapache4/files/info.php b/myapache4/files/info.php new file mode 100644 index 0000000..1868a00 --- /dev/null +++ b/myapache4/files/info.php @@ -0,0 +1,2 @@ + + ServerName {{ vhost.servername|lower }} + ServerAlias {{ vhost.serveralias }} + DocumentRoot {{ vhost.documentroot }} + CustomLog {{ vhost.accesslog }} combined + ErrorLog {{ vhost.errorlog }} + + Options none + Allowoverride none + Require all denied + + {% if use_php %} + + SetHandler proxy:fcgi://localhost:9000 + + {% endif %} + + + Options {{ vhost.documentrootoptions|default( "none" ) }} + Require all granted + + +{% endfor %} \ No newline at end of file diff --git a/myapache4/tests/inventory b/myapache4/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/myapache4/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/myapache4/tests/test.yml b/myapache4/tests/test.yml new file mode 100644 index 0000000..797e379 --- /dev/null +++ b/myapache4/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - myapache \ No newline at end of file diff --git a/myapache4/vars/centos.yml b/myapache4/vars/centos.yml new file mode 120000 index 0000000..ba2f905 --- /dev/null +++ b/myapache4/vars/centos.yml @@ -0,0 +1 @@ +redhat.yml \ No newline at end of file diff --git a/myapache4/vars/debian.yml b/myapache4/vars/debian.yml new file mode 100644 index 0000000..03ceb9d --- /dev/null +++ b/myapache4/vars/debian.yml @@ -0,0 +1,7 @@ +--- +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 diff --git a/myapache4/vars/main.yml b/myapache4/vars/main.yml new file mode 100644 index 0000000..1fb822e --- /dev/null +++ b/myapache4/vars/main.yml @@ -0,0 +1,15 @@ +--- +# 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 \ No newline at end of file diff --git a/myapache4/vars/redhat.yml b/myapache4/vars/redhat.yml new file mode 100644 index 0000000..c77ed08 --- /dev/null +++ b/myapache4/vars/redhat.yml @@ -0,0 +1,7 @@ +--- +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