10 Commits

Author SHA1 Message Date
737e8a4861 remove unused file 2025-02-14 09:14:12 +01:00
1b29887d41 cleanup 2021-11-30 10:57:43 +01:00
c99e80e5cf Merge branch 'apache_solution' into solution 2021-11-30 10:57:10 +01:00
d5ffc62bca mise au point 2021-11-30 10:55:41 +01:00
b6e736e264 solution apache 2021-11-30 10:51:49 +01:00
7c7e0658fc back to apache 2021-11-30 10:46:03 +01:00
a41ee487a4 rename readme 2021-11-16 09:35:03 +01:00
719dd8618b rajout gestion fichier 2021-06-10 13:59:38 +02:00
a1e2666e83 solution tp dependances 2021-04-20 14:04:37 +02:00
7720a58487 solution 2021-04-20 11:08:36 +02:00
20 changed files with 115 additions and 133 deletions

View File

@@ -1,6 +1,6 @@
## Rôles ## Rôles
**Tâche**: Écrire / Convertir un rôle **Tâche**: Écrire 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,7 +8,13 @@
## Pratique: ## Pratique:
Convertir en un rôle nommé "sib.apache" le playbook apache.yml". Convertir en un rôle nommé "apache" le 1er playbook mis au point lors de l'atelier "handlers".
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

View File

@@ -1,5 +1,5 @@
--- ---
- hosts: centos - hosts: centos
name: install apache name: install apache from role
roles: roles:
- sib.apache - tco.apache

View File

@@ -1,38 +0,0 @@
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).

View File

@@ -1,2 +0,0 @@
---
# defaults file for sib.apache

View File

@@ -1,6 +0,0 @@
---
# handlers file for sib.apache
- name: restart httpd
service:
name: httpd
state: restarted

View File

@@ -1,55 +0,0 @@
---
# 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

View File

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

View File

@@ -1,24 +0,0 @@
<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>

View File

@@ -1,2 +0,0 @@
---
# vars file for sib.apache

38
tco.apache/README.md Normal file
View File

@@ -0,0 +1,38 @@
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>

View File

@@ -0,0 +1,2 @@
---
# defaults file for tco.apache

View File

@@ -0,0 +1,6 @@
---
# handlers file for tco
- name: restart apache
service:
name: httpd
state: restarted

39
tco.apache/tasks/main.yml Normal file
View File

@@ -0,0 +1,39 @@
---
- 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

View File

@@ -0,0 +1 @@
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>

View File

@@ -0,0 +1,16 @@
<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>

View File

@@ -2,4 +2,4 @@
- hosts: localhost - hosts: localhost
remote_user: root remote_user: root
roles: roles:
- sib.apache - tco.apache

2
tco.apache/vars/main.yml Normal file
View File

@@ -0,0 +1,2 @@
---
# vars file for tco.apache