From 941186d1f2f6305cb44778f378e32d90a8745275 Mon Sep 17 00:00:00 2001 From: Florentin Labelle <florentin.labelle@student-cs.fr> Date: Wed, 12 Oct 2022 11:21:23 +0200 Subject: [PATCH] Fix deployment --- vms/README.md | 12 ++++++++---- vms/cloudinit.py | 26 -------------------------- vms/cloudinit.yaml | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 30 deletions(-) delete mode 100644 vms/cloudinit.py diff --git a/vms/README.md b/vms/README.md index 7b971e0..717986a 100644 --- a/vms/README.md +++ b/vms/README.md @@ -4,9 +4,6 @@ 1. Les faire papser 2. Figer le paps 10-15 mins avant le tp de déploiment -3. Exporter en csv -4. Mettre le résultat dans le paps.csv -5. Lancer le cloudinit.py ## Création des vms @@ -26,4 +23,11 @@ - `source openrc` - récupérer les ips - `openstack server list --project formation -f yaml | yq ".[].Networks.vm[1]"` -- les copier dans un fichier vscode, puis attribuer une vm à chaque mec en mode tu prends le numéro de ton paps et l'ip de la ligne associé. +- Appeler Marc-Antoine ou Quentin si ça marche pas +- les copier dans un fichier vscode, puis attribuer une vm à chaque mec en mode tu prends le numéro de son paps et l'ip de la ligne associé. + +## Se connecter à une vm + +- attendre 1-2 min que le cloud-init s'execute +- user: viazero + mdp: viazero diff --git a/vms/cloudinit.py b/vms/cloudinit.py deleted file mode 100644 index 7bf8e02..0000000 --- a/vms/cloudinit.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Generate cloud-init configuration for the VMs. -""" -import crypt -cloudinit=""" -#cloud-config -apt_upgrade: true -ssh_pwauth: 1 -users: -""" -with open("paps.csv", encoding="utf-8") as file: - for line in file.readlines()[1:]: - login = line.split(";")[0][4:] - password = crypt.crypt(login, crypt.mksalt(crypt.METHOD_SHA256)) - cloudinit += f""" - - name: {login} - primary_group: {login} - groups: users - lock_passwd: false - shell: /bin/bash - sudo: ALL=(ALL) NOPASSWD:ALL - passwd: {password} - - """ -with open("cloudinit.yaml", "w", encoding="utf-8") as file: - file.write(cloudinit) diff --git a/vms/cloudinit.yaml b/vms/cloudinit.yaml index e69de29..d73ef35 100644 --- a/vms/cloudinit.yaml +++ b/vms/cloudinit.yaml @@ -0,0 +1,21 @@ +#cloud-config +apt_upgrade: true +ssh_pwauth: 1 +runcmd: + - apt install -y zsh curl python3-pip git ca-certificates fail2ban + - mkdir -p /etc/zsh + - git clone https://github.com/robbyrussell/oh-my-zsh.git /etc/zsh/.oh-my-zsh + - mkdir -p /etc/zsh/.oh-my-viarezo + - git clone https://gitlab.viarezo.fr/ViaRezo/oh-my-viarezo.git /etc/zsh/.oh-my-viarezo/themes/oh-my-viarezo + - git clone https://gitlab.viarezo.fr/ViaRezo/zsh-plugins.git /etc/zsh/.oh-my-viarezo/plugins + - curl https://gitlab.viarezo.fr/-/snippets/40/raw/main/zshrc > /etc/zsh/zshrc + - chsh -s /bin/zsh + - touch /root/.zshrc + - touch /home/viazero/.zshrc +users: + - name: viazero + primary_group: viazero + lock_passwd: false + shell: /bin/zsh + sudo: ALL=(ALL) NOPASSWD:ALL + passwd: $5$mPCaWrI78yDsgbTd$ipZkGn/CAuo4A9Y9fO21C6CcW2JmrzI100XD9xSCHE1 -- GitLab