append game and build for some new servers

master
Amir Hossein Moghiseh 2022-04-24 16:03:36 +04:30
parent 224efb6708
commit 3c537fba27
12 changed files with 287 additions and 15 deletions

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.DS_* .DS_*
password password
.DS*

View File

@ -8,10 +8,10 @@
src: template/nginx-server-block.j2 src: template/nginx-server-block.j2
dest: /tmp/new-nginx-server-block.{{item.server_name}}.conf dest: /tmp/new-nginx-server-block.{{item.server_name}}.conf
with_items: with_items:
- server_name: dev.capitan.igarson.app - server_name: tetris.game.igarson.app
server_config: "" server_config: ""
service_port: 10003 service_port: 6005
conf_file: ngrok.conf conf_file: games.conf
- name: append /tmp/new-nginx-server-block.conf to specific conf - name: append /tmp/new-nginx-server-block.conf to specific conf
@ -19,20 +19,20 @@
cat /tmp/new-nginx-server-block.{{item.server_name}}.conf >> /etc/nginx/sites-available/{{ item.conf_file }} cat /tmp/new-nginx-server-block.{{item.server_name}}.conf >> /etc/nginx/sites-available/{{ item.conf_file }}
rm -rf /tmp/new-nginx-server-block.{{item.server_name}}.conf rm -rf /tmp/new-nginx-server-block.{{item.server_name}}.conf
with_items: with_items:
- server_name: dev.capitan.igarson.app - server_name: tetris.game.igarson.app
server_config: "" server_config: ""
service_port: 10003 service_port: 6005
conf_file: ngrok.conf conf_file: games.conf
- name: encrypt all domains - name: encrypt all domains
shell: | shell: |
certbot --nginx -d {{item.server_name}} -n --redirect certbot --nginx -d {{item.server_name}} -n --redirect
with_items: with_items:
- server_name: dev.capitan.igarson.app - server_name: tetris.game.igarson.app
server_config: "" server_config: ""
service_port: 10003 service_port: 6005
conf_file: ngrok.conf conf_file: games.conf
- name: Reload nginx to activate specified site - name: Reload nginx to activate specified site
service: name=nginx state=restarted service: name=nginx state=restarted

View File

@ -0,0 +1,34 @@
---
- name: appen stacks
hosts: supermaster
become: yes
tasks:
- name: create stack template
template:
src: template/stack-block.j2
dest: /tmp/new-stack-block.{{item.service_name}}.yml
with_items:
- service_name: tetris
registry: registry.vnfco.ir/ig/game/tetris:latest
target_port: 80
source_port: 6005
stack_lvl: 6
- name: append /tmp/new-stack-block.conf to specific stack file
shell: |
cat /tmp/new-stack-block.{{item.service_name}}.yml >> /home/dockerman/stacks/lvl{{item.stack_lvl}}/stack.yml
rm -rf /tmp/new-stack-block.{{item.service_name}}.yml
with_items:
- service_name: tetris
registry: registry.vnfco.ir/ig/game/tetris:latest
target_port: 80
source_port: 6005
stack_lvl: 6

View File

@ -0,0 +1,134 @@
---
- name: server initial command
hosts: 'fts'
become: yes
become_method: sudo
become_user: root
vars_files:
- var/registry.yml
tasks:
# - name: set shecan dns
# copy:
# src: ../dns/resolv.conf
# dest: /etc/resolv.conf
# owner: root
# group: root
# mode: u=rwx,g=rwx,o=rwx
# - name: disable ufw
# shell: ufw disable
# - name: disable swap
# shell: swapoff -a
# - name: sid swap off in fstab
# shell: sed -i '/swap/d' /etc/fstab
# - name: set timezone
# shell: timedatectl set-timezone Asia/Tehran
# - name: apt-get update
# apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
# - name: add docker key and add docker repo
# shell: |
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
# - name: installing docker dependencies
# apt:
# name: "{{item}}"
# state: present
# update_cache: yes
# with_items:
# - ca-certificates
# - curl
# - gnupg
# - lsb-release
# - name: installing docker-ce and docker-ce-cli and
# apt:
# name: "{{item}}"
# state: present
# update_cache: yes
# with_items:
# - docker-ce
# - docker-ce-cli
# - containerd.io
- name: start and enable docker and containerd
service:
name: "{{item}}"
state: started
enabled: yes
with_items:
- docker
- containerd
- name: installing nginx and certbot
apt:
name: "{{item}}"
state: present
update_cache: yes
with_items:
- nginx
- letsencrypt
- python3-certbot-nginx
- name: create the docker user account
user: name=dockerman append=yes state=present createhome=yes shell=/bin/bash
- name: allow 'dockerman' to use sudo without needing a password
lineinfile:
dest: /etc/sudoers
line: 'dockerman ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
- name: add user to docker group
user:
name: dockerman
groups: docker
state: present
- name: reset and enable docker
shell: |
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
# add docker home to enviroment variable
- name: login docker
become: dockerman
shell: docker login -u {{ registry_user }} -p {{ registry_password }} {{ registry_url }}
- name: reboot
shell: reboot
ignore_errors: yes

