# Commandes

## Exécuter le docker compose (avec vm)

### Démarrage de la vm

`vagrant up` dans le dossier "vagrant/virtualbox" ou "vagrant/libvirt" pour démarrer les VMs

Si erreur 
Exécuter `sudo rmmod kvm_amd && sudo modprobe kvm` avant de relancer `vagrant up`

list exixting vagrant VMs
`vagrant global-status`

kill vagrant vm command
`vagrant destroy -g [vm id]`

Créer une clé ssh en se connectant une fois dans la vm
```bash
ssh vagrant@192.168.56.141
password: vagrant
exit
```

```bash 
vagrant global-status | grep "running" | awk '{print $1}' | xargs -L 1 vagrant destroy -g
```

# Relancer la vm
```bash
vagrant reload
```


lors de l'exec de `ansible-playbook -i hosts playbook.yml` si erreur suivante :

```
fatal: [master-node]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: 
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!  IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible 
that a host key has just been changed.\r\nThe fingerprint for the ED25519 key sent by the remote host 
is\[x].\r\nPlease contact your system administrator.
\r\nAdd correct host key in /home/[x]/.ssh/known_hosts to get rid of this message.
...
```

Supprimer la clé ssh de la vm
```bash
ssh-keygen -f "/home/[nom]/.ssh/known_hosts" -R "192.168.56.141"
```

Recréer une clé ssh en se reconnectant à la vm 
Puis relancer `ansible-playbook -i hosts playbok.yml`


### Exécuter le docker compose (sans vm)
```bash
docker compose -f "./ansible/files/dockercompose/docker-compose.yml" up
```

```bash 
docker compose down -v
docker volume prune
```
