Skip to content
Snippets Groups Projects
Unverified Commit 3e538868 authored by REIG Julien's avatar REIG Julien
Browse files

first commit

parent 2078a4b5
No related branches found
No related tags found
No related merge requests found
Showing with 218 additions and 0 deletions
{
"cmake.configureOnOpen": false
}
\ No newline at end of file
- name: Deploy Cart
hosts: cartservice
roles:
- csharp_service
\ No newline at end of file
- name: Deploy Services
hosts: productcatalogservice
vars:
go_version: "1.19.3"
roles:
- role: go_service
vars:
service_name: productcatalogservice
git_repo_url: https://gitlab+deploy-token-33:TCe6Hux5sq81g6jmEsub@gitlab.imt-atlantique.fr/ue-devops-fila2/online-boutique-services/productcatalogservice
path_to_service: /tmp/productcatalog_service
proto_file_name: productcatalogservice
\ No newline at end of file
- name: Deploy Recommendation
hosts: recommendationservice
roles:
- role: python_service
vars:
service_name: recommendation_service
path_to_service: /tmp/recommendation_service
python_script: recommendation_server.py
\ No newline at end of file
all:
hosts:
frontend:
ansible_host: 10.29.246.97
ansible_user: root
ansible_port: 22
ansible_password: "0000"
productcatalogservice:
ansible_host: 10.29.247.194
ansible_user: root
ansible_port: 22
ansible_password: "0000"
recommendationservice:
ansible_host: 10.29.244.83
ansible_user: root
ansible_port: 22
ansible_password: "0000"
cartservice:
ansible_host: 10.29.244.15
ansible_user: root
ansible_port: 22
ansible_password: "0000"
\ No newline at end of file
ssh root@10.29.244.15 -p 22
\ No newline at end of file
ssh root@10.29.246.97 -p 22
\ No newline at end of file
ssh root@10.29.247.194 -p 22
\ No newline at end of file
ssh root@10.29.244.83 -p 22
\ No newline at end of file
- name:
\ No newline at end of file
[Unit]
Description=Lancement du microservice {{ service_name }}
After=network.target
[Service]
User=root
WorkingDirectory={{ working_directory }}
ExecStart={{ cmd_to_execute }}
Environment={{ env_vars }}
[Install]
WantedBy=multi-user.target
\ No newline at end of file
- name: Go mod download
ansible.builtin.command:
cmd: go mod download
chdir: "{{path_to_service}}"
- name: Build the proto
ansible.builtin.command:
cmd: protoc --go_out=plugins=grpc:genproto -I . {{proto_file_name}}.proto
chdir: "{{path_to_service}}"
- name: Build the service
ansible.builtin.command:
cmd: go build -o {{service_name}}
chdir: "{{path_to_service}}"
- name: restart the service
ansible.builtin.systemd:
name: "{{service_name}}"
daemon_reload: true
state: restarted
enabled: yes
\ No newline at end of file
- name: Download and extract Go
ansible.builtin.unarchive:
src: https://go.dev/dl/go{{go_version}}.linux-amd64.tar.gz
dest: /usr/local
remote_src: yes
- name: Create symlink to Go
ansible.builtin.file:
src: /usr/local/go/bin/{{item}}
dest: /usr/local/bin/{{item}}
state: link
with_items:
- go
- gofmt
- name: Install protobuf-compiler and golang-goprotobuf-dev package
ansible.builtin.apt:
name:
- golang-goprotobuf-dev
- protobuf-compiler
state: present
update_cache: yes
- name: Download {{service_name}} from git
ansible.builtin.git:
repo: "{{git_repo_url}}"
dest: "{{path_to_service}}"
notify:
- Go mod download
- Build the proto
- Build the service
- restart the service
- name: Create genproto directory
ansible.builtin.file:
path: "{{path_to_service}}/genproto"
state: directory
notify:
- Build the proto
- Build the service
- restart the service
- name: Create the {{service_name}} file
vars:
working_directory: "{{path_to_service}}"
cmd_to_execute: "{{path_to_service}}/{{service_name}}"
env_vars: "port=3550"
ansible.builtin.template:
src: templates/systemd.j2
dest: /etc/systemd/system/{{service_name}}.service
notify:
- restart the service
[Unit]
Description=Lancement du microservice {{ service_name }}
After=network.target
[Service]
User=root
WorkingDirectory={{ working_directory }}
ExecStart={{ cmd_to_execute }}
Environment={{ env_vars }}
[Install]
WantedBy=multi-user.target
\ No newline at end of file
- name: restart the service
ansible.builtin.systemd:
name: "{{service_name}}"
daemon_reload: true
state: restarted
enabled: yes
- name: Build the proto
ansible.builtin.command:
chdir: "{{path_to_service}}"
cmd: "protoc -I. --python_out=. --grpc_python_out=. recommendationservice.proto"
\ No newline at end of file
- name: Clone repository
ansible.builtin.git:
repo: https://gitlab+deploy-token-37:TC4cPWqPPs2R8qTY5mir@gitlab.imt-atlantique.fr/ue-devops-fila2/online-boutique-services/recommendationservice
dest: "{{path_to_service}}"
notify:
- Build the proto
- restart the service
- name: Install pip
ansible.builtin.apt:
name:
- pip
state: present
update_cache: yes
- name: pip from requirements
ansible.builtin.pip:
chdir: "{{path_to_service}}"
requirements: requirements.txt
- name: Install protobuf-compiler
ansible.builtin.apt:
name:
- protobuf-compiler
state: present
update_cache: yes
- name: Create genproto directory
ansible.builtin.file:
path: "{{path_to_service}}/genproto"
state: directory
notify:
- Build the proto
- restart the service
- name: Create the {{service_name}} service file
vars:
working_directory: "{{path_to_service}}"
cmd_to_execute: "{{path_to_service}}/{{python_script}}"
env_vars: "port=8081"
ansible.builtin.template:
src: templates/systemd.j2
dest: /etc/systemd/system/{{service_name}}.service
notify:
- restart the service
[Unit]
Description=Lancement du microservice {{ service_name }}
After=network.target
[Service]
User=root
WorkingDirectory={{ working_directory }}
ExecStart={{ cmd_to_execute }}
Environment={{ env_vars }}
[Install]
WantedBy=multi-user.target
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment