simplification et mise au point
This commit is contained in:
31
apache.yml
31
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
|
||||
24
vhost.conf
Normal file
24
vhost.conf
Normal file
@@ -0,0 +1,24 @@
|
||||
<VirtualHost *:80>
|
||||
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
|
||||
<Directory />
|
||||
Options none
|
||||
Allowoverride none
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /var/www/html/example.org>
|
||||
Require all granted
|
||||
</Directory>
|
||||
<Directory /var/www/html/example.org/Private>
|
||||
Options indexes
|
||||
AuthName "stop"
|
||||
AuthType Basic
|
||||
AuthUserFile /etc/httpd/passwd
|
||||
require valid-user
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
Reference in New Issue
Block a user