133 lines
3.5 KiB
YAML
Executable File
133 lines
3.5 KiB
YAML
Executable File
#cloud-config
|
|
# vim: syntax=yaml
|
|
|
|
hostname: meta-76
|
|
manage_etc_hosts: false
|
|
|
|
groups:
|
|
- meta: yoh1
|
|
|
|
# Configuration des utilisateurs
|
|
users:
|
|
- default
|
|
- name: yoh1
|
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
|
groups: meta
|
|
passwd: $6$Cvg/O/hpkWgpCvLd$z6awusyCE39i.JzjNfDvJPbxyEHu4rXSVUjQZJL8OGKOWpQNfe3iS1S7/7zstZcHhIIy.VzoC/V5YLQ7SYFA.0
|
|
lock_passwd: false
|
|
- name: docker
|
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
|
groups: meta
|
|
passwd: $6$dMo0oCFfhDf2velN$cq258FKXOjyFTZR64Uow5m/LWdaoU5peYaqIJPE0dpMiKRCo.2JRtVnuRu8.dWZaghkpnfnfaC.lclWNk1d6t.
|
|
lock_passwd: false
|
|
|
|
# Mise à jour des paquets et installation des dépendances
|
|
package_update: true
|
|
package_upgrade: true
|
|
|
|
packages:
|
|
- fail2ban
|
|
- postgresql14-contrib
|
|
- nmap
|
|
- docker
|
|
- docker-cli-compose
|
|
- xe-guest-utilities
|
|
# Commandes avant boot
|
|
bootcmd:
|
|
- modprobe bonding
|
|
|
|
runcmd:
|
|
- rc-update add docker default
|
|
- rc-update add xe-guest-utilities default
|
|
- rc-service docker start
|
|
- rc-service xe-guest-utilities start
|
|
- rc-update add local boot
|
|
# - /etc/local.d/bonding-setup.start
|
|
|
|
# Attendre que le réseau soit stable
|
|
- sleep 5
|
|
|
|
# Configurer Docker
|
|
- rc-update add docker boot
|
|
- rc-service docker start
|
|
|
|
# Initialiser Swarm
|
|
- docker swarm init --advertise-addr bond0 || logger "Swarm already initialized or failed"
|
|
|
|
# Logs de diagnostic
|
|
- ip addr > /var/log/network-post-init.log
|
|
- ip route > /var/log/routes-post-init.log
|
|
- cat /proc/net/bonding/bond0 > /var/log/bond-post-init.log 2>&1 || echo "Bond not ready" > /var/log/bond-post-init.log
|
|
- docker info > /var/log/docker-info.log 2>&1
|
|
|
|
|
|
write_files:
|
|
- path: /etc/motd
|
|
content: |
|
|
Bienvenue sur bojemoi
|
|
# Fichiers de configuration
|
|
write_files:
|
|
- path: /etc/modules
|
|
content: |
|
|
bonding
|
|
xen_netfront
|
|
append: true
|
|
|
|
- path: /etc/modprobe.d/bonding.conf
|
|
content: |
|
|
alias bond0 bonding
|
|
options bonding mode=1 miimon=100 use_carrier=1
|
|
permissions: '0644'
|
|
|
|
- path: /etc/local.d/bonding-setup.start
|
|
permissions: '0755'
|
|
content: |
|
|
#!/bin/sh
|
|
# Setup bonding
|
|
logger "Starting bonding setup"
|
|
|
|
# Charger le module si pas déjà fait
|
|
modprobe bonding 2>/dev/null || true
|
|
|
|
# Créer bond0 si n'existe pas
|
|
if ! ip link show bond0 >/dev/null 2>&1; then
|
|
ip link add bond0 type bond mode active-backup miimon 100 primary eth0
|
|
logger "Bond0 created"
|
|
fi
|
|
|
|
# S'assurer que les interfaces sont down
|
|
ip link set eth0 down 2>/dev/null
|
|
ip link set eth1 down 2>/dev/null
|
|
|
|
# Attacher les interfaces au bond
|
|
ip link set eth0 master bond0 2>/dev/null || echo "+eth0" > /sys/class/net/bond0/bonding/slaves
|
|
ip link set eth1 master bond0 2>/dev/null || echo "+eth1" > /sys/class/net/bond0/bonding/slaves
|
|
|
|
# Activer les interfaces
|
|
ip link set eth0 up
|
|
ip link set eth1 up
|
|
ip link set bond0 up
|
|
|
|
logger "Bonding setup complete"
|
|
|
|
# Log status
|
|
sleep 2
|
|
cat /proc/net/bonding/bond0 > /var/log/bond0-init.log 2>&1
|
|
|
|
- path: /etc/docker/daemon.json
|
|
content: |
|
|
{
|
|
"metrics-addr": "0.0.0.0:9323",
|
|
"experimental": true,
|
|
"log-driver": "json-file",
|
|
"log-opts": {
|
|
"max-size": "10m",
|
|
"max-file": "3"
|
|
}
|
|
}
|
|
permissions: '0644'
|
|
|
|
|
|
# Afficher un message final à l'utilisateur après l'installation
|
|
final_message: "L'installation est terminée avec succès ! Accédez à l'interface {ip}"
|