Jeremy Zheng 3 лет назад
Родитель
Сommit
4ce1f653c2

+ 3 - 3
deploy/README.md

@@ -18,11 +18,11 @@ ssh-copy-id -i .ssh/id_ed25519 USER@HOST
 
 
 ```bash
 ```bash
 # test ssh connections
 # test ssh connections
-peony -i clients/CLUSTER ping.yml
+peony -i clients/CLUSTER JOB.yml
 # run on all hosts
 # run on all hosts
-peony -i clients/CLUSTER ping.yml
+peony -i clients/CLUSTER JOB.yml
 # run on only group
 # run on only group
-peony -i clients/CLUSTER ping.yml -l GROUP
+peony -i clients/CLUSTER JOB.yml -l GROUP
 ```
 ```
 
 
 ## System image
 ## System image

+ 65 - 57
deploy/roles/mint/tasks/main.yml

@@ -1,86 +1,94 @@
-- name: Git checkout source code
+- name: Git checkout source code(laravel)
   ansible.builtin.git:
   ansible.builtin.git:
     repo: "https://github.com/iapt-platform/mint.git"
     repo: "https://github.com/iapt-platform/mint.git"
     dest: "{{ app_deploy_target }}/htdocs"
     dest: "{{ app_deploy_target }}/htdocs"
     version: laravel
     version: laravel
+    force: true
 
 
-- name: Setup storage folder
-  become: true
-  ansible.builtin.file:
-    path: "{{ app_deploy_target }}/storage"
-    state: directory
-    recurse: true
-    owner: www-data
-    group: www-data
-
-- name: Install v2 php dependencies
-  ansible.builtin.shell: "php{{ app_php_version }} {{ ansible_env.HOME }}/.local/bin/composer install"
-  args:
-    chdir: "{{ app_deploy_target }}"
-
-- name: Install v2 nodejs dependencies
-  # ansible.builtin.file:
-  #   src: "/var/www/{{ inventory_hostname }}/node_modules/v2"
-  #   dest: "{{ app_deploy_target }}/node_modules"
-  #   state: link
+- name: Install v2 nodejs dependencies(laravel)
   ansible.builtin.shell: npm install
   ansible.builtin.shell: npm install
   args:
   args:
-    chdir: "{{ app_deploy_target }}"
+    chdir: "{{ app_deploy_target }}/htdocs"
 
 
 # TODO will remove in future
 # TODO will remove in future
-- name: Install v1 php dependencies
+- name: Install v1 php dependencies(laravel)
   ansible.builtin.shell: "php{{ app_php_version }} {{ ansible_env.HOME }}/.local/bin/composer install"
   ansible.builtin.shell: "php{{ app_php_version }} {{ ansible_env.HOME }}/.local/bin/composer install"
   args:
   args:
-    chdir: "{{ app_deploy_target }}/public"
+    chdir: "{{ app_deploy_target }}/htdocs/public"
 
 
 # TODO will remove in future
 # TODO will remove in future
-- name: Install v1 nodejs dependencies
-  # ansible.builtin.file:
-  #   src: "/var/www/{{ inventory_hostname }}/node_modules/v1"
-  #   dest: "{{ app_deploy_target }}/public/node_modules"
-  #   state: link
+- name: Install v1 nodejs dependencies(laravel)
   ansible.builtin.shell: npm install
   ansible.builtin.shell: npm install
   args:
   args:
-    chdir: "{{ app_deploy_target }}/public"
+    chdir: "{{ app_deploy_target }}/htdocs/public"
 
 
 # TODO will remove in future
 # TODO will remove in future
-- name: Install v1 tmp
-  ansible.builtin.file:
-    src: "/var/www/{{ inventory_hostname }}/tmp"
-    dest: "{{ app_deploy_target }}/public/tmp"
-    state: link
-
-- name: .env(v2)
+- name: Setup tmp folder(laravel)
   become: true
   become: true
-  ansible.builtin.template:
-    src: env-v2.j2
-    dest: "{{ app_deploy_target }}/.env"
+  ansible.builtin.file:
+    path: "{{ app_deploy_target }}/tmp"
+    state: directory
+    recurse: true
     owner: www-data
     owner: www-data
     group: www-data
     group: www-data
-    mode: "0400"
 
 
 # TODO will remove in future
 # TODO will remove in future
