Compare commits
17 Commits
c4065559fc
...
master
Author | SHA1 | Date | |
---|---|---|---|
ff7644a32a | |||
5dff08c44d | |||
5aff69a05a | |||
9dc73bf077 | |||
cf2b702eb5 | |||
23d03f8ba0 | |||
5ed8b36c28 | |||
3cd5d20de6 | |||
2685f7bb11 | |||
f0270a56ec | |||
0f5412ea8b | |||
5fb573f447 | |||
5b2f572453 | |||
958a6225b1 | |||
41e7591163 | |||
4117afd993 | |||
c7e438d4ee |
27
README.md
27
README.md
@ -1,7 +1,6 @@
|
|||||||
# kaz-vagrant
|
# kaz-vagrant
|
||||||
|
|
||||||
[Kaz](https://kaz.bzh/) est un CHATONS du Morbihan. Nous proposons ici un moyen de le répliquer dans une VM. Il y a des éléments de configuration à définir avant d'initialiser ce simulateur.
|
[Kaz](https://kaz.bzh/) est un CHATONS du Morbihan. Nous proposons ici un moyen de le répliquer dans une VM. Il y a des éléments de configuration à définir avant d'initialiser ce simulateur.
|
||||||
|
|
||||||
Le principe est de faire fonctionner un simulateur de notre CHATONS dans une VirtualBox pour mettre au point nos différents services.
|
Le principe est de faire fonctionner un simulateur de notre CHATONS dans une VirtualBox pour mettre au point nos différents services.
|
||||||
|
|
||||||
Nous utilisons :
|
Nous utilisons :
|
||||||
@ -11,7 +10,7 @@ Nous utilisons :
|
|||||||
* LXC pour faire tourner ces services dans des conteneurs distincts (ie, kaz-prod est un conteneur LXC)
|
* LXC pour faire tourner ces services dans des conteneurs distincts (ie, kaz-prod est un conteneur LXC)
|
||||||
* Docker pour chaque service de notre serveur
|
* Docker pour chaque service de notre serveur
|
||||||
|
|
||||||
À la fin, nous obtenons une maquette d'un petit internet simulé, avec du DNS, des mails tiers, et notre serveur kaz-prod dans un coin.
|
À la fin, nous obtenons une maquette d'un petit internet simulé, avec du DNS, des mails tiers, et nos serveurs hoster-a-kaz1 et hoster-b-kaz2 dans un coin.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -36,7 +35,7 @@ cd kaz-vagrant/
|
|||||||
vagrant up
|
vagrant up
|
||||||
```
|
```
|
||||||
|
|
||||||
Cette étape peut-être (très) longue. Notamment, la construction de kaz-prod se fait dans un conteneur LXC, dans lequel les overlays docker passent par un filesystem plus lent qu'en natif... Comptez entre 40 minutes et quelques heures, selon la connexion réseau et les performances de la machine.
|
Cette étape peut-être (très) longue, notamment la construction des machines Kaz... Comptez entre 40 minutes et quelques heures, selon la connexion réseau et les performances de la machine.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -46,15 +45,18 @@ Les utilisateurs créés sont
|
|||||||
* debian/debian
|
* debian/debian
|
||||||
* root/root.
|
* root/root.
|
||||||
|
|
||||||
|
Se connecter en root/root
|
||||||
|
|
||||||
Lors du démarrage de la VM, il faut lancer SNSTER :
|
Lors du démarrage de la VM, il faut lancer SNSTER :
|
||||||
```bash
|
```bash
|
||||||
cd /root/snster-kaz
|
cd /root/snster-kaz
|
||||||
snster start
|
snster start
|
||||||
```
|
```
|
||||||
|
|
||||||
Normalement, kaz-prod lance automatiquement les dockers (dans son rc.local), mais si ça ne marche pas bien il peut falloir les relancer (que se passe-t-il si on relance container.sh pendant que container.sh n'est pas encore fini ? faut-il l'enlever du rc.local ? Le lancement initial peut rater, probablement si le DNS n'est pas encore fonctionnel lors du lancement, à mettre au point et peut-être enlever du rc.local ?)
|
Normalement, hoster-a-kaz1 et hoster-b-kaz2 lancent automatiquement les dockers (dans rc.local), mais si ça ne marche pas bien il peut falloir les relancer (que se passe-t-il si on relance container.sh pendant que container.sh n'est pas encore fini ? faut-il l'enlever du rc.local ? Le lancement initial peut rater, probablement si le DNS n'est pas encore fonctionnel lors du lancement, à mettre au point et peut-être enlever du rc.local ?)
|
||||||
```bash
|
```bash
|
||||||
snster attach kaz-prod -x /kaz/bin/container.sh start
|
snster attach hoster-a-kaz1 -x /kaz/bin/container.sh start
|
||||||
|
snster attach hoster-b-kaz2 -x /kaz/bin/container.sh start
|
||||||
```
|
```
|
||||||
|
|
||||||
Vous pouvez alors (toutes les commandes snster doivent être exécutées dans `/root/snster-kaz`) :
|
Vous pouvez alors (toutes les commandes snster doivent être exécutées dans `/root/snster-kaz`) :
|
||||||
@ -62,17 +64,20 @@ Vous pouvez alors (toutes les commandes snster doivent être exécutées dans `/
|
|||||||
* Ouvrir Firefox et naviguer vers :
|
* Ouvrir Firefox et naviguer vers :
|
||||||
* `https://www.kaz.sns`, le Kaz interne à la VM
|
* `https://www.kaz.sns`, le Kaz interne à la VM
|
||||||
* `https://listes.kaz.sns`, le sympa interne à la VM
|
* `https://listes.kaz.sns`, le sympa interne à la VM
|
||||||
|
* `https://pad2.kaz.sns`, le pad sur kaz2
|
||||||
* `https://www.kaz.bzh`, le vrai Kaz
|
* `https://www.kaz.bzh`, le vrai Kaz
|
||||||
* Ouvrir claws-mail et retrouver les comptes mails configurés :
|
* Ouvrir claws-mail et retrouver les comptes mails configurés :
|
||||||
* `contact1@kaz.sns` à `contact4@kaz.sns`, hébergés sur le kaz-prod de la VM
|
* `contact1@kaz.sns` à `contact4@kaz.sns`, hébergés sur le kaz-prod de la VM
|
||||||
* `email@isp-a.sns`, hébergé dans le conteneur LXC isp-a-infra
|
* `email@isp-a.sns`, hébergé dans le conteneur LXC isp-a-infra
|
||||||
* Travailler sur kaz-prod : `snster attach kaz-prod`
|
* Travailler sur hoster-a-kaz1 : `snster attach hoster-a-kaz1`
|
||||||
* Afficher un plan de réseau : `snster print`
|
* Afficher un plan de réseau : `snster print`
|
||||||
* Le système de fichiers de kaz-prod est accessible directement dans la VM:
|
* Le système de fichiers de hoster-a-kaz1 est accessible directement dans la VM:
|
||||||
* `/kaz-prod/` [VM] correspond à `/` [kaz-prod]
|
* `/kaz1-prod/` [VM] correspond à `/` [hoster-a-kaz1]
|
||||||
* `/kaz` [VM] correspond à `/kaz` [kaz-prod]
|
* `/kaz` [VM] correspond à `/kaz` [hoster-a-kaz1]
|
||||||
* Il est probablement pratique d'installer son environnement de développement sur la VM, avec ses clés SSH et son éditeur favori.
|
* Il est probablement pratique d'installer son environnement de développement sur la VM, avec ses clés SSH et son éditeur favori.
|
||||||
|
|
||||||
|
Dans Vagrantfile, existent des répertoires partagés entre le host et le VM mais pour qu'ils soient visibles depuis la VM, il faut démarrer la VM non pas avec VirtualBox mais avec Vagrant up.
|
||||||
|
|
||||||
Il y a un aperçu de l'état des services avec l'url https://kaz.sns/status/allServices.html
|
Il y a un aperçu de l'état des services avec l'url https://kaz.sns/status/allServices.html
|
||||||
|
|
||||||

|

|
||||||
@ -93,9 +98,9 @@ Il vous faudra accepter les éventuelles alertes de sécurité pour certificat a
|
|||||||
|
|
||||||
## Mise au point
|
## Mise au point
|
||||||
|
|
||||||
Pour réinstaller Kaz sur kaz-prod (avec suppression de /kaz, des volumes dockers et réinstallation complète), depuis la VM :
|
Pour réinstaller Kaz sur kaz1 (avec suppression de /kaz, des volumes dockers et réinstallation complète; idem kaz2), depuis la VM :
|
||||||
```bash
|
```bash
|
||||||
snster attach kaz-prod -x "/root/kaz.sh"
|
snster attach hoster-a-kaz1 -x "/root/kaz.sh"
|
||||||
```
|
```
|
||||||
|
|
||||||
Pour détruire la VM et recommencer, depuis l'hôte :
|
Pour détruire la VM et recommencer, depuis l'hôte :
|
||||||
|
20
Vagrantfile
vendored
20
Vagrantfile
vendored
@ -2,32 +2,14 @@
|
|||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
# vi: set ft=ruby :
|
# vi: set ft=ruby :
|
||||||
|
|
||||||
unless Vagrant.has_plugin?("vagrant-disksize")
|
|
||||||
raise Vagrant::Errors::VagrantError.new, "vagrant-disksize plugin is missing. Please install it using 'vagrant plugin install vagrant-disksize' and rerun 'vagrant up'"
|
|
||||||
end
|
|
||||||
|
|
||||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||||
# configures the configuration version (we support older styles for
|
# configures the configuration version (we support older styles for
|
||||||
# backwards compatibility). Please don't change it unless you know what
|
# backwards compatibility). Please don't change it unless you know what
|
||||||
# you're doing.
|
# you're doing.
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
|
|
||||||
required_plugins = %w( vagrant-disksize )
|
config.vm.box = "debian/bookworm64"
|
||||||
_retry = false
|
|
||||||
required_plugins.each do |plugin|
|
|
||||||
unless Vagrant.has_plugin? plugin
|
|
||||||
system "vagrant plugin install #{plugin}"
|
|
||||||
_retry=true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if (_retry)
|
|
||||||
exec "vagrant " + ARGV.join(' ')
|
|
||||||
end
|
|
||||||
|
|
||||||
config.vm.box = "debian/bullseye64"
|
|
||||||
config.vm.hostname = 'kaz-vm'
|
config.vm.hostname = 'kaz-vm'
|
||||||
config.disksize.size = '50GB'
|
|
||||||
|
|
||||||
config.vm.provider "virtualbox" do |vb|
|
config.vm.provider "virtualbox" do |vb|
|
||||||
vb.memory = "4096"
|
vb.memory = "4096"
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 103 KiB |
@ -1,2 +1,2 @@
|
|||||||
proxy
|
#proxy
|
||||||
#traefik
|
traefik
|
||||||
|
@ -19,7 +19,8 @@ domain_sympa=listes.kaz.sns
|
|||||||
########################################
|
########################################
|
||||||
# choix d'un serveur partiel
|
# choix d'un serveur partiel
|
||||||
# site=site-2
|
# site=site-2
|
||||||
site=
|
site=kaz1
|
||||||
|
acme_server="https://ca.mica.sns/acme/acme/directory"
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Pour garradin qui met en "dure" dans
|
# Pour garradin qui met en "dure" dans
|
||||||
|
@ -24,7 +24,7 @@ export DebugLog="${OUTPUT_DIR}/log/log-kaz-$(date +%y-%m-%d-%T)-"
|
|||||||
|
|
||||||
# copie des sources
|
# copie des sources
|
||||||
cd /
|
cd /
|
||||||
git clone https://git.kaz.bzh/KAZ/kaz.git
|
git clone https://git.kaz.bzh/KAZ/KazV2.git kaz
|
||||||
(cd /kaz ; git checkout "${KAZBRANCH}" )
|
(cd /kaz ; git checkout "${KAZBRANCH}" )
|
||||||
|
|
||||||
cp "${DIR}/kaz-config/dockers.env" /kaz/config/dockers.env
|
cp "${DIR}/kaz-config/dockers.env" /kaz/config/dockers.env
|
||||||
|
@ -35,6 +35,7 @@ koffre IN CNAME kaz1
|
|||||||
pad IN CNAME kaz1
|
pad IN CNAME kaz1
|
||||||
agora IN CNAME kaz1
|
agora IN CNAME kaz1
|
||||||
listes IN MX 10 listes
|
listes IN MX 10 listes
|
||||||
|
pad2 IN CNAME kaz2
|
||||||
listes IN A 100.80.1.2
|
listes IN A 100.80.1.2
|
||||||
firewall IN A 100.80.0.1
|
firewall IN A 100.80.0.1
|
||||||
firewall IN AAAA 2001:db8:80::0:1
|
firewall IN AAAA 2001:db8:80::0:1
|
||||||
|
@ -5,9 +5,13 @@ if [ -z $SNSTERGUARD ] ; then exit 1; fi
|
|||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
|
DEB_VERSION=`cat /etc/debian_version | cut -d'.' -f1`
|
||||||
|
if [ $DEB_VERSION -eq "11" ] # DEB 11 aka Bullseye
|
||||||
|
then
|
||||||
# disable systemd-resolved which conflicts with nsd
|
# disable systemd-resolved which conflicts with nsd
|
||||||
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
||||||
systemctl stop systemd-resolved
|
systemctl stop systemd-resolved
|
||||||
|
fi
|
||||||
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get update
|
DEBIAN_FRONTEND=noninteractive apt-get update
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get remove -y apache2
|
DEBIAN_FRONTEND=noninteractive apt-get remove -y apache2
|
||||||
@ -55,11 +59,12 @@ echo "export SNSTERGUARD='true'" >> /root/.bashrc
|
|||||||
|
|
||||||
|
|
||||||
# On place les certifs
|
# On place les certifs
|
||||||
if [ -d letsencrypt ]; then
|
cp -ar tls/root_ca.crt /usr/local/share/ca-certificates/
|
||||||
cp -ar letsencrypt /etc/
|
|
||||||
cp /etc/letsencrypt/local/rootCA.pem /usr/local/share/ca-certificates/rootCA.crt
|
|
||||||
/usr/sbin/update-ca-certificates --fresh
|
/usr/sbin/update-ca-certificates --fresh
|
||||||
fi
|
|
||||||
|
mkdir -p /etc/letsencrypt/live/kaz.sns
|
||||||
|
cp tls/wildcard.crt /etc/letsencrypt/live/kaz.sns/fullchain.pem
|
||||||
|
cp tls/wildcard.key /etc/letsencrypt/live/kaz.sns/privkey.pem
|
||||||
|
|
||||||
# On sauve le proxy APT
|
# On sauve le proxy APT
|
||||||
proxy=$(/sbin/ip route | awk '/default/ { print $3 }' | head -1)
|
proxy=$(/sbin/ip route | awk '/default/ { print $3 }' | head -1)
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
proxy
|
#proxy
|
||||||
#traefik
|
traefik
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
#jirafeau
|
#jirafeau
|
||||||
#ethercalc
|
#ethercalc
|
||||||
#collabora
|
#collabora
|
||||||
#ethercalc
|
etherpad
|
||||||
#etherpad
|
|
||||||
#quotas
|
#quotas
|
||||||
#web
|
#web
|
||||||
#vigilo
|
#vigilo
|
||||||
|
@ -19,7 +19,8 @@ domain_sympa=listes.kaz.sns
|
|||||||
########################################
|
########################################
|
||||||
# choix d'un serveur partiel
|
# choix d'un serveur partiel
|
||||||
# site=site-2
|
# site=site-2
|
||||||
site=site-2
|
site=kaz2
|
||||||
|
acme_server="https://ca.mica.sns/acme/acme/directory"
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# Pour garradin qui met en "dure" dans
|
# Pour garradin qui met en "dure" dans
|
||||||
@ -52,7 +53,7 @@ gravHost=grav
|
|||||||
ldapHost=ldap
|
ldapHost=ldap
|
||||||
matterHost=agora
|
matterHost=agora
|
||||||
officeHost=office
|
officeHost=office
|
||||||
padHost=pad
|
padHost=pad2
|
||||||
quotasHost=quotas
|
quotasHost=quotas
|
||||||
smtpHost=smtp
|
smtpHost=smtp
|
||||||
sympaHost=listes
|
sympaHost=listes
|
||||||
@ -62,7 +63,7 @@ wordpressHost=wp
|
|||||||
ldapUIHost=mdp
|
ldapUIHost=mdp
|
||||||
mobilizonHost=mobilizon
|
mobilizonHost=mobilizon
|
||||||
vaultwardenHost=koffre
|
vaultwardenHost=koffre
|
||||||
traefikHost=dashboard
|
traefikHost=dashboard2
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
# ports internes
|
# ports internes
|
||||||
|
@ -24,7 +24,7 @@ export DebugLog="${OUTPUT_DIR}/log/log-kaz-$(date +%y-%m-%d-%T)-"
|
|||||||
|
|
||||||
# copie des sources
|
# copie des sources
|
||||||
cd /
|
cd /
|
||||||
git clone https://git.kaz.bzh/KAZ/kaz.git
|
git clone https://git.kaz.bzh/KAZ/KazV2.git kaz
|
||||||
(cd /kaz ; git checkout "${KAZBRANCH}" )
|
(cd /kaz ; git checkout "${KAZBRANCH}" )
|
||||||
|
|
||||||
cp "${DIR}/kaz-config/dockers.env" /kaz/config/dockers.env
|
cp "${DIR}/kaz-config/dockers.env" /kaz/config/dockers.env
|
||||||
@ -33,6 +33,9 @@ export DebugLog="${OUTPUT_DIR}/log/log-kaz-$(date +%y-%m-%d-%T)-"
|
|||||||
cp "${DIR}/kaz-config/container-${type}.list" /kaz/config/
|
cp "${DIR}/kaz-config/container-${type}.list" /kaz/config/
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# copie certif de la CA locale pour traefik (nécessaire pour ACME/Smallstep)
|
||||||
|
cp /usr/local/share/ca-certificates/root_ca.crt /kaz/dockers/traefik/conf/
|
||||||
|
|
||||||
echo -e "\n #### secretGen\n"
|
echo -e "\n #### secretGen\n"
|
||||||
/kaz/bin/secretGen.sh
|
/kaz/bin/secretGen.sh
|
||||||
|
|
||||||
|
@ -5,9 +5,13 @@ if [ -z $SNSTERGUARD ] ; then exit 1; fi
|
|||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
|
DEB_VERSION=`cat /etc/debian_version | cut -d'.' -f1`
|
||||||
|
if [ $DEB_VERSION -eq "11" ] # DEB 11 aka Bullseye
|
||||||
|
then
|
||||||
# disable systemd-resolved which conflicts with nsd
|
# disable systemd-resolved which conflicts with nsd
|
||||||
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
||||||
systemctl stop systemd-resolved
|
systemctl stop systemd-resolved
|
||||||
|
fi
|
||||||
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get update
|
DEBIAN_FRONTEND=noninteractive apt-get update
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get remove -y apache2
|
DEBIAN_FRONTEND=noninteractive apt-get remove -y apache2
|
||||||
@ -55,11 +59,12 @@ echo "export SNSTERGUARD='true'" >> /root/.bashrc
|
|||||||
|
|
||||||
|
|
||||||
# On place les certifs
|
# On place les certifs
|
||||||
if [ -d letsencrypt ]; then
|
cp -ar tls/root_ca.crt /usr/local/share/ca-certificates/
|
||||||
cp -ar letsencrypt /etc/
|
|
||||||
cp /etc/letsencrypt/local/rootCA.pem /usr/local/share/ca-certificates/rootCA.crt
|
|
||||||
/usr/sbin/update-ca-certificates --fresh
|
/usr/sbin/update-ca-certificates --fresh
|
||||||
fi
|
|
||||||
|
mkdir -p /etc/letsencrypt/live/kaz.sns
|
||||||
|
cp tls/wildcard.crt /etc/letsencrypt/live/kaz.sns/fullchain.pem
|
||||||
|
cp tls/wildcard.key /etc/letsencrypt/live/kaz.sns/privkey.pem
|
||||||
|
|
||||||
# On sauve le proxy APT
|
# On sauve le proxy APT
|
||||||
proxy=$(/sbin/ip route | awk '/default/ { print $3 }' | head -1)
|
proxy=$(/sbin/ip route | awk '/default/ { print $3 }' | head -1)
|
||||||
@ -99,6 +104,7 @@ DEBIAN_FRONTEND=noninteractive apt-get autoremove -y
|
|||||||
DEBIAN_FRONTEND=noninteractive apt-get clean
|
DEBIAN_FRONTEND=noninteractive apt-get clean
|
||||||
|
|
||||||
# On installe Kaz
|
# On installe Kaz
|
||||||
|
docker network create postfixNet # temp fix
|
||||||
ifconfig lo:0 100.81.0.2
|
ifconfig lo:0 100.81.0.2
|
||||||
echo "100.81.0.2 smtp imap www mail cloud cloud.kaz.sns tableur tableur.kaz.sns webmail webmail.kaz.sns garradin garradin.kaz.sns wiki wiki.kaz.sns git git.kaz.sns office office.kaz.sns depot depot.kaz.sns ldap ldap.kaz.sns mdp mdp.kaz.sns koffre koffre.kaz.sns pad pad.kaz.sns agora agora.kaz.sns dashboard dashboard.kaz.sns" >> /etc/hosts
|
echo "100.81.0.2 smtp imap www mail cloud cloud.kaz.sns tableur tableur.kaz.sns webmail webmail.kaz.sns garradin garradin.kaz.sns wiki wiki.kaz.sns git git.kaz.sns office office.kaz.sns depot depot.kaz.sns ldap ldap.kaz.sns mdp mdp.kaz.sns koffre koffre.kaz.sns pad pad.kaz.sns agora agora.kaz.sns dashboard dashboard.kaz.sns" >> /etc/hosts
|
||||||
cp "${DIR}/kaz.sh" /root/kaz.sh
|
cp "${DIR}/kaz.sh" /root/kaz.sh
|
||||||
|
@ -23,9 +23,8 @@ if [ -f /clawsmail/addclawsuser.sh ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# On place les certifs
|
# On place les certifs
|
||||||
if [ -d letsencrypt ]; then
|
if [ -f tls/root_ca.crt ]; then
|
||||||
cp -ar letsencrypt /etc/
|
cp -ar tls/root_ca.crt /usr/local/share/ca-certificates/root.crt
|
||||||
cp /etc/letsencrypt/local/rootCA.pem /usr/local/share/ca-certificates/root.crt
|
|
||||||
/usr/sbin/update-ca-certificates --fresh
|
/usr/sbin/update-ca-certificates --fresh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -7,13 +7,17 @@ cd `dirname $0`
|
|||||||
|
|
||||||
# Email's mail account email@isp-a.sns
|
# Email's mail account email@isp-a.sns
|
||||||
useradd -m -s "/bin/bash" -p `mkpasswd --method=sha-512 email` email || true
|
useradd -m -s "/bin/bash" -p `mkpasswd --method=sha-512 email` email || true
|
||||||
addgroup email mail
|
adduser email mail
|
||||||
#mkdir /home/hacker/mail
|
#mkdir /home/hacker/mail
|
||||||
#touch /home/hacker/mail/Drafts /home/hacker/mail/Queue /home/hacker/mail/Sent /home/hacker/mail/Trash
|
#touch /home/hacker/mail/Drafts /home/hacker/mail/Queue /home/hacker/mail/Sent /home/hacker/mail/Trash
|
||||||
|
|
||||||
|
DEB_VERSION=`cat /etc/debian_version | cut -d'.' -f1`
|
||||||
|
if [ $DEB_VERSION -eq "11" ] # DEB 11 aka Bullseye
|
||||||
|
then
|
||||||
# disable systemd-resolved which conflicts with nsd
|
# disable systemd-resolved which conflicts with nsd
|
||||||
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
||||||
systemctl stop systemd-resolved
|
systemctl stop systemd-resolved
|
||||||
|
fi
|
||||||
|
|
||||||
# manage isp-a.sns zone
|
# manage isp-a.sns zone
|
||||||
apt-get update
|
apt-get update
|
||||||
|
@ -7,14 +7,14 @@ header:
|
|||||||
config:
|
config:
|
||||||
prefix: kaz
|
prefix: kaz
|
||||||
nat-bridge: lxcbr0
|
nat-bridge: lxcbr0
|
||||||
default-master: bullseye
|
default-master: bookworm
|
||||||
|
|
||||||
masters:
|
masters:
|
||||||
bullseye:
|
bookworm:
|
||||||
backend: lxc
|
backend: lxc
|
||||||
template: debian
|
template: debian
|
||||||
parameters:
|
parameters:
|
||||||
release: bullseye
|
release: bookworm
|
||||||
arch: amd64
|
arch: amd64
|
||||||
family: debian
|
family: debian
|
||||||
|
|
||||||
@ -23,9 +23,8 @@ masters:
|
|||||||
template: download
|
template: download
|
||||||
parameters:
|
parameters:
|
||||||
dist: alpine
|
dist: alpine
|
||||||
release: 3.14
|
release: 3.21
|
||||||
arch: amd64
|
arch: amd64
|
||||||
no-validate: true
|
|
||||||
family: alpine
|
family: alpine
|
||||||
|
|
||||||
disabled-groups:
|
disabled-groups:
|
||||||
|
@ -5,22 +5,36 @@ if [ -z $SNSTERGUARD ] ; then exit 1; fi
|
|||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
|
DEB_VERSION=`cat /etc/debian_version | cut -d'.' -f1`
|
||||||
|
if [ $DEB_VERSION -eq "11" ] # DEB 11 aka Bullseye
|
||||||
|
then
|
||||||
# disable systemd-resolved which conflicts with nsd
|
# disable systemd-resolved which conflicts with nsd
|
||||||
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
||||||
systemctl stop systemd-resolved
|
systemctl stop systemd-resolved
|
||||||
|
fi
|
||||||
|
|
||||||
# manage mica.sns zone
|
# manage mica.sns zone
|
||||||
apt-get update
|
apt-get update
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y unbound
|
DEBIAN_FRONTEND=noninteractive apt-get install -y unbound
|
||||||
cp dns.conf /etc/unbound/unbound.conf.d/
|
cp dns.conf /etc/unbound/unbound.conf.d/
|
||||||
|
|
||||||
|
# On place les certifs
|
||||||
|
if [ -f tls/root_ca.crt ]; then
|
||||||
|
cp -ar tls/root_ca.crt /usr/local/share/ca-certificates/
|
||||||
|
/usr/sbin/update-ca-certificates --fresh
|
||||||
|
fi
|
||||||
|
|
||||||
# Install smallstep CA / ACME server
|
# Install smallstep CA / ACME server
|
||||||
cd /tmp
|
cd /tmp
|
||||||
wget https://github.com/smallstep/cli/releases/download/v0.17.2/step-cli_0.17.2_amd64.deb
|
wget "https://dl.smallstep.com/gh-release/cli/gh-release-header/v0.24.4/step-cli_0.24.4_amd64.deb"
|
||||||
dpkg -i step-cli_0.17.2_amd64.deb
|
dpkg -i step-cli_0.24.4_amd64.deb
|
||||||
wget https://github.com/smallstep/certificates/releases/download/v0.17.2/step-ca_0.17.2_amd64.deb
|
wget "https://dl.smallstep.com/gh-release/certificates/gh-release-header/v0.24.2/step-ca_0.24.2_amd64.deb"
|
||||||
dpkg -i step-ca_0.17.2_amd64.deb
|
dpkg -i step-ca_0.24.2_amd64.deb
|
||||||
|
|
||||||
|
echo "password" > /root/ca-passwordfile
|
||||||
|
step ca init --deployment-type=standalone --name="Kaz CA" --dns="ca.mica.sns" --acme --address=":443" --provisioner="contact@kaz.sns" --password-file="/root/ca-passwordfile" --root="${DIR}/tls/root_ca.crt" --key "${DIR}/tls/root_ca.key"
|
||||||
|
echo -e '#!/bin/sh\nstep-ca --password-file /root/ca-passwordfile' >> /etc/rc.local
|
||||||
|
chmod +x /etc/rc.local
|
||||||
|
|
||||||
# step ca init
|
# step ca init
|
||||||
# step ca root root.crt
|
# step ca root root.crt
|
||||||
|
@ -6,9 +6,13 @@ if [ -z $SNSTERGUARD ] ; then exit 1; fi
|
|||||||
DIR=`dirname $0`
|
DIR=`dirname $0`
|
||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
|
DEB_VERSION=`cat /etc/debian_version | cut -d'.' -f1`
|
||||||
|
if [ $DEB_VERSION -eq "11" ] # DEB 11 aka Bullseye
|
||||||
|
then
|
||||||
# disable systemd-resolved which conflicts with nsd
|
# disable systemd-resolved which conflicts with nsd
|
||||||
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
echo "DNSStubListener=no" >> /etc/systemd/resolved.conf
|
||||||
systemctl stop systemd-resolved
|
systemctl stop systemd-resolved
|
||||||
|
fi
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y nsd
|
DEBIAN_FRONTEND=noninteractive apt-get install -y nsd
|
||||||
|
@ -20,8 +20,8 @@ touch /etc/network/keepdhcp
|
|||||||
|
|
||||||
# Force lxc bridged interface metric (else, it grows to 200+interface_index, which can be large with successive stop/start)
|
# Force lxc bridged interface metric (else, it grows to 200+interface_index, which can be large with successive stop/start)
|
||||||
# This metric must be lower than the one exported by BGP for the default route (static part below)
|
# This metric must be lower than the one exported by BGP for the default route (static part below)
|
||||||
mkdir /etc/udhcpc
|
mkdir -p /etc/udhcpc
|
||||||
echo "IF_METRIC=200" > /etc/udhcpc/udhcpc.conf
|
echo "IF_METRIC=200" >> /etc/udhcpc/udhcpc.conf
|
||||||
|
|
||||||
|
|
||||||
# customize bird config (BGP)
|
# customize bird config (BGP)
|
||||||
@ -38,3 +38,5 @@ protocol static {
|
|||||||
# Add dnsmasq for external dns
|
# Add dnsmasq for external dns
|
||||||
apk add dnsmasq
|
apk add dnsmasq
|
||||||
rc-update add dnsmasq
|
rc-update add dnsmasq
|
||||||
|
# dnsmasq listen on eth1
|
||||||
|
echo "interface=eth1" >> /etc/dnsmasq.conf
|
||||||
|
@ -143,48 +143,22 @@ SystemMaxFileSize=2M
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# CA et certifs avec mkcert
|
# CA et certifs avec smallstep
|
||||||
|
|
||||||
echo -e "\n #### mkcert\n"
|
echo -e "\n #### smallstep\n"
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y libnss3-tools
|
cd /tmp
|
||||||
|
wget "https://dl.smallstep.com/gh-release/cli/gh-release-header/v0.24.4/step-cli_0.24.4_amd64.deb"
|
||||||
|
dpkg -i step-cli_0.24.4_amd64.deb
|
||||||
|
echo "password" > /root/ca-passwordfile
|
||||||
|
step ca init --deployment-type=standalone --name="Kaz CA" --dns="ca.mica.sns" --acme --address=":443" --provisioner="contact@kaz.sns" --password-file="/root/ca-passwordfile"
|
||||||
|
|
||||||
mkdir -p /root/mkcert
|
mkdir -p /root/tls
|
||||||
cd /root/mkcert
|
cp /root/.step/certs/root_ca.crt /root/tls/root_ca.crt
|
||||||
if [ ! -f mkcert ]; then
|
chmod 644 /root/tls/root_ca.crt
|
||||||
wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64 -O mkcert
|
cp /root/.step/secrets/root_ca_key /root/tls/root_ca.key
|
||||||
chmod +x mkcert
|
step crypto change-pass /root/tls/root_ca.key --no-password --insecure --password-file="/root/ca-passwordfile" --force
|
||||||
mkdir -p /etc/letsencrypt/local/
|
|
||||||
export CAROOT=/etc/letsencrypt/local/
|
|
||||||
/root/mkcert/mkcert -install # CA dans /etc/letsencrypt/local/
|
|
||||||
cd "${CAROOT}"
|
|
||||||
cat > "${CAROOT}/kaz.sns.cnf" <<EOF
|
|
||||||
[ req ]
|
|
||||||
prompt = no
|
|
||||||
distinguished_name = dn
|
|
||||||
req_extensions = req_ext
|
|
||||||
|
|
||||||
[ dn ]
|
step certificate create "*.kaz.sns" /root/tls/wildcard.crt /root/tls/wildcard.key --profile leaf --ca /root/.step/certs/intermediate_ca.crt --ca-key /root/.step/secrets/intermediate_ca_key --ca-password-file /root/ca-passwordfile --bundle --force --no-password --insecure --not-after 20000h
|
||||||
CN = *.kaz.sns
|
|
||||||
emailAddress = admin@kaz.sns
|
|
||||||
O = KAZ
|
|
||||||
OU = Dev
|
|
||||||
L = Vannes
|
|
||||||
ST = France
|
|
||||||
C = FR
|
|
||||||
|
|
||||||
[ req_ext ]
|
|
||||||
subjectAltName = @alt_names
|
|
||||||
|
|
||||||
[alt_names]
|
|
||||||
DNS.0 = *.kaz.sns
|
|
||||||
EOF
|
|
||||||
openssl req -new -newkey rsa:2048 -sha256 -nodes -keyout kaz.sns.key -out kaz.sns.csr -config kaz.sns.cnf
|
|
||||||
/root/mkcert/mkcert -csr "${CAROOT}/kaz.sns.csr" # cert et clé dans /etc/letsencrypt/local/
|
|
||||||
|
|
||||||
mkdir -p /etc/letsencrypt/live/kaz.sns/
|
|
||||||
ln -s ../../local/_wildcard.kaz.sns.pem /etc/letsencrypt/live/kaz.sns/fullchain.pem
|
|
||||||
ln -s ../../local/kaz.sns.key /etc/letsencrypt/live/kaz.sns/privkey.pem
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Cache docker registry
|
# Cache docker registry
|
||||||
echo "proxy:
|
echo "proxy:
|
||||||
@ -203,7 +177,7 @@ auth:
|
|||||||
git clone https://framagit.org/flesueur/snster.git
|
git clone https://framagit.org/flesueur/snster.git
|
||||||
cd snster
|
cd snster
|
||||||
# git checkout tags/v1.1.0
|
# git checkout tags/v1.1.0
|
||||||
git checkout fe59ef1f
|
git checkout 34b7c57cb7480cb4b3a84d14a1a46b60d0eb5967
|
||||||
./install.sh
|
./install.sh
|
||||||
|
|
||||||
# BTRFS avec hotfix sale de SNSTER
|
# BTRFS avec hotfix sale de SNSTER
|
||||||
@ -213,20 +187,22 @@ auth:
|
|||||||
mkfs.btrfs -f /root/btrfs.img
|
mkfs.btrfs -f /root/btrfs.img
|
||||||
echo "/root/btrfs.img /var/lib/lxc btrfs loop 0 0" >> /etc/fstab
|
echo "/root/btrfs.img /var/lib/lxc btrfs loop 0 0" >> /etc/fstab
|
||||||
mount /var/lib/lxc
|
mount /var/lib/lxc
|
||||||
sed -i -e "s/template=self.template/template=self.template, bdevtype='btrfs'/" /usr/local/lib/python3.9/dist-packages/backends/LxcBackend.py
|
sed -i -e "s/template=self.template/template=self.template, bdevtype='btrfs'/" /usr/local/lib/python3.11/dist-packages/backends/LxcBackend.py
|
||||||
|
|
||||||
# SNSTER KAZ
|
# SNSTER KAZ
|
||||||
cp -ar ${VAGRANT_SRC_DIR}/snster-kaz /root
|
cp -ar ${VAGRANT_SRC_DIR}/snster-kaz /root
|
||||||
|
|
||||||
# crypto keys
|
# crypto keys
|
||||||
cp -ar /etc/letsencrypt /root/snster-kaz/hoster-a/kaz1/
|
cp -ar /root/tls /root/snster-kaz/hoster-a/kaz1/
|
||||||
cp -ar /etc/letsencrypt /root/snster-kaz/isp-a/home/
|
cp -ar /root/tls /root/snster-kaz/hoster-b/kaz2/
|
||||||
cp -ar /etc/letsencrypt /root/snster-kaz/hoster-b/kaz2/
|
cp -ar /root/tls /root/snster-kaz/isp-a/home/
|
||||||
|
cp -ar /root/tls /root/snster-kaz/mica/infra/
|
||||||
|
|
||||||
|
|
||||||
# On lie le filesystem de kaz-prod dans le /kaz de la VM pour le dév
|
# On lie le filesystem de kaz-prod dans le /kaz de la VM pour le dév
|
||||||
ln -s /var/lib/lxc/kaz-hoster-a-kaz1/rootfs/ /kaz1-prod
|
ln -s /var/lib/lxc/kaz-hoster-a-kaz1/rootfs/ /kaz1-prod
|
||||||
ln -s /var/lib/lxc/kaz-hoster-b-kaz2/rootfs/ /kaz2-prod
|
ln -s /var/lib/lxc/kaz-hoster-b-kaz2/rootfs/ /kaz2-prod
|
||||||
ln -s /kaz-prod/kaz /kaz
|
ln -s /kaz-prod1/kaz /kaz
|
||||||
|
|
||||||
# On met le KAZGUARD pour la mise au point
|
# On met le KAZGUARD pour la mise au point
|
||||||
echo "export KAZGUARD='true'" >> /root/.bashrc
|
echo "export KAZGUARD='true'" >> /root/.bashrc
|
||||||
|
@ -15,16 +15,21 @@ git pull
|
|||||||
sed -i -e "s/template=self.template/template=self.template, bdevtype='btrfs'/" /usr/local/lib/python3.9/dist-packages/backends/LxcBackend.py
|
sed -i -e "s/template=self.template/template=self.template, bdevtype='btrfs'/" /usr/local/lib/python3.9/dist-packages/backends/LxcBackend.py
|
||||||
|
|
||||||
# On récupère le dernier kaz-vagrant
|
# On récupère le dernier kaz-vagrant
|
||||||
|
if [ -z "${KAZBRANCH}" ] ; then
|
||||||
|
KAZBRANCH="master"
|
||||||
|
fi
|
||||||
cd /tmp
|
cd /tmp
|
||||||
git clone https://git.kaz.bzh/KAZ/kaz-vagrant.git || (cd kaz-vagrant && git pull)
|
git clone https://git.kaz.bzh/KAZ/kaz-vagrant.git || (cd kaz-vagrant && git fetch && git switch "${KAZBRANCH}" && git pull)
|
||||||
cd /tmp/kaz-vagrant
|
cd /tmp/kaz-vagrant
|
||||||
|
git switch "${KAZBRANCH}"
|
||||||
|
|
||||||
# On écrase les anciens fichiers
|
# On écrase les anciens fichiers
|
||||||
cp -ar /tmp/kaz-vagrant/files/snster-kaz /root/
|
cp -ar /tmp/kaz-vagrant/files/snster-kaz /root/
|
||||||
# crypto keys
|
# crypto keys
|
||||||
cp -ar /etc/letsencrypt /root/snster-kaz/hoster-a/kaz1/
|
cp -ar /root/tls /root/snster-kaz/hoster-a/kaz1/
|
||||||
cp -ar /etc/letsencrypt /root/snster-kaz/hoster-b/kaz2/
|
cp -ar /root/tls /root/snster-kaz/hoster-b/kaz2/
|
||||||
cp -ar /etc/letsencrypt /root/snster-kaz/isp-a/home/
|
cp -ar /root/tls /root/snster-kaz/isp-a/home/
|
||||||
|
cp -ar /root/tls /root/snster-kaz/mica/infra/
|
||||||
|
|
||||||
# On détruit et reconstruit tout sauf kaz-prod
|
# On détruit et reconstruit tout sauf kaz-prod
|
||||||
SNSTER="snster -c /root/snster-kaz"
|
SNSTER="snster -c /root/snster-kaz"
|
||||||
|
Reference in New Issue
Block a user