View File

@ -0,0 +1,29 @@
{{item.service_name}}:
image: {{item.registry}}
environment:
- TZ=Asia/Tehran
deploy:
update_config:
parallelism: 1
delay: 10s
order: start-first
restart_policy:
condition: any
delay: 5s
window: 120s
resources:
limits:
cpus: '0.5'
memory: 50M
replicas: 1
mode: replicated
placement:
constraints:
- node.role == worker
ports:
- {{item.source_port}}:{{item.target_port}}
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
networks:
- mother

View File

@ -6,6 +6,8 @@
6023 api mafia 6023 api mafia
6003 quiz ==> must change 6003 quiz ==> must change
6023 api quiz ==> must change 6023 api quiz ==> must change
6005 tetris
} }
8000-9000 = base 8000-9000 = base

View File

@ -5,7 +5,7 @@ networks:
external: true external: true
services: services:
ls: webserver:
image: registry.vnfco.ir/imed/webserver:latest image: registry.vnfco.ir/imed/webserver:latest
environment: environment:
- ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_ENVIRONMENT=Production

View File

@ -0,0 +1,35 @@
version: "3.7"
networks:
mother:
external: true
services:
lord:
image: registry.vnfco.ir/amirmoghi3/me:latest
environment:
- TZ=Asia/Tehran
deploy:
update_config:
parallelism: 1
delay: 10s
order: start-first
restart_policy:
condition: any
delay: 5s
window: 120s
replicas: 1
mode: replicated
volumes:
- type: bind
source: /etc/localtime
target: /etc/localtime
read_only: true
- type: bind
source: /etc/timezone
target: /etc/timezone
read_only: true
ports:
- 8585:3000
networks:
- mother

View File

@ -0,0 +1,35 @@
version: "3.7"
networks:
mother:
external: true
services:
website:
image: registry.vnfco.ir/ftsco/website:latest
environment:
- TZ=Asia/Tehran
deploy:
update_config:
parallelism: 1
delay: 10s
order: start-first
restart_policy:
condition: any
delay: 5s
window: 120s
replicas: 1
mode: replicated
volumes:
- type: bind
source: /etc/localtime
target: /etc/localtime
read_only: true
- type: bind
source: /etc/timezone
target: /etc/timezone
read_only: true
ports:
- 3000:3000
networks:
- mother

BIN
stacks/lvl2/.DS_Store vendored

Binary file not shown.

View File

@ -71,7 +71,7 @@ services:
resources: resources:
limits: limits:
cpus: '1' cpus: '1'
memory: 500m memory: 600m
replicas: 1 replicas: 1
mode: replicated mode: replicated
placement: placement:
@ -112,11 +112,13 @@ services:
image: registry.vnfco.ir/ig/sms:latest image: registry.vnfco.ir/ig/sms:latest
environment: environment:
- QUEUE_NAME=ig-sms - QUEUE_NAME=ig-sms
- RABBIT_URI=amqp://igarsonAgent:muyXHzymcTYLzk3wYnIwG+UJWECKy0ViUDO+UlCmPF3XS+2kliuV0TaA0mWf6lT@rabbitmq:5672 - RABBIT_URI=amqp://test:test@192.168.0.108:5672
- SMS_SERVICE_URI=https://api.kavenegar.com/v1/ - SMS_SERVICE_URI=https://api.kavenegar.com/v1/
- SMS_SERVICE_CONTEXT_PATH=/sms/send.json - USERAPIKEY=3735494B4143727A794346457461576A2B4B6668414973424E333561505A694B
- USERAPIKEY=7461633837643439575446434F7161634F676C58426E674B396A5356586A3173
- SECRETKEY=!#u*(!@ofOAJDU31y+ - SECRETKEY=!#u*(!@ofOAJDU31y+
- LINENUMBER=2000500666
- VERIFICATION_SERVICE_CONTEXT_PATH=/verify/lookup.json
- SMS_SERVICE_CONTEXT_PATH=/sms/lookup.json
- TZ=Asia/Tehran - TZ=Asia/Tehran
deploy: deploy:
update_config: update_config: