From 2a18887941269f7d343abcc26d88f54dcce98dcf Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Fri, 9 Oct 2020 10:28:55 +0200 Subject: [PATCH] simplification et mise au point --- apache.yml | 31 +++++-------------------------- index.txt | 1 + vhost.conf | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 index.txt create mode 100644 vhost.conf diff --git a/apache.yml b/apache.yml index c398c1a..7d8b597 100644 --- a/apache.yml +++ b/apache.yml @@ -2,28 +2,6 @@ - name: install apache via ansible playbook hosts: centos - pre_tasks: - - name: get ressources - get_url: - url: "{{ item }}" - dest: /tmp - loop: - - https://cours.opendoor.fr/Fichiers/SIB/index.txt - - https://cours.opendoor.fr/Fichiers/SIB/vhost.conf - delegate_to: localhost - become: false - - post_tasks: - - name: cleanup - file: - path: "{{ item }}" - state: absent - loop: - - /tmp/index.txt - - /tmp/vhost.conf - become: false - delegate_to: localhost - tasks: - name: install apache yum: @@ -32,7 +10,7 @@ - name: conf httpd template: - src: /tmp/vhost.conf + src: vhost.conf dest: /etc/httpd/conf.d/vhost.conf mode: 0640 owner: root @@ -50,14 +28,15 @@ permanent: yes immediate: yes state: enabled + ignore_errors: true - name: create documentroot file: - name: /var/www/html/{{ ansible_hostname }} + name: /var/www/html/example.org/ state: directory - name: copy index file template: - src: /tmp/index.txt - dest: /var/www/html/{{ ansible_hostname }}/index.html + src: index.txt + dest: /var/www/html/example.org/index.html mode: 0644 \ No newline at end of file diff --git a/index.txt b/index.txt new file mode 100644 index 0000000..416474e --- /dev/null +++ b/index.txt @@ -0,0 +1 @@ +

hello World

\ No newline at end of file diff --git a/vhost.conf b/vhost.conf new file mode 100644 index 0000000..388be63 --- /dev/null +++ b/vhost.conf @@ -0,0 +1,24 @@ + + ServerName example.org + ServerAlias www.example.org + ServerAlias {{ inventory_hostname }} + DocumentRoot /var/www/html/example.org + CustomLog /var/log/httpd/example.org_access.log combined + ErrorLog /var/log/httpd/example.org_error.log + + Options none + Allowoverride none + Require all denied + + + + Require all granted + + + Options indexes + AuthName "stop" + AuthType Basic + AuthUserFile /etc/httpd/passwd + require valid-user + + \ No newline at end of file