Compare commits
3 Commits
apache_sol
...
solutionAp
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ecd8acbd2 | |||
| fd95cee4b4 | |||
| f4420ee8e5 |
10
Readme.md
10
Readme.md
@@ -1,6 +1,6 @@
|
|||||||
## Rôles
|
## Rôles
|
||||||
|
|
||||||
**Tâche**: Écrire un rôle
|
**Tâche**: Écrire / Convertir un rôle
|
||||||
|
|
||||||
**Condition**: pour améliorer l'organisation et la maintenance de nos playbooks
|
**Condition**: pour améliorer l'organisation et la maintenance de nos playbooks
|
||||||
|
|
||||||
@@ -8,13 +8,7 @@
|
|||||||
|
|
||||||
## Pratique:
|
## Pratique:
|
||||||
|
|
||||||
Convertir en un rôle nommé "apache" le 1er playbook mis au point lors de l'atelier "handlers".
|
Convertir en un rôle nommé "sib.apache" le playbook apache.yml".
|
||||||
|
|
||||||
Vous pouvez récupérer ce playbook via la commande:
|
|
||||||
```bash
|
|
||||||
git clone -b solution https://infra.opendoor.fr/git/tom/sib_12_handlers
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
- hosts: centos
|
- hosts: centos
|
||||||
name: install apache from role
|
name: install apache
|
||||||
roles:
|
roles:
|
||||||
- tco.apache
|
- sib.apache
|
||||||
38
sib.apache/README.md
Normal file
38
sib.apache/README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
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:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
2
sib.apache/defaults/main.yml
Normal file
2
sib.apache/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# defaults file for sib.apache
|
||||||
6
sib.apache/handlers/main.yml
Normal file
6
sib.apache/handlers/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# handlers file for sib.apache
|
||||||
|
- name: restart httpd
|
||||||
|
service:
|
||||||
|
name: httpd
|
||||||
|
state: restarted
|
||||||
55
sib.apache/tasks/main.yml
Normal file
55
sib.apache/tasks/main.yml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
# tasks file for sib.apache
|
||||||
|
- name: install apache
|
||||||
|
yum:
|
||||||
|
name: httpd
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: conf httpd
|
||||||
|
template:
|
||||||
|
src: vhost.conf
|
||||||
|
dest: /etc/httpd/conf.d/vhost.conf
|
||||||
|
mode: 0640
|
||||||
|
owner: root
|
||||||
|
group: apache
|
||||||
|
notify: restart httpd
|
||||||
|
|
||||||
|
- name: activate apache
|
||||||
|
service:
|
||||||
|
name: httpd
|
||||||
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: setup firewall
|
||||||
|
block:
|
||||||
|
- name: install firewalld packages
|
||||||
|
yum:
|
||||||
|
name:
|
||||||
|
- python3-firewall
|
||||||
|
- firewalld
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: enable firewalld service
|
||||||
|
service:
|
||||||
|
name: firewalld
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: open firewall port
|
||||||
|
firewalld:
|
||||||
|
service: http
|
||||||
|
permanent: yes
|
||||||
|
immediate: yes
|
||||||
|
state: enabled
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: create documentroot
|
||||||
|
file:
|
||||||
|
name: /var/www/html/example.org/
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: copy index file
|
||||||
|
template:
|
||||||
|
src: index.txt
|
||||||
|
dest: /var/www/html/example.org/index.html
|
||||||
|
mode: 0644
|
||||||
1
sib.apache/templates/index.txt
Normal file
1
sib.apache/templates/index.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<h1>hello World</h1>
|
||||||
24
sib.apache/templates/vhost.conf
Normal file
24
sib.apache/templates/vhost.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName example.fr
|
||||||
|
ServerAlias www.example.fr
|
||||||
|
ServerAlias {{ inventory_hostname }}
|
||||||
|
DocumentRoot /var/www/html/example.fr
|
||||||
|
CustomLog /var/log/httpd/example.fr_access.log combined
|
||||||
|
ErrorLog /var/log/httpd/example.fr_error.log
|
||||||
|
<Directory />
|
||||||
|
Options none
|
||||||
|
Allowoverride none
|
||||||
|
Require all denied
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory /var/www/html/example.fr>
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
<Directory /var/www/html/example.fr/Private>
|
||||||
|
Options indexes
|
||||||
|
AuthName "stop"
|
||||||
|
AuthType Basic
|
||||||
|
AuthUserFile /etc/httpd/passwd
|
||||||
|
require valid-user
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
remote_user: root
|
remote_user: root
|
||||||
roles:
|
roles:
|
||||||
- tco.apache
|
- sib.apache
|
||||||
2
sib.apache/vars/main.yml
Normal file
2
sib.apache/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for sib.apache
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
Role Name
|
|
||||||
=========
|
|
||||||
|
|
||||||
Install apache
|
|
||||||
|
|
||||||
Requirements
|
|
||||||
------------
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Role Variables
|
|
||||||
--------------
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
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: centos
|
|
||||||
roles:
|
|
||||||
- tco.apache
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
BSD
|
|
||||||
|
|
||||||
Author Information
|
|
||||||
------------------
|
|
||||||
|
|
||||||
Thomas C <thomas@opendoor.fr>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# defaults file for tco.apache
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
# handlers file for tco
|
|
||||||
- name: restart apache
|
|
||||||
service:
|
|
||||||
name: httpd
|
|
||||||
state: restarted
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install apache
|
|
||||||
yum:
|
|
||||||
name: httpd
|
|
||||||
state: latest
|
|
||||||
|
|
||||||
- name: conf httpd
|
|
||||||
template:
|
|
||||||
src: vhost.conf
|
|
||||||
dest: /etc/httpd/conf.d/vhost.conf
|
|
||||||
mode: 0640
|
|
||||||
owner: root
|
|
||||||
group: apache
|
|
||||||
notify: restart apache
|
|
||||||
|
|
||||||
- name: activate apache
|
|
||||||
service:
|
|
||||||
name: httpd
|
|
||||||
enabled: yes
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: open firewall port
|
|
||||||
firewalld:
|
|
||||||
service: http
|
|
||||||
permanent: yes
|
|
||||||
immediate: yes
|
|
||||||
state: enabled
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: create documentroot
|
|
||||||
file:
|
|
||||||
name: /var/www/html/orsys.fr
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: create index file
|
|
||||||
template:
|
|
||||||
src: index.txt
|
|
||||||
dest: /var/www/html/orsys.fr/index.html
|
|
||||||
mode: 0644
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<VirtualHost *:80>
|
|
||||||
ServerName orsys.fr
|
|
||||||
ServerAlias www.orsys.fr
|
|
||||||
DocumentRoot /var/www/html/orsys.fr/
|
|
||||||
CustomLog /var/log/httpd/orsys.fr_access.log combined
|
|
||||||
ErrorLog /var/log/httpd/orsys.fr_error.log
|
|
||||||
<Directory />
|
|
||||||
Options none
|
|
||||||
Allowoverride none
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /var/www/html/orsys.fr>
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for tco.apache
|
|
||||||
Reference in New Issue
Block a user