Compare commits
5 Commits
solution_a
...
solution
| Author | SHA1 | Date | |
|---|---|---|---|
| d0763aebe9 | |||
| 6e42991efa | |||
| 5123a8d280 | |||
| 8e6ed730b1 | |||
| 93ea1c3c8e |
19
0Readme.md
19
0Readme.md
@@ -1,19 +0,0 @@
|
|||||||
## Variables
|
|
||||||
|
|
||||||
|
|
||||||
*Tâche*: Utiliser des variables pour assouplir l'utilisation d'un rôle
|
|
||||||
|
|
||||||
*Condition*: quand on souhaite adapter un rôle ou un playbook à une situation différente, sans avoir à gérer une autre version du playbook.
|
|
||||||
|
|
||||||
*Norme*: En utilisant les variables
|
|
||||||
|
|
||||||
### Pratique:
|
|
||||||
|
|
||||||
Reprendre le rôle récupéré depuis ansible-galaxy, constater ses lacunes
|
|
||||||
|
|
||||||
Les corriger une fois qu'elles ont été identifiées.
|
|
||||||
|
|
||||||
### Performance
|
|
||||||
|
|
||||||
Il est désormais facile d'adapter le rôle pour qu'il traite un autre site que www.orsys.fr
|
|
||||||
|
|
||||||
@@ -14,6 +14,15 @@ None
|
|||||||
Role Variables
|
Role Variables
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
apache_server_name - nom du site
|
||||||
|
|
||||||
|
apache_service_name - nom du service
|
||||||
|
apache_package_name - nom du package
|
||||||
|
apache_config_dir - répertoire de config
|
||||||
|
apache_group_name - nom du groupe apache
|
||||||
|
#apache_listen_port - port d'écoute - defaut 80
|
||||||
|
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
|
#/home/formation/ansible_apache_formation/defaults/main.yml
|
||||||
---
|
---
|
||||||
|
apache_listen_port: 80
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
- name: reload httpd
|
---
|
||||||
service:
|
- name: reload httpd
|
||||||
name: "{{ apache_service_name }}"
|
service:
|
||||||
state: reloaded
|
name: "{{ apache_service_name }}"
|
||||||
|
state: reloaded
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
- name: import OS variables
|
||||||
|
include_vars: "{{ ansible_distribution |lower }}{{ ansible_distribution_major_version }}.yml"
|
||||||
|
|
||||||
- name: installation
|
- name: installation
|
||||||
package:
|
package:
|
||||||
name: "{{ apache_package_name }}"
|
name: "{{ apache_package_name }}"
|
||||||
@@ -8,10 +11,10 @@
|
|||||||
notify: reload httpd
|
notify: reload httpd
|
||||||
template:
|
template:
|
||||||
src: vhost.conf
|
src: vhost.conf
|
||||||
dest: /etc/httpd/conf.d/vhost.conf
|
dest: "{{ apache_config_dir }}/vhost.conf"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
owner: root
|
owner: root
|
||||||
group: apache
|
group: "{{ apache_group_name }}"
|
||||||
|
|
||||||
- name: enable service
|
- name: enable service
|
||||||
service:
|
service:
|
||||||
@@ -28,30 +31,30 @@
|
|||||||
|
|
||||||
- name: create documentroot
|
- name: create documentroot
|
||||||
file:
|
file:
|
||||||
name: "{{ apache_documentroot }}"
|
name: "/var/www/{{ apache_server_name }}"
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: create index file
|
- name: create index file
|
||||||
template:
|
template:
|
||||||
src: index.html
|
src: index.html
|
||||||
dest: "{{ apache_documentroot }}/index.html"
|
dest: "/var/www/{{ apache_server_name }}/index.html"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
||||||
- name: install python passlib package
|
- name: install python passlib package
|
||||||
package:
|
package:
|
||||||
name: python-passlib
|
name: "{{ python_passlib_package }}"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: passwd file
|
- name: passwd file
|
||||||
htpasswd:
|
htpasswd:
|
||||||
path: "/etc/httpd/passwd"
|
path: "{{ apache_config_dir }}/passwd"
|
||||||
name: tom
|
name: tom
|
||||||
password: "123Soleil"
|
password: "123Soleil"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
owner: root
|
owner: root
|
||||||
group: "apache"
|
group: "{{ apache_group_name }}"
|
||||||
|
|
||||||
- name: start service
|
- name: start service
|
||||||
service:
|
service:
|
||||||
name: "{{ apache_service_name }}"
|
name: "{{ apache_service_name }}"
|
||||||
state: restarted
|
state: started
|
||||||
@@ -1,24 +1,23 @@
|
|||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerName {{ apache_server_name }}
|
ServerName {{ apache_server_name }}"
|
||||||
ServerAlias www.{{ apache_server_name }}
|
ServerAlias www.{{ apache_server_name }}"
|
||||||
ServerAlias {{ inventory_hostname }}
|
DocumentRoot /var/www/{{ apache_server_name }}"
|
||||||
DocumentRoot /var/www/html/{{ apache_server_name }}
|
CustomLog /var/log/{{ apache_service_name }}/{{ apache_server_name }}"_access.log combined
|
||||||
CustomLog /var/log/httpd/{{ apache_server_name }}_access.log combined
|
ErrorLog /var/log/{{ apache_service_name }}/{{ apache_server_name }}"_error.log
|
||||||
ErrorLog /var/log/httpd/{{ apache_server_name }}_error.log
|
|
||||||
<Directory />
|
<Directory />
|
||||||
Options none
|
Options none
|
||||||
Allowoverride none
|
Allowoverride none
|
||||||
Require all denied
|
Require all denied
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory {{ apache_documentroot }}>
|
<Directory /var/www/{{ apache_server_name }}">
|
||||||
Require all granted
|
Require all granted
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory {{ apache_documentroot }}/Private>
|
<Directory /var/www/{{ apache_server_name }}"/Private>
|
||||||
Options indexes
|
Options indexes
|
||||||
AuthName "stop"
|
AuthName "stop"
|
||||||
AuthType Basic
|
AuthType Basic
|
||||||
AuthUserFile /etc/httpd/passwd
|
AuthUserFile {{ apache_config_dir }}/passwd
|
||||||
require valid-user
|
require valid-user
|
||||||
</Directory>
|
</Directory>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
6
ansible_apache_formation/vars/almalinux9.yml
Normal file
6
ansible_apache_formation/vars/almalinux9.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#/home/formation/ansible_apache_formation/vars/centos8.yml
|
||||||
|
python_passlib_package: python3-passlib
|
||||||
|
apache_service_name: httpd
|
||||||
|
apache_package_name: httpd
|
||||||
|
apache_config_dir: /etc/httpd/conf.d
|
||||||
|
apache_group_name: apache
|
||||||
1
ansible_apache_formation/vars/centos7.yml
Normal file
1
ansible_apache_formation/vars/centos7.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
python_passlib_package: python-passlib
|
||||||
6
ansible_apache_formation/vars/centos8.yml
Normal file
6
ansible_apache_formation/vars/centos8.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#/home/formation/ansible_apache_formation/vars/centos8.yml
|
||||||
|
python_passlib_package: python3-passlib
|
||||||
|
apache_service_name: httpd
|
||||||
|
apache_package_name: httpd
|
||||||
|
apache_config_dir: /etc/httpd/conf.d
|
||||||
|
apache_group_name: apache
|
||||||
7
ansible_apache_formation/vars/debian10.yml
Normal file
7
ansible_apache_formation/vars/debian10.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#/home/formation/ansible_apache_formation/vars/debian10.yml
|
||||||
|
python_passlib_package: python3-passlib
|
||||||
|
apache_service_name: apache2
|
||||||
|
apache_package_name: apache2
|
||||||
|
apache_config_dir: /etc/apache2/sites-enabled
|
||||||
|
apache_group_name: www-data
|
||||||
|
|
||||||
4
apache.yml
Normal file
4
apache.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- hosts: cibles
|
||||||
|
role:
|
||||||
|
- ansible_apache_formation
|
||||||
2
host_vars/centos1.formation.opendoor.fr.yml
Normal file
2
host_vars/centos1.formation.opendoor.fr.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
apache_server_name: orsys.fr
|
||||||
|
apache_documentroot: /srv/www/orsys.fr
|
||||||
Reference in New Issue
Block a user