mirror of
https://github.com/Expand-sys/CCash
synced 2026-03-22 20:47:10 +11:00
Merge branch 'v2.5.1' of https://github.com/EntireTwix/CCash into v2.5.1
This commit is contained in:
commit
d303016124
4 changed files with 158 additions and 44 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
[all]
|
[all]
|
||||||
10.10.0.145 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no'
|
127.0.0.1 ansible_ssh_user=root ansible_ssh_common_args='-o StrictHostKeyChecking=no'
|
||||||
|
|
@ -4,9 +4,10 @@
|
||||||
become: true
|
become: true
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: load variables
|
- name: load variables
|
||||||
ansible.builtin.include_vars: "{{ item }}"
|
ansible.builtin.include_vars: '{{ item }}'
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- "default.yml"
|
- "vars/default.yml"
|
||||||
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: refresh packages update
|
- name: refresh packages update
|
||||||
|
|
@ -23,30 +24,22 @@
|
||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
yum:
|
yum:
|
||||||
name:
|
name: [git, gcc, gcc-c++, libuuid-devel, openssl-devel, zlib-devel, jsoncpp-devel, cmake]
|
||||||
[
|
|
||||||
git,
|
|
||||||
gcc,
|
|
||||||
gcc-c++,
|
|
||||||
libuuid-devel,
|
|
||||||
openssl-devel,
|
|
||||||
zlib-devel,
|
|
||||||
jsoncpp-devel,
|
|
||||||
cmake,
|
|
||||||
]
|
|
||||||
state: present
|
state: present
|
||||||
when: ansible_os_family == "RedHat"
|
when: ansible_os_family == "RedHat"
|
||||||
|
|
||||||
- name: clone CCash repository
|
- name: clone CCash repository
|
||||||
git:
|
git:
|
||||||
repo: https://github.com/EntireTwix/CCash.git
|
repo: https://github.com/EntireTwix/CCash.git
|
||||||
dest: "{{BUILD_DIR}}/CCash"
|
dest: '{{BUILD_DIR}}/CCash'
|
||||||
recursive: true
|
recursive: true
|
||||||
update: false
|
update: true
|
||||||
|
force: true
|
||||||
|
version: "{{ BRANCH }}"
|
||||||
|
|
||||||
- name: Make lib base64
|
- name: Make lib base64
|
||||||
community.general.make:
|
community.general.make:
|
||||||
chdir: "{{BUILD_DIR}}/CCash/third_party/base64"
|
chdir: '{{BUILD_DIR}}/CCash/third_party/base64'
|
||||||
params:
|
params:
|
||||||
AVX2_CFLAGS: -mavx2
|
AVX2_CFLAGS: -mavx2
|
||||||
SSSE3_CFLAGS: -mssse3
|
SSSE3_CFLAGS: -mssse3
|
||||||
|
|
@ -56,49 +49,161 @@
|
||||||
|
|
||||||
- name: create build dir
|
- name: create build dir
|
||||||
file:
|
file:
|
||||||
path: "{{BUILD_DIR}}/CCash/build"
|
path: '{{BUILD_DIR}}/CCash/build'
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Cmake CCash
|
- name: Cmake CCash
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
chdir: "{{BUILD_DIR}}/CCash/build"
|
chdir: '{{BUILD_DIR}}/CCash/build'
|
||||||
cmd: |
|
cmd: |
|
||||||
cmake -DDROGON_CONFIG_LOC="{{ BUILD_DIR }}/CCash/config/config.json" -DUSER_SAVE_LOC="{{ BUILD_DIR }}/CCash/config/users.dat" -DUSE_DEPRECATED_ENDPOINTS="{{ USE_DEPRECATED_ENDPOINTS }}" ..
|
cmake -DDROGON_CONFIG_LOC="{{ BUILD_DIR }}/CCash/config/config.json" -DUSER_SAVE_LOC="{{ BUILD_DIR }}/CCash/config/users.dat" -DUSE_DEPRECATED_ENDPOINTS="{{ USE_DEPRECATED_ENDPOINTS }}" ..
|
||||||
|
|
||||||
- name: make CCash
|
- name: make CCash
|
||||||
community.general.make:
|
community.general.make:
|
||||||
chdir: "{{BUILD_DIR}}/CCash/build"
|
chdir: '{{BUILD_DIR}}/CCash/build'
|
||||||
params:
|
params:
|
||||||
NUM_THREADS: "-j{{ ansible_processor_vcpus }}"
|
NUM_THREADS: '-j{{ ansible_processor_vcpus }}'
|
||||||
|
|
||||||
|
|
||||||
- name: create users file
|
- name: create users file
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
chdir: "{{BUILD_DIR}}/CCash/build/"
|
chdir: '{{BUILD_DIR}}/CCash/build/'
|
||||||
cmd: ./bank
|
cmd: ./bank
|
||||||
creates: "{{ BUILD_DIR }}/CCash/config/users.dat"
|
creates: '{{ BUILD_DIR }}/CCash/config/users.dat'
|
||||||
- name: chmod +x ssl.sh
|
- name: chmod +x ssl.sh
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
mode: u+x
|
mode: u+x
|
||||||
path: "{{BUILD_DIR}}/CCash/config/ssl.sh"
|
path: '{{BUILD_DIR}}/CCash/config/ssl.sh'
|
||||||
- name: generate default ssl
|
- name: create ssl gen file
|
||||||
ansible.builtin.command:
|
|
||||||
chdir: "{{BUILD_DIR}}/CCash/config/"
|
|
||||||
cmd: "./ssl.sh"
|
|
||||||
|
|
||||||
- name: create service file
|
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
content: |
|
content: |
|
||||||
[Unit]
|
{
|
||||||
Description=CCash API Server
|
"listeners": [
|
||||||
After=network.target remote-fs.target nss-lookup.target
|
{
|
||||||
|
"address": "0.0.0.0",
|
||||||
|
"port": 80,
|
||||||
|
"https": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"address": "0.0.0.0",
|
||||||
|
"port": 443,
|
||||||
|
"https": true,
|
||||||
|
"cert": "{{ BUILD_DIR }}/CCash/config/cert.cert",
|
||||||
|
"key": "{{ BUILD_DIR }}/CCash/config/key.key"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
dest: "{{ BUILD_DIR }}/CCash/config/config.json"
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
ExecStart={{BUILD_DIR}}/CCash/build/bank {{ADMIN_A}} {{SAVE_FREQ}}
|
|
||||||
ExecStop=/bin/kill -WINCH ${MAINPID}
|
|
||||||
KillSignal=SIGCONT
|
|
||||||
PrivateTmp=true
|
|
||||||
|
|
||||||
[Install]
|
- name: create ssl gen file
|
||||||
WantedBy=multi-user.target
|
ansible.builtin.copy:
|
||||||
dest: /etc/systemd/system/ccash.service
|
content: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
openssl genrsa -out server.pass.key 2048
|
||||||
|
openssl rsa -in server.pass.key -out {{ BUILD_DIR }}/CCash/config/key.key
|
||||||
|
rm server.pass.key
|
||||||
|
openssl req -new -key {{ BUILD_DIR }}/CCash/config/key.key -out server.csr \
|
||||||
|
-subj "/C=US/ST=CCashland/L=NEW CCASH/O=CCash/OU=Devs/CN=localhost"
|
||||||
|
openssl x509 -req -days 365 -in server.csr -signkey {{ BUILD_DIR }}/CCash/config/key.key -out {{ BUILD_DIR }}/CCash/config/cert.cert
|
||||||
|
dest: "{{ BUILD_DIR }}/CCash/config/ssl.sh"
|
||||||
|
|
||||||
|
- name: generate default ssl
|
||||||
|
ansible.builtin.command:
|
||||||
|
chdir: '{{BUILD_DIR}}/CCash/config/'
|
||||||
|
cmd: './ssl.sh'
|
||||||
|
|
||||||
|
- name: Start CCash Api Server
|
||||||
|
ansible.builtin.command:
|
||||||
|
chdir: '{{ BUILD_DIR }}/CCash/build'
|
||||||
|
cmd: './bank {{ ADMIN_A }} {{ SAVE_FREQ }} true'
|
||||||
|
|
||||||
|
- name: Clone Web
|
||||||
|
git:
|
||||||
|
repo: https://github.com/Expand-sys/ccashfrontend.git
|
||||||
|
dest: '{{BUILD_DIR}}/CCash/web'
|
||||||
|
recursive: true
|
||||||
|
update: true
|
||||||
|
force: true
|
||||||
|
|
||||||
|
when: WEB_ENABLED == true
|
||||||
|
|
||||||
|
- name: "Install Nodejs 18 module"
|
||||||
|
command: dnf module install -y nodejs:18/common
|
||||||
|
register: result
|
||||||
|
changed_when:
|
||||||
|
- '"Enabling module streams" in result.stdout'
|
||||||
|
when: ansible_os_family == "RedHat" and WEB_ENABLED == true
|
||||||
|
|
||||||
|
|
||||||
|
- name: install pm2
|
||||||
|
community.general.npm:
|
||||||
|
path: '{{ BUILD_DIR }}/CCash/web'
|
||||||
|
name: pm2
|
||||||
|
global: true
|
||||||
|
when: WEB_ENABLED == true
|
||||||
|
|
||||||
|
- name: install web dependencies
|
||||||
|
community.general.npm:
|
||||||
|
path: '{{ BUILD_DIR }}/CCash/web'
|
||||||
|
when: WEB_ENABLED == true
|
||||||
|
|
||||||
|
- name: create .env file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: |
|
||||||
|
BANKAPIURL={{ ansible_facts["all_ipv4_addresses"][0] }}
|
||||||
|
SECURE=true
|
||||||
|
SETUP=true
|
||||||
|
PORT={{ WEB_PORT }}
|
||||||
|
dest: '{{ BUILD_DIR }}/CCash/web/.env'
|
||||||
|
when: WEB_ENABLED == true
|
||||||
|
|
||||||
|
- name: create pm2 file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: |
|
||||||
|
{
|
||||||
|
"name": "ccashfrontend",
|
||||||
|
"script": "{{ BUILD_DIR }}/ccash/web/index.js",
|
||||||
|
"watch": "{{ BUILD_DIR }}/ccash/web/tmp/restart.txt",
|
||||||
|
"instances": "1"
|
||||||
|
}
|
||||||
|
dest: "{{ BUILD_DIR }}/CCash/web/pm2.json"
|
||||||
|
when: WEB_ENABLED == true
|
||||||
|
|
||||||
|
|
||||||
|
- name: start webapp service
|
||||||
|
ansible.builtin.command:
|
||||||
|
chdir: "{{ BUILD_DIR }}/CCash/web"
|
||||||
|
cmd: |
|
||||||
|
pm2 start index.js --update-env --name 'CCashFrontend' -f
|
||||||
|
when: START_SERVICES == true and WEB_ENABLED == true
|
||||||
|
|
||||||
|
- name: enable web app on boot
|
||||||
|
ansible.builtin.command:
|
||||||
|
chdir: "{{ BUILD_DIR }}/CCash/web"
|
||||||
|
cmd: |
|
||||||
|
pm2 startup
|
||||||
|
when: START_ON_BOOT == true and START_SERVICES == true and WEB_ENABLED == true
|
||||||
|
- name: enable ccash on boot
|
||||||
|
ansible.builtin.cron:
|
||||||
|
name: CCash enable on boot
|
||||||
|
special_time: reboot
|
||||||
|
state: present
|
||||||
|
job: '{{ BUILD_DIR }}/CCash/build/bank {{ ADMIN_A }} {{ SAVE_FREQ }} true'
|
||||||
|
when: START_ON_BOOT == true
|
||||||
|
|
||||||
|
- name: allow firewalld ports
|
||||||
|
ansible.posix.firewalld:
|
||||||
|
permanent: true
|
||||||
|
port: 443/tcp
|
||||||
|
state: enabled
|
||||||
|
|
||||||
|
- name: allow firewalld ports
|
||||||
|
ansible.posix.firewalld:
|
||||||
|
permanent: true
|
||||||
|
port: 3000/tcp
|
||||||
|
state: enabled
|
||||||
|
when: WEB_ENABLED == true
|
||||||
|
|
||||||
|
|
|
||||||
4
deployment/requirements.yml
Normal file
4
deployment/requirements.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
collections:
|
||||||
|
- ansible.posix
|
||||||
|
- community.general
|
||||||
|
|
@ -3,3 +3,8 @@ BUILD_DIR: "/root"
|
||||||
ADMIN_A: "admin"
|
ADMIN_A: "admin"
|
||||||
SAVE_FREQ: "2"
|
SAVE_FREQ: "2"
|
||||||
USE_DEPRECATED_ENDPOINTS: "true"
|
USE_DEPRECATED_ENDPOINTS: "true"
|
||||||
|
WEB_ENABLED: true
|
||||||
|
WEB_PORT: "3000"
|
||||||
|
START_SERVICES: true
|
||||||
|
START_ON_BOOT: true
|
||||||
|
BRANCH: "v2.5.1"
|
||||||
Loading…
Reference in a new issue