Compare commits
10 Commits
836d079a0a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c6eab7b09a | |||
| b365759be6 | |||
| 211b7d5725 | |||
| c9a161e215 | |||
| d91a5e97fd | |||
| 67626a455b | |||
| d8b0c86d3d | |||
| 4194486224 | |||
| c4b221354b | |||
| 7ebd1be9fd |
10
README.md
Normal file
10
README.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Mise en place du serveur pédagogique pour la SNT
|
||||||
|
|
||||||
|
Avec une Debian ou une Ubuntu serveur toute fraiche, installer git et ansible
|
||||||
|
|
||||||
|
apt install git ansible
|
||||||
|
|
||||||
|
Cloner le dépot puis
|
||||||
|
|
||||||
|
cd serveur_lycee
|
||||||
|
ansible-playbook localhost.yml
|
||||||
@@ -1 +1,14 @@
|
|||||||
<h1> Serveur pédagogique pour {{ name }} </h1>
|
<!DOCTYPE html>
|
||||||
|
<html lang=fr>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="Author" content="B.Bertrand">
|
||||||
|
<title>{{ item }}</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1> Serveur pédagogique pour {{ item }} </h1>
|
||||||
|
<!-- corps: tout ce que l'on veut afficher doit être mis entre ces balises -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
22
files/root_index.html.j2
Normal file
22
files/root_index.html.j2
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang=fr>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="Author" content="B.Bertrand">
|
||||||
|
<title>{{ item }}</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1> Serveur pédagogique pour {{ matiere }} </h1>
|
||||||
|
<!-- corps: tout ce que l'on veut afficher doit être mis entre ces balises -->
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{% for user in peda %}
|
||||||
|
<li>
|
||||||
|
<a href="./~{{ user }}">{{ user }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor%}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<IfModule mod_userdir.c>
|
|
||||||
UserDir public_html
|
|
||||||
UserDir disabled root
|
|
||||||
|
|
||||||
<Directory /home/*/public_html>
|
|
||||||
AllowOverride All
|
|
||||||
Options MultiViews Indexes SymLinksIfOwnerMatch
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
</IfModule>
|
|
||||||
11
files/vsftpd.conf.j2
Normal file
11
files/vsftpd.conf.j2
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
listen=YES
|
||||||
|
listen_ipv6=NO
|
||||||
|
|
||||||
|
anonymous_enable=NO
|
||||||
|
local_enable=YES
|
||||||
|
write_enable=YES
|
||||||
|
chroot_local_user=YES
|
||||||
|
allow_writeable_chroot=YES
|
||||||
|
secure_chroot_dir=/var/run/vsftpd/empty
|
||||||
|
|
||||||
|
pam_service_name=vsftpd
|
||||||
5
home
Normal file
5
home
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[nsi]
|
||||||
|
192.168.2.146 ansible_user=debian
|
||||||
|
|
||||||
|
[snt]
|
||||||
|
ansible ansible_user=debian
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
---
|
---
|
||||||
- hosts: 127.0.0.1
|
- hosts: all
|
||||||
connection: local
|
#ask_pass: true
|
||||||
become: true
|
become: true
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/default.yml
|
- vars/default.yml
|
||||||
|
- vars/accounts.yml
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- include: tasks/lamp.yml
|
#- include: tasks/lamp.yml
|
||||||
- include: tasks/userdir.yml
|
- include: tasks/accounts.yml
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: Reload Apache
|
- name: Reload Apache
|
||||||
|
|||||||
5
lycee
Normal file
5
lycee
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[stex]
|
||||||
|
stex.ovh ansible_port=25022 ansible_user=root
|
||||||
|
|
||||||
|
[home]
|
||||||
|
192.168.2.146 ansible_user=debian
|
||||||
34
lycee.yml
Normal file
34
lycee.yml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- hosts: snt
|
||||||
|
#ask_pass: true
|
||||||
|
become: true
|
||||||
|
vars_files:
|
||||||
|
- vars/default.yml
|
||||||
|
- vars/snt_accounts.yml
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Update
|
||||||
|
apt:
|
||||||
|
update_cache: true
|
||||||
|
upgrade: true
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- include: tasks/lamp.yml
|
||||||
|
- include: tasks/ftp.yml
|
||||||
|
- include: tasks/accounts.yml
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Reload Apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: reloaded
|
||||||
|
|
||||||
|
- name: Restart Apache
|
||||||
|
service:
|
||||||
|
name: apache2
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: Reload vsftpd
|
||||||
|
service:
|
||||||
|
name: vsftpd
|
||||||
|
state: reload
|
||||||
42
tasks/accounts.yml
Normal file
42
tasks/accounts.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
- name: add users
|
||||||
|
user:
|
||||||
|
name: "{{ item }}"
|
||||||
|
create_home: true
|
||||||
|
password: "{{ lookup('password', './pass/' + item + '_pass length=10 chars=ascii_letters') | password_hash('sha512') }}"
|
||||||
|
update_password: on_create
|
||||||
|
with_items: "{{ users }}"
|
||||||
|
register: returned
|
||||||
|
|
||||||
|
- name: create public_html
|
||||||
|
file:
|
||||||
|
path: "/home/{{ item}}/public_html/"
|
||||||
|
owner: "{{ item }}"
|
||||||
|
group: www-data
|
||||||
|
state: directory
|
||||||
|
with_items: "{{ users }}"
|
||||||
|
|
||||||
|
- name: Sets Up Index page
|
||||||
|
template:
|
||||||
|
src: "files/index.html.j2"
|
||||||
|
dest: "/home/{{ item }}/public_html/index.html"
|
||||||
|
mode: 774
|
||||||
|
with_items: "{{ users }}"
|
||||||
|
|
||||||
|
- name: create database
|
||||||
|
mysql_db:
|
||||||
|
db: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
login_user: root
|
||||||
|
login_password: "{{ mysql_root_password }}"
|
||||||
|
with_items: "{{ users }}"
|
||||||
|
|
||||||
|
- name: create db user
|
||||||
|
mysql_user:
|
||||||
|
user: "{{ item }}"
|
||||||
|
password: "{{ lookup('password', './pass/' + item + '_sql length=10 chars=ascii_letters') | password_hash('sha512') }}"
|
||||||
|
priv: "{{ item + '.*:ALL,GRANT' }}"
|
||||||
|
login_user: root
|
||||||
|
login_password: "{{ mysql_root_password }}"
|
||||||
|
state: present
|
||||||
|
with_items: "{{ users }}"
|
||||||
19
tasks/ftp.yml
Normal file
19
tasks/ftp.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: Install vsftpd Packages
|
||||||
|
apt:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: latest
|
||||||
|
loop:
|
||||||
|
- 'vsftpd'
|
||||||
|
|
||||||
|
- name: Set up vsftpd conf
|
||||||
|
template:
|
||||||
|
src: "files/vsftpd.conf.j2"
|
||||||
|
dest: "/etc/vsftpd.conf"
|
||||||
|
notify: Reload vsftpd
|
||||||
|
|
||||||
|
- name: Start vsftpd service
|
||||||
|
service:
|
||||||
|
name: vsftpd
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
---
|
---
|
||||||
- name: Install prerequisites
|
|
||||||
apt: name={{ item }} update_cache=yes state=latest force_apt_get=yes
|
|
||||||
loop: [ 'aptitude' ]
|
|
||||||
|
|
||||||
#Apache Configuration
|
#Apache Configuration
|
||||||
- name: Install LAMP Packages
|
- name: Install LAMP Packages
|
||||||
apt: name={{ item }} update_cache=yes state=latest
|
apt: name={{ item }} update_cache=yes state=latest
|
||||||
loop: [ 'apache2', 'mysql-server', 'python3-pymysql', 'php', 'php-mysql', 'libapache2-mod-php' ]
|
loop:
|
||||||
|
- 'apache2'
|
||||||
|
- 'mariadb-server'
|
||||||
|
- 'python3-pymysql'
|
||||||
|
- 'php'
|
||||||
|
- 'php-mysql'
|
||||||
|
- 'libapache2-mod-php'
|
||||||
|
|
||||||
- name: Create document root
|
- name: Create document root
|
||||||
file:
|
file:
|
||||||
@@ -30,12 +32,18 @@
|
|||||||
when: disable_default
|
when: disable_default
|
||||||
notify: Reload Apache
|
notify: Reload Apache
|
||||||
|
|
||||||
# MySQL Configuration
|
# MySQL Configuration
|
||||||
|
- name: Start MariaDB service
|
||||||
|
service:
|
||||||
|
name: mariadb
|
||||||
|
state: started
|
||||||
|
|
||||||
- name: Sets the root password
|
- name: Sets the root password
|
||||||
mysql_user:
|
mysql_user:
|
||||||
name: root
|
name: root
|
||||||
password: "{{ mysql_root_password }}"
|
password: "{{ mysql_root_password }}"
|
||||||
login_unix_socket: /var/run/mysqld/mysqld.sock
|
login_unix_socket: /var/run/mysqld/mysqld.sock
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: Removes all anonymous user accounts
|
- name: Removes all anonymous user accounts
|
||||||
mysql_user:
|
mysql_user:
|
||||||
@@ -52,12 +60,6 @@
|
|||||||
login_user: root
|
login_user: root
|
||||||
login_password: "{{ mysql_root_password }}"
|
login_password: "{{ mysql_root_password }}"
|
||||||
|
|
||||||
- name: "UFW - Allow HTTP on port {{ http_port }}"
|
|
||||||
ufw:
|
|
||||||
rule: allow
|
|
||||||
port: "{{ http_port }}"
|
|
||||||
proto: tcp
|
|
||||||
|
|
||||||
- name: Sets Up PHP Info Page
|
- name: Sets Up PHP Info Page
|
||||||
template:
|
template:
|
||||||
src: "files/info.php.j2"
|
src: "files/info.php.j2"
|
||||||
@@ -65,8 +67,13 @@
|
|||||||
|
|
||||||
- name: Sets Up Index page
|
- name: Sets Up Index page
|
||||||
template:
|
template:
|
||||||
src: "files/index.html.j2"
|
src: "files/root_index.html.j2"
|
||||||
dest: "/var/www/{{ http_host }}/info.php"
|
dest: "/var/www/{{ http_host }}/index.html"
|
||||||
vars:
|
vars:
|
||||||
name: "la SNT"
|
item:
|
||||||
|
- "{{ matiere }}"
|
||||||
|
|
||||||
|
- name: Enable userdir
|
||||||
|
shell: /usr/sbin/a2enmod userdir
|
||||||
|
notify: Reload Apache
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Enable userdir
|
|
||||||
shell: /usr/sbin/a2enmod userdir
|
|
||||||
notify: Reload Apache
|
|
||||||
|
|
||||||
- name: Set up userdir virtualhost
|
|
||||||
template:
|
|
||||||
src: "files/userdir.conf.j2"
|
|
||||||
dest: "/etc/apache2/mods-enabled/userdir.conf"
|
|
||||||
notify: Reload Apache
|
|
||||||
|
|
||||||
4
vars/accounts.yml
Normal file
4
vars/accounts.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
users:
|
||||||
|
- name: test1
|
||||||
|
- name: test2
|
||||||
14
vars/snt_accounts.yml
Normal file
14
vars/snt_accounts.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
matiere: "SNT"
|
||||||
|
peda:
|
||||||
|
- "2GTG1"
|
||||||
|
- "2GTG2"
|
||||||
|
- "2GTG3"
|
||||||
|
- "2GTG4"
|
||||||
|
- "2GTG5"
|
||||||
|
- "2GTG6"
|
||||||
|
- "2GTG8"
|
||||||
|
- "2GTG9"
|
||||||
|
profs:
|
||||||
|
- "proftest"
|
||||||
|
users: "{{ peda + profs }}"
|
||||||
Reference in New Issue
Block a user