-- name: config.php(v1)
-  become: true
-  ansible.builtin.template:
-    src: config-v1.php.j2
-    dest: "{{ app_deploy_target }}/public/app/config.php"
-    owner: www-data
-    group: www-data
-    mode: "0400"
+- name: Install v1 tmp(laravel)
+  ansible.builtin.file:
+    src: "{{ app_deploy_target }}/tmp"
+    dest: "{{ app_deploy_target }}/htdocs/public/tmp"
+    state: link
 
 
-# TODO will remove in future
-- name: config.js(v1)
+- name: Install v2 php dependencies
+  ansible.builtin.shell: "php{{ app_php_version }} {{ ansible_env.HOME }}/.local/bin/composer install"
+  args:
+    chdir: "{{ app_deploy_target }}/htdocs"
+
+- name: Setup storage folder(laravel)
   become: true
   become: true
-  ansible.builtin.template:
-    src: config-v1.js.j2
-    dest: "{{ app_deploy_target }}/public/app/config.js"
+  ansible.builtin.file:
+    path: "{{ app_deploy_target }}/storage"
+    state: directory
+    recurse: true
     owner: www-data
     owner: www-data
     group: www-data
     group: www-data
-    mode: "0400"
 
 
-- name: Create a current link
+- name: Delete repo's storage folder(laravel)
+  ansible.builtin.file:
+    path: "{{ app_deploy_target }}/htdocs/storage"
+    state: absent
+
+- name: create storage link(laravel)
   ansible.builtin.file:
   ansible.builtin.file:
-    src: "{{ app_deploy_target }}"
-    dest: /var/www/{{ inventory_hostname }}/current
+    src: "{{ app_deploy_target }}/storage"
+    dest: "{{ app_deploy_target }}/htdocs/storage"
     state: link
     state: link
+
+- name: create v2 config file(laravel)
+  ansible.builtin.file:
+    src: "{{ app_deploy_target }}/etc/v2.env"
+    dest: "{{ app_deploy_target }}/htdocs/.env"
+    state: link
+
+# FIXME
+- name: create v1 config file(laravel)
+  ansible.builtin.file:
+    src: "{{ app_deploy_target }}/etc/v1.php"
+    dest: "{{ app_deploy_target }}/htdocs/public/app/config.php"
+    state: link
+
+- name: Git checkout source code(agile)
+  ansible.builtin.git:
+    repo: "https://github.com/iapt-platform/mint.git"
+    dest: "{{ app_deploy_target }}/agile"
+    version: agile
+
+- name: Install dashboard dependencies(agile)
+  ansible.builtin.shell: yarn install
+  args:
+    chdir: "{{ app_deploy_target }}/agile/dashboard"
+
+- name: Build dashboard (agile)
+  ansible.builtin.shell: BUILD_PATH={{ app_deploy_target }}/dashboard PUBLIC_URL=/pcd yarn build
+  args:
+    chdir: "{{ app_deploy_target }}/agile/dashboard"

+ 0 - 14
deploy/roles/mint/templates/config-v1.js.j2

@@ -1,14 +0,0 @@
-var RPC_SERVER="https://{{ app_rpc_host }}";
-
-/*
-  |---------------
-  |网站资源文件,非用户的图片,音频,视频
-  |---------------
-  |对应/public/tmp/ 目录 开发线可以设置为 http://127.0.0.1:8000/tmp
-  |所有文件存储在 https://drive.google.com/drive/folders/1-4dn4juD-0-lsKndDui2W9nT9wcS_Y33?usp=sharing
-  |开发线可自行下载放到/public/tmp/
-  |或直接引用离您最近的assets server
-  |------------------------
-*/
-
-var ASSETS_SERVER = "https://assets-{{ app_cluster_domain }}"

+ 0 - 60
deploy/roles/mint/templates/config-v1.php.j2

@@ -1,60 +0,0 @@
-<?php
-
-#域名设置
-define("RPC_SERVER","https://{{ app_rpc_host }}");
-define("ASSETS_SERVER","https://assets-{{ app_cluster_domain }}");
-/*
-电子邮件设置
-PHPMailer
-*/
-define("Email", [
-				 "Host"=>"smtp.gmail.com",//Set the SMTP server to send through
-				 "SMTPAuth"=>true,//Enable SMTP authentication
-				 "Username"=>'{{ app_smtp_username }}',//SMTP username
-				 "Password"=>'{{ app_smtp_password }}',//SMTP password
-				 "Port"=>465,//TCP port to connect to 465; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
-				 "From"=>"{{ app_smtp_username }}",
-				 "Sender"=>"webmaster"
-				 ]);
-
-/*
-数据库设置
-*/
-define("Database",[
-	"type"=>"pgsql",
-	"server"=>"{{ app_postgresql_host }}",
-	"port"=>{{ app_postgresql_port }},
-	"name"=>"{{ app_postgresql_name }}",
-	"sslmode" => "disable",
-	"user" => "{{ app_postgresql_user }}",
-	"password" => "{{ app_postgresql_password }}"
-]);
-
-
-/*
-Redis 设置,
-*/
-define("Redis",[
-	"host" => "{{ app_redis_host }}",
-	"port" => 6379,
-	"password" => "",
-	"namespace" => "{{ app_redis_namespace }}"
-]);
-
-# 雪花id
-define("SnowFlake",[
-	"DatacenterId"=>1,
-	"WorkerId"=>1
-]);
-
-#目录设置,不能更改
-require_once __DIR__."/config.dir.php";
-
-/*
-数据表
-*/
-#表设置,此行不能更改
-require_once __DIR__."/config.table.php";
-
-
-?>

+ 0 - 62
deploy/roles/mint/templates/env-v2.j2

@@ -1,62 +0,0 @@
-BASE_DIR="{{ app_deploy_target }}/.env.global"
-CACHE_DIR="${BASE_DIR}/cache"
-TMP_DIR="${BASE_DIR}/tmp"
-
-APP_NAME=wikipali
-APP_ENV=production
-APP_KEY="{{ app_laravel_key }}"
-APP_DEBUG=false
-APP_URL="https://{{ inventory_hostname }}"
-
-LOG_CHANNEL=stack
-LOG_DEPRECATIONS_CHANNEL=null
-LOG_LEVEL=info
-
-DB_CONNECTION=pgsql
-DB_HOST={{ app_postgresql_host }}
-DB_PORT={{ app_postgresql_port }}
-DB_DATABASE={{ app_postgresql_name }}
-DB_USERNAME={{ app_postgresql_user }}
-DB_PASSWORD="{{ app_postgresql_password }}"
-
-BROADCAST_DRIVER=log
-CACHE_DRIVER=redis
-FILESYSTEM_DRIVER=local
-QUEUE_CONNECTION=sync
-SESSION_DRIVER=file
-SESSION_LIFETIME=120
-
-MEMCACHED_HOST=127.0.0.1
-
-REDIS_HOST={{ app_redis_host }}
-REDIS_PASSWORD=null
-REDIS_PORT=6379
-REDIS_NAMESPACE="{{ app_redis_namespace }}"
-
-MAIL_MAILER=smtp
-MAIL_HOST=smtp.gmail.com
-MAIL_PORT=465
-MAIL_USERNAME={{ app_smtp_username }}
-MAIL_PASSWORD="{{ app_smtp_password }}"
-MAIL_ENCRYPTION=ssl
-MAIL_FROM_ADDRESS={{ app_smtp_username }}
-MAIL_FROM_NAME="webmaster"
-
-AWS_ACCESS_KEY_ID=
-AWS_SECRET_ACCESS_KEY=
-AWS_DEFAULT_REGION=us-east-1
-AWS_BUCKET=
-AWS_USE_PATH_STYLE_ENDPOINT=false
-
-PUSHER_APP_ID=
-PUSHER_APP_KEY=
-PUSHER_APP_SECRET=
-PUSHER_APP_CLUSTER=mt1
-
-MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
-MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
-
-ASSETS_SERVER="https://assets-{{ app_cluster_domain }}"
-RPC_SERVER="https://{{ app_rpc_host }}"
-SNOWFLAKE_DATA_CENTER_ID=1
-SNOWFLAKE_WORKER_ID=1

+ 0 - 15
deploy/roles/ubuntu/tasks/armbian.yml

@@ -1,15 +0,0 @@
-- name: backup /boot/armbianEnv.txt
-  become: true
-  copy:
-    src: /boot/armbianEnv.txt
-    dest: "{{ app_backup }}/boot_armbianEnv_txt"
-    remote_src: yes
-    backup: yes
-  
-- name: enable uart for armbian
-  become: true
-  lineinfile:
-    path: /boot/armbianEnv.txt
-    regexp: '^overlays='
-    line: overlays=usbhost2 usbhost3 uart1 uart2 analog-codec
-

+ 0 - 60
deploy/roles/ubuntu/tasks/friendly-core.yml

@@ -1,60 +0,0 @@
-
-- name: backup serial-getty@ttyAMA0.service.d/autologin.conf
-  become: true
-  ansible.builtin.copy:
-    src: /etc/systemd/system/serial-getty@ttyAMA0.service.d/autologin.conf
-    dest: "{{ app_backup }}/ttyAMA0_autologin_conf"
-    remote_src: yes
-    backup: yes
-
-- name: disable autologin for ttyAMA0
-  become: true
-  ansible.builtin.replace:
-    path: /etc/systemd/system/serial-getty@ttyAMA0.service.d/autologin.conf
-    regexp: ' --autologin pi '
-    replace: ' '
-
-- name: backup getty@tty1.service.d/autologin.conf
-  become: true
-  ansible.builtin.copy:
-    src: /etc/systemd/system/getty@tty1.service.d/autologin.conf
-    dest: "{{ app_backup }}/tty1_autologin_conf"
-    remote_src: yes
-    backup: yes
-
-- name: disable autologin for tty1
-  become: true
-  ansible.builtin.replace:
-    path: /etc/systemd/system/getty@tty1.service.d/autologin.conf
-    regexp: ' --autologin pi '
-    replace: ' '
-
-- name: backup serial-getty@ttyS0.service.d/autologin.conf
-  become: true
-  ansible.builtin.copy:
-    src: /etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf
-    dest: "{{ app_backup }}/ttyS0_autologin_conf"
-    remote_src: yes
-    backup: yes
-
-- name: disable autologin for ttyS0
-  become: true
-  ansible.builtin.replace:
-    path: /etc/systemd/system/serial-getty@ttyS0.service.d/autologin.conf
-    regexp: ' --autologin pi '
-    replace: ' '
-
-- name: backup serial-getty@ttySAC0.service.d/autologin.conf
-  become: true
-  ansible.builtin.copy:
-    src: /etc/systemd/system/serial-getty@ttySAC0.service.d/autologin.conf
-    dest: "{{ app_backup }}/ttySAC0_autologin_conf"
-    remote_src: yes
-    backup: yes
-
-- name: disable autologin for ttySAC0
-  become: true
-  ansible.builtin.replace:
-    path: /etc/systemd/system/serial-getty@ttySAC0.service.d/autologin.conf
-    regexp: ' --autologin pi '
-    replace: ' '

+ 2 - 61
deploy/roles/ubuntu/tasks/main.yml

@@ -1,38 +1,5 @@
-# - name: Remove postfix at first
-#   become: true
-#   apt:
-#     name: postfix
-#     state: absent
-#     purge: yes
-
-# - name: Backup /etc/apt/sources.list.d
-#   become: true
-#   copy:
-#     src: /etc/apt/sources.list.d
-#     dest: "{{ app_backup }}/etc_apt_sources_list_d"
-#     remote_src: yes
-#     backup: yes
-
-# - name: Delete /etc/apt/sources.list.d
-#   become: true
-#   file:
-#     state: absent
-#     path: /etc/apt/sources.list.d
-
 - import_tasks: init.yml
 - import_tasks: init.yml
 
 
-# https://github.com/nodesource/distributions#deb
-# - name: Download nodejs-ppa installer
-#   get_url:
-#     url: https://deb.nodesource.com/setup_lts.x
-#     dest: "{{ app_downloads }}/setup_node_lts.sh"
-#     mode: '0755'
-
-# - name: Install nodejs ppa
-#   become: true
-#   ansible.builtin.shell: "{{ app_downloads }}/setup_node_lts.sh"
-
-
 - name: add PPA for Ubuntu Toolchain
 - name: add PPA for Ubuntu Toolchain
   become: true
   become: true
   ansible.builtin.apt_repository:
   ansible.builtin.apt_repository:
@@ -68,7 +35,6 @@
       - lshw
       - lshw
       - tcpdump
       - tcpdump
       - lm-sensors
       - lm-sensors
-      - hddtemp
       - dmidecode
       - dmidecode
       - net-tools
       - net-tools
       - iputils-arping
       - iputils-arping
@@ -103,6 +69,7 @@
       - tmux
       - tmux
       - hugo
       - hugo
       - nodejs
       - nodejs
+      - npm
       - python3
       - python3
       - python3-pip
       - python3-pip
       - python3-distutils
       - python3-distutils
@@ -110,6 +77,7 @@
       - libssl-dev
       - libssl-dev
       - libpq-dev
       - libpq-dev
       - libmysqlclient-dev
       - libmysqlclient-dev
+      - libevent-dev
 
 
 - name: Install dependicy packages(>bionic)
 - name: Install dependicy packages(>bionic)
   become: true
   become: true
@@ -120,8 +88,6 @@
   # ansible_facts['distribution'] == "Ubuntu"
   # ansible_facts['distribution'] == "Ubuntu"
   when: ansible_facts['distribution_major_version'] | int >= 20
   when: ansible_facts['distribution_major_version'] | int >= 20
 
 
-
-
 - import_tasks: locales.yml
 - import_tasks: locales.yml
 
 
 - name: Set default editor to vim
 - name: Set default editor to vim
@@ -140,30 +106,6 @@
 
 
 # ---------------------------------------------------
 # ---------------------------------------------------
 
 
-- name: check if friendlyelec
-  ansible.builtin.stat:
-    path: /etc/friendlyelec-release
-  register: app_os_friendlyelec
-
-- import_tasks: friendly-core.yml
-  when: app_os_friendlyelec.stat.islnk is defined and app_os_friendlyelec.stat.isreg
-
-- name: check if armbian
-  ansible.builtin.stat:
-    path: /etc/armbian-release
-  register: app_os_armbian
-
-- import_tasks: armbian.yml
-  when: app_os_armbian.stat.islnk is defined and app_os_armbian.stat.isreg
-
-- import_tasks: raspbian.yml
-  when: ansible_distribution == 'Raspbian'
-
-- import_tasks: pi.yml
-  when: ansible_distribution == 'Raspbian' or (app_os_armbian.stat.islnk is defined and app_os_armbian.stat.isreg) or (app_os_friendlyelec.stat.islnk is defined and app_os_friendlyelec.stat.isreg)
-
-# ---------------------------------------------------
-
 - name: enable nginx service
 - name: enable nginx service
   become: true
   become: true
   ansible.builtin.systemd:
   ansible.builtin.systemd:
@@ -192,5 +134,4 @@
     enabled: yes
     enabled: yes
     masked: no
     masked: no
 
 
-
 - import_tasks: clean.yml
 - import_tasks: clean.yml

+ 0 - 52
deploy/roles/ubuntu/tasks/raspbian.yml

@@ -1,52 +0,0 @@
-# https://www.raspberrypi.org/documentation/configuration/uart.md
-
-- name: backup /boot/config.txt
-  become: true
-  ansible.builtin.copy:
-    src: /boot/config.txt
-    dest: "{{ app_backup }}/boot_config_txt"
-    remote_src: yes
-    backup: yes
-
-- name: enable uart
-  become: true
-  lineinfile:
-    path: /boot/config.txt
-    regexp: '^enable_uart='
-    line: enable_uart=1
-
-- name: disable bluetooth
-  become: true
-  lineinfile:
-    path: /boot/config.txt
-    regexp: '^dtoverlay='
-    line: dtoverlay=disable-bt
-
-- name: hidden splash message
-  become: true
-  lineinfile:
-    path: /boot/config.txt
-    regexp: '^disable_splash='
-    line: disable_splash=1 
-
-- name: backup /boot/cmdline.txt
-  become: true
-  ansible.builtin.copy:
-    src: /boot/cmdline.txt
-    dest: "{{ app_backup }}/boot_cmdline_txt"
-    remote_src: yes
-    backup: yes
-
-- name: disable debug port & logo
-  become: true
-  ansible.builtin.replace:
-    path: /boot/cmdline.txt
-    regexp: 'console=serial0,115200'
-    replace: 'loglevel=3 logo.nologo'
-
-- name: disable hciuart service
-  become: true
-  ansible.builtin.systemd:
-    name: hciuart
-    enabled: no
-    masked: yes

+ 3 - 3
deploy/scripts/laravel-react.sh

@@ -41,9 +41,9 @@ server {
   client_max_body_size 128M;
   client_max_body_size 128M;
   
   
 
 
-  location /my/ {
-    alias /var/www/$1/current/dashboard/;
-    try_files \$uri \$uri/ /my/index.html;
+  location /pcd/ {
+    alias /var/www/$1/dashboard/;
+    try_files \$uri \$uri/ /pcd/index.html;
     
     
     location ~* \\.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)\$ {
     location ~* \\.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)\$ {
       access_log off;
       access_log off;