diff --git a/ansibleLabsTLC/Readme.md b/ansibleLabsTLC/Readme.md new file mode 100644 index 0000000..047ff52 --- /dev/null +++ b/ansibleLabsTLC/Readme.md @@ -0,0 +1,89 @@ +# TP Ansible + +## Objectif du TP + +Ce TP est une introduction pratique à Ansible. Le but est d'observer le déploiement automatisé à l'aide d'Ansible. Ce TP est donné dans le cadre du cours  [TLC](https://hackmd.diverse-team.fr/s/SJqu5DjSD) au [département d'Informatique et d'Electronique](https://istic.univ-rennes1.fr/) de l'[Université de Rennes 1](https://www.univ-rennes1.fr/). + +## Enoncé + +- **Tâche 0**. Créer deux machines virtuelle (https://vm.istic.univ-rennes1.fr/ séléctionner **ubuntu22** comme image de base), l'accès au port 22 se fera au travers du [VPN](https://istic.univ-rennes1.fr/intranet/services#section-4). + +Une fois que vous avez créer ces machines, vérifier que vous avez accès à ces machines en ssh avec les instructions reçues par email. + + + +- **Tâche 1**. + +En s'inspirant du playbooks disponible [ici](https://github.com/barais/demoAnsible/tree/main/lamp_ubuntu1804_2hosts_withroles), déployer cette simple application ansible sur vos vms. + +Sur votre portable : + +``bash +apt-get install ansible +git clone https://github.com/barais/demoAnsible +cd demoAnsible/lamp_ubuntu1804_2hosts_withroles +# edit the hosts to put the IP of your VMs and the login and password +nano -w hosts +ansible-playbook site.yml -i hosts +``` + + + +Essayer d'accéder à http://ADRESSE_IP_DE_VOTRE_VM_WEB/index.php + + +- **Tâche 2**. + +Créer un nouveau playbook pour installer micok8S sur votre VM. + +Tout d'abord, créer la structure de votre playbook. Prenez le temps de lire les recommandations ici. +https://docs.ansible.com/ansible/latest/tips_tricks/sample_setup.html + +En utilisant les modules apt, snap et shell, créer un playbook pour installer microk8S. + +Je rappelle que microk8s s'installe manuellement avec les commandes suivantes. + +- Install Docker + +[Install Docker on ubuntu](https://docs.docker.com/engine/install/ubuntu/) + +- Install microk8s + +[See docs](https://microk8s.io/docs/getting-started) + +```bash +sudo snap install microk8s --classic --channel=1.25 +sudo usermod -a -G microk8s $USER +sudo chown -f -R $USER ~/.kube +microk8s start +microk8s status --wait-ready +``` + +Enable services + +```bash +microk8s enable dns storage +microk8s enable dashboard ingress +microk8s enable registry +``` + +Pushing to this insecure registry may fail in some versions of Docker unless the + daemon is explicitly configured to trust this registry. To address this we need + to edit /etc/docker/daemon.json and add: + +```json +{ + "insecure-registries" : ["localhost:32000"] +} +``` + +The new configuration should be loaded with a Docker daemon restart: + +```bash +sudo systemctl restart docker +``` + +- **Tâche 3**. + +Pour les plus gerriers, révisez votre playbook ansible pour utiliser le module suivant +https://galaxy.ansible.com/gepaplexx/microk8s diff --git a/lamp_ubuntu1804_2hosts_withroles/README.md b/lamp_ubuntu2204_2hosts_withroles/README.md similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/README.md rename to lamp_ubuntu2204_2hosts_withroles/README.md diff --git a/lamp_ubuntu1804_2hosts_withroles/group_vars/all b/lamp_ubuntu2204_2hosts_withroles/group_vars/all similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/group_vars/all rename to lamp_ubuntu2204_2hosts_withroles/group_vars/all diff --git a/lamp_ubuntu1804_2hosts_withroles/group_vars/dbservers b/lamp_ubuntu2204_2hosts_withroles/group_vars/dbservers similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/group_vars/dbservers rename to lamp_ubuntu2204_2hosts_withroles/group_vars/dbservers diff --git a/lamp_ubuntu1804_2hosts_withroles/group_vars/webservers b/lamp_ubuntu2204_2hosts_withroles/group_vars/webservers similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/group_vars/webservers rename to lamp_ubuntu2204_2hosts_withroles/group_vars/webservers diff --git a/lamp_ubuntu1804_2hosts_withroles/hosts b/lamp_ubuntu2204_2hosts_withroles/hosts similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/hosts rename to lamp_ubuntu2204_2hosts_withroles/hosts diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/common/handlers/main.yml b/lamp_ubuntu2204_2hosts_withroles/roles/common/handlers/main.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/common/handlers/main.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/common/handlers/main.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/common/tasks/main.yml b/lamp_ubuntu2204_2hosts_withroles/roles/common/tasks/main.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/common/tasks/main.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/common/tasks/main.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/common/templates/ntp.conf.j2 b/lamp_ubuntu2204_2hosts_withroles/roles/common/templates/ntp.conf.j2 similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/common/templates/ntp.conf.j2 rename to lamp_ubuntu2204_2hosts_withroles/roles/common/templates/ntp.conf.j2 diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/db/handlers/main.yml b/lamp_ubuntu2204_2hosts_withroles/roles/db/handlers/main.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/db/handlers/main.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/db/handlers/main.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/db/tasks/main.yml b/lamp_ubuntu2204_2hosts_withroles/roles/db/tasks/main.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/db/tasks/main.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/db/tasks/main.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/db/templates/my.cnf.j2 b/lamp_ubuntu2204_2hosts_withroles/roles/db/templates/my.cnf.j2 similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/db/templates/my.cnf.j2 rename to lamp_ubuntu2204_2hosts_withroles/roles/db/templates/my.cnf.j2 diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/web/handlers/main.yml b/lamp_ubuntu2204_2hosts_withroles/roles/web/handlers/main.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/web/handlers/main.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/web/handlers/main.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/web/tasks/copy_code.yml b/lamp_ubuntu2204_2hosts_withroles/roles/web/tasks/copy_code.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/web/tasks/copy_code.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/web/tasks/copy_code.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/web/tasks/install_httpd.yml b/lamp_ubuntu2204_2hosts_withroles/roles/web/tasks/install_httpd.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/web/tasks/install_httpd.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/web/tasks/install_httpd.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/web/tasks/main.yml b/lamp_ubuntu2204_2hosts_withroles/roles/web/tasks/main.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/web/tasks/main.yml rename to lamp_ubuntu2204_2hosts_withroles/roles/web/tasks/main.yml diff --git a/lamp_ubuntu1804_2hosts_withroles/roles/web/templates/index.php.j2 b/lamp_ubuntu2204_2hosts_withroles/roles/web/templates/index.php.j2 similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/roles/web/templates/index.php.j2 rename to lamp_ubuntu2204_2hosts_withroles/roles/web/templates/index.php.j2 diff --git a/lamp_ubuntu1804_2hosts_withroles/site.yml b/lamp_ubuntu2204_2hosts_withroles/site.yml similarity index 100% rename from lamp_ubuntu1804_2hosts_withroles/site.yml rename to lamp_ubuntu2204_2hosts_withroles/site.yml diff --git a/lamp_ubuntu1804_onehost/files/apache.conf.j2 b/lamp_ubuntu2204_onehost/files/apache.conf.j2 similarity index 100% rename from lamp_ubuntu1804_onehost/files/apache.conf.j2 rename to lamp_ubuntu2204_onehost/files/apache.conf.j2 diff --git a/lamp_ubuntu1804_onehost/files/info.php.j2 b/lamp_ubuntu2204_onehost/files/info.php.j2 similarity index 100% rename from lamp_ubuntu1804_onehost/files/info.php.j2 rename to lamp_ubuntu2204_onehost/files/info.php.j2 diff --git a/lamp_ubuntu1804_onehost/hosts b/lamp_ubuntu2204_onehost/hosts similarity index 100% rename from lamp_ubuntu1804_onehost/hosts rename to lamp_ubuntu2204_onehost/hosts diff --git a/lamp_ubuntu1804_onehost/playbook.yml b/lamp_ubuntu2204_onehost/playbook.yml similarity index 100% rename from lamp_ubuntu1804_onehost/playbook.yml rename to lamp_ubuntu2204_onehost/playbook.yml diff --git a/lamp_ubuntu1804_onehost/readme.md b/lamp_ubuntu2204_onehost/readme.md similarity index 100% rename from lamp_ubuntu1804_onehost/readme.md rename to lamp_ubuntu2204_onehost/readme.md diff --git a/lamp_ubuntu1804_onehost/vars/default.yml b/lamp_ubuntu2204_onehost/vars/default.yml similarity index 100% rename from lamp_ubuntu1804_onehost/vars/default.yml rename to lamp_ubuntu2204_onehost/vars/default.yml diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 2f869ba..24868f5 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -1,7 +1,7 @@ # #################################################################### # ################### CONFIGURATION VARIABLES ######################## # #################################################################### -IMAGE_NAME = "bento/ubuntu-18.04" # Image to use +IMAGE_NAME = "bento/ubuntu-22.04" # Image to use MEM = 2048 # Amount of RAM CPU = 1 # Number of processors SLAVE_NBR = 2 # Number of slaves node