rendu TP TLC 2024

This commit is contained in:
Rémi Rativel 2024-03-27 19:25:56 +01:00
commit 73835f377e
10 changed files with 148 additions and 0 deletions

1
Ansible/demoAnsible Submodule

@ -0,0 +1 @@
Subproject commit 0836898feca1b8aaa8aff348fe0438fde9c9f7ca

View File

@ -0,0 +1,9 @@
[webservers]
148.60.11.43
[webservers:vars]
ansible_connection=ssh
ansible_ssh_user=zprojet
ansible_ssh_pass=tp_ansible_pass
ansible_become_pass=tp_ansible_pass
ansible_python_interpreter=/usr/bin/python3

View File

@ -0,0 +1,20 @@
---
- name: Checking if daemon.json exists
ansible.builtin.stat:
path: /etc/docker/daemon.json
register: is_present
- block:
- name: Adding registry to file
ansible.builtin.lineinfile:
path: /etc/docker/daemon.json
line: '{ "insecure-registries" : ["localhost:32000"] }'
create: yes
when: is_present.stat.exists == false
- name: Restart docker
ansible.builtin.systemd_service:
state: restarted
daemon_reload: true
name: docker

View File

@ -0,0 +1,24 @@
---
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable
state: present
- name: Update apt and install docker-ce
apt:
name: docker-ce
state: latest
update_cache: true
- name: Install Docker Module for Python
pip:
name: docker
- name: Start docker daemon
systemd_service:
name: docker
state: restarted

View File

@ -0,0 +1,16 @@
---
- name: Start microk8s
ansible.builtin.command: microk8s start
- name: Wait for microk8S to be ready
ansible.builtin.command: microk8s status --wait-ready
- name: Enable dns storage
ansible.builtin.command: microk8s enable dns storage
- name: Enable ingress dashboard
ansible.builtin.command: microk8s enable dashboard ingress
- name: Enable registry
ansible.builtin.command: microk8s enable registry

View File

@ -0,0 +1,9 @@
---
- include_tasks: docker_install.yml
- include_tasks: microk8s_install.yml
- include_tasks: enable_microk8s.yml
- include_tasks: add_insecure_registries.yml

View File

@ -0,0 +1,15 @@
---
- name: Install snapd
apt:
name: snapd
state: present
- name: Install MicroK8s
shell: snap install microk8s --classic
- name: Allow non-root access to MicroK8s
shell: usermod -aG microk8s $USER
- name: Configure MicroK8s
shell: sudo microk8s status --wait-ready

View File

@ -0,0 +1,10 @@
---
# This playbook deploys the whole application stack in this site.
- name: apply common configuration to all nodes
hosts: all
remote_user: zprojet
become: yes
roles:
- microk8s

16
Docker/Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM ubuntu:22.04
RUN yes | apt-get update
RUN apt-get install -y openjdk-8-jdk
RUN apt-get install -y maven
RUN apt-get install -y libpng-dev
RUN apt-get install -y git
RUN git clone https://github.com/barais/TPDockerSampleApp
WORKDIR TPDockerSampleApp
RUN mvn install:install-file -Dfile=./lib/opencv-3410.jar -DgroupId=org.opencv -DartifactId=opencv -Dversion=3.4.10 -Dpackaging=jar
# Pour compiler
RUN mvn package
# Pour lancer l'application
CMD java -Djava.library.path=lib/ubuntuupperthan18/ -jar target/fatjar-0.0.1-SNAPSHOT.jar

View File

@ -0,0 +1,28 @@
version: "3.8"
services:
reverse-proxy:
image: jwilder/nginx-proxy
ports:
- 8080:80
volumes:
- /var/run/docker.sock:/tmp/docker.sock
nginx1:
image: nginx
environment:
- HOSTNAME=m
nginx2:
image: nginx
environment:
- HOSTNAME=m
nginx3:
image: nginx
environment:
- HOSTNAME=m
nginx4:
image: nginx
environment:
- HOSTNAME=m