2024-02-07 12:20:05 +01:00
|
|
|
---
|
|
|
|
- name: dabo
|
2024-02-07 14:34:58 +01:00
|
|
|
hosts: all
|
2024-02-07 12:20:05 +01:00
|
|
|
tasks:
|
|
|
|
|
|
|
|
- name: Create /home/docker/dabo.{{inventory_hostname}} dir
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: /home/docker/dabo.{{inventory_hostname}}
|
|
|
|
owner: root
|
|
|
|
group: docker
|
|
|
|
state: directory
|
|
|
|
mode: '0550'
|
|
|
|
|
|
|
|
- name: Git checkout
|
|
|
|
ansible.builtin.git:
|
2024-12-18 13:07:01 +01:00
|
|
|
repo: 'https://github.com/egabosh/dabo.git'
|
2024-02-07 12:20:05 +01:00
|
|
|
dest: /home/docker/dabo.{{inventory_hostname}}
|
|
|
|
force: true
|
|
|
|
notify: Restart dabo
|
|
|
|
|
2024-12-18 13:07:01 +01:00
|
|
|
- name: /home/docker/dabo.{{inventory_hostname}}/initiate.sh
|
2024-02-07 12:20:05 +01:00
|
|
|
blockinfile:
|
2024-12-18 13:07:01 +01:00
|
|
|
path: /home/docker/dabo.{{inventory_hostname}}/initiate.sh
|
2024-02-07 12:20:05 +01:00
|
|
|
create: yes
|
|
|
|
mode: 0550
|
|
|
|
owner: root
|
|
|
|
group: docker
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK"
|
|
|
|
block: |
|
|
|
|
cd /home/docker/dabo.{{inventory_hostname}}
|
|
|
|
|
|
|
|
if ! [ -d home/.ssh ]
|
|
|
|
then
|
|
|
|
mkdir -p home/.ssh
|
|
|
|
ssh-keygen -f home/.ssh/id_ed25519 -N "" -t ed25519 >/dev/null
|
|
|
|
chmod 700 home/.ssh
|
|
|
|
fi
|
2024-12-18 13:07:01 +01:00
|
|
|
mkdir -p data/botdata strategies
|
|
|
|
chown -R 10000:10000 dabo data home strategies dabo-bot.conf
|
2024-02-07 12:20:05 +01:00
|
|
|
|
|
|
|
backup: yes
|
|
|
|
validate: /bin/bash -n %s
|
2024-12-18 13:07:01 +01:00
|
|
|
notify: run initiate.sh
|
2024-02-07 12:20:05 +01:00
|
|
|
|
2024-12-18 13:07:01 +01:00
|
|
|
- name: /home/docker/dabo.{{inventory_hostname}}/initiate.sh shebang
|
2024-02-07 12:20:05 +01:00
|
|
|
lineinfile:
|
2024-12-18 13:07:01 +01:00
|
|
|
path: /home/docker/dabo.{{inventory_hostname}}/initiate.sh
|
2024-02-07 12:20:05 +01:00
|
|
|
insertbefore: BOF
|
|
|
|
line: "#!/bin/bash -e"
|
|
|
|
|
|
|
|
|
|
|
|
- name: Basic dabo config
|
|
|
|
blockinfile:
|
|
|
|
path: /home/docker/dabo.{{inventory_hostname}}/dabo-bot.conf
|
|
|
|
create: yes
|
|
|
|
mode: 0440
|
|
|
|
owner: 10000
|
|
|
|
group: 10000
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK"
|
|
|
|
block: |
|
|
|
|
URL=dabo.{{inventory_hostname}}
|
|
|
|
validate: /bin/bash -n %s
|
|
|
|
backup: yes
|
|
|
|
notify:
|
|
|
|
- Restart dabo
|
|
|
|
|
|
|
|
|
2024-11-25 16:53:48 +01:00
|
|
|
#- name: Get crypted PW
|
2024-12-18 13:07:01 +01:00
|
|
|
# shell: bash /home/docker/dabo.{{inventory_hostname}}/initiate.sh
|
2024-11-25 16:53:48 +01:00
|
|
|
# register: cryptpw
|
|
|
|
# changed_when: false
|
2024-02-07 12:20:05 +01:00
|
|
|
|
|
|
|
- name: /home/docker/dabo.{{inventory_hostname}}/docker-compose.override.yml Container Configuration
|
|
|
|
blockinfile:
|
|
|
|
path: /home/docker/dabo.{{inventory_hostname}}/docker-compose.override.yml
|
|
|
|
create: yes
|
|
|
|
mode: 0440
|
|
|
|
owner: root
|
|
|
|
group: docker
|
|
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK"
|
|
|
|
block: |
|
2024-12-18 12:43:04 +01:00
|
|
|
networks:
|
|
|
|
dabo-network:
|
|
|
|
driver: bridge
|
|
|
|
driver_opts:
|
|
|
|
com.docker.network.bridge.name: br-dabo
|
|
|
|
traefik:
|
|
|
|
external: true
|
|
|
|
|
2024-02-07 12:20:05 +01:00
|
|
|
services:
|
|
|
|
|
|
|
|
dabo-bot:
|
|
|
|
networks:
|
|
|
|
- traefik
|
|
|
|
- dabo-network
|
|
|
|
|
|
|
|
dabo-web:
|
|
|
|
labels:
|
|
|
|
- traefik.enable=true
|
|
|
|
# HTTPS
|
|
|
|
- traefik.http.routers.dabo.rule=Host(`dabo.{{inventory_hostname}}`)
|
|
|
|
- traefik.http.routers.dabo.entrypoints=https
|
|
|
|
- traefik.http.routers.dabo.tls=true
|
|
|
|
# Proxy to service-port
|
|
|
|
- traefik.http.services.dabo.loadbalancer.server.port=80
|
|
|
|
- traefik.http.routers.dabo.service=dabo
|
|
|
|
# cert via letsencrypt
|
|
|
|
- traefik.http.routers.dabo.tls.certresolver=letsencrypt
|
|
|
|
# activate secHeaders@file
|
2024-11-25 16:53:48 +01:00
|
|
|
- traefik.http.routers.dabo.middlewares=secHeaders@file,default-basic-auth@file
|
2024-02-07 12:20:05 +01:00
|
|
|
# Traefik network
|
|
|
|
- traefik.docker.network=traefik
|
|
|
|
networks:
|
|
|
|
- traefik
|
|
|
|
backup: yes
|
|
|
|
notify: Restart dabo
|
|
|
|
|
|
|
|
- name: Build dabo-bot
|
|
|
|
ansible.builtin.shell: docker -l warn compose --ansi never build --progress=plain --pull --no-cache --force-rm
|
|
|
|
args:
|
|
|
|
chdir: /home/docker/dabo.{{inventory_hostname}}
|
|
|
|
creates: /home/docker/dabo.{{inventory_hostname}}/data/botdata/MARKET_PERFORMANCE
|
|
|
|
|
|
|
|
|
|
|
|
handlers:
|
|
|
|
|
2024-12-18 13:07:01 +01:00
|
|
|
- name: run initiate.sh
|
|
|
|
ansible.builtin.shell: ./initiate.sh
|
2024-02-07 12:20:05 +01:00
|
|
|
args:
|
|
|
|
chdir: /home/docker/dabo.{{inventory_hostname}}
|
|
|
|
notify: Restart dabo
|
|
|
|
|
|
|
|
- name: Restart dabo
|
|
|
|
ansible.builtin.shell: docker compose up -d --force-recreate
|
|
|
|
args:
|
|
|
|
chdir: /home/docker/dabo.{{inventory_hostname}}
|
2024-12-18 13:07:01 +01:00
|
|
|
|