simplification et mise au point

This commit is contained in:
2020-10-09 10:28:55 +02:00
parent 7c639fb85d
commit 2a18887941
3 changed files with 30 additions and 26 deletions

View File

@@ -2,28 +2,6 @@
- name: install apache via ansible playbook - name: install apache via ansible playbook
hosts: centos 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: tasks:
- name: install apache - name: install apache
yum: yum:
@@ -32,7 +10,7 @@
- name: conf httpd - name: conf httpd
template: template:
src: /tmp/vhost.conf src: vhost.conf
dest: /etc/httpd/conf.d/vhost.conf dest: /etc/httpd/conf.d/vhost.conf
mode: 0640 mode: 0640
owner: root owner: root
@@ -50,14 +28,15 @@
permanent: yes permanent: yes
immediate: yes immediate: yes
state: enabled state: enabled
ignore_errors: true
- name: create documentroot - name: create documentroot
file: file:
name: /var/www/html/{{ ansible_hostname }} name: /var/www/html/example.org/
state: directory state: directory
- name: copy index file - name: copy index file
template: template:
src: /tmp/index.txt src: index.txt
dest: /var/www/html/{{ ansible_hostname }}/index.html dest: /var/www/html/example.org/index.html
mode: 0644 mode: 0644

1
index.txt Normal file
View File

@@ -0,0 +1 @@
<h1>hello World</h1>

24
vhost.conf Normal file
View 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>