diff --git a/vms/README.md b/vms/README.md index 7b971e0e480eddfd9c1051faf04c32061dfff0f1..717986a7bea34dec6a7d156e45c4dcb5fec6562b 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 7bf8e0259e8d408c879112a7e66de843d670a067..0000000000000000000000000000000000000000 --- 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d73ef35cdc95a096f20f81093cf2480fa1d8ae30 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