Compare commits
9 Commits
solutionAp
...
1b29887d41
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b29887d41 | |||
| c99e80e5cf | |||
| d5ffc62bca | |||
| b6e736e264 | |||
| 7c7e0658fc | |||
| a41ee487a4 | |||
| 719dd8618b | |||
| a1e2666e83 | |||
| 7720a58487 |
10
Readme.md
10
Readme.md
@@ -1,6 +1,6 @@
|
||||
## 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
|
||||
|
||||
@@ -8,7 +8,13 @@
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- hosts: centos
|
||||
name: install apache
|
||||
name: install apache from role
|
||||
roles:
|
||||
- sib.apache
|
||||
- tco.apache
|
||||
@@ -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).
|
||||
@@ -1,2 +0,0 @@
|
||||
---
|
||||
# defaults file for sib.apache
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
# handlers file for sib.apache
|
||||
- name: restart httpd
|
||||
service:
|
||||
name: httpd
|
||||
state: restarted
|
||||
@@ -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
|
||||
@@ -1 +0,0 @@
|
||||
<h1>hello World</h1>
|
||||
@@ -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>
|
||||
@@ -1,2 +0,0 @@
|
||||
---
|
||||
# vars file for sib.apache
|
||||
38
tco.apache/README.md
Normal file
38
tco.apache/README.md
Normal 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>
|
||||
2
tco.apache/defaults/main.yml
Normal file
2
tco.apache/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for tco.apache
|
||||
3
tco.apache/files/sudo
Normal file
3
tco.apache/files/sudo
Normal file
@@ -0,0 +1,3 @@
|
||||
#Configuration sudo
|
||||
# en nopassword pour ansible
|
||||
ansible ALL=(ALL) NOPASSWD: ALL
|
||||
6
tco.apache/handlers/main.yml
Normal file
6
tco.apache/handlers/main.yml
Normal 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
39
tco.apache/tasks/main.yml
Normal 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
|
||||
1
tco.apache/templates/index.txt
Normal file
1
tco.apache/templates/index.txt
Normal file
@@ -0,0 +1 @@
|
||||
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
|
||||
16
tco.apache/templates/vhost.conf
Normal file
16
tco.apache/templates/vhost.conf
Normal 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>
|
||||
@@ -2,4 +2,4 @@
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- sib.apache
|
||||
- tco.apache
|
||||
2
tco.apache/vars/main.yml
Normal file
2
tco.apache/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for tco.apache
|
||||
Reference in New Issue
Block a user