Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add playbooks for separate sensor testing server #64

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions ansible/playbooks/initial-setup-sensor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Separate sensor setup so as not to risk messing with stage or prod
---
- name: Install docker
hosts: sensor
user: root
tasks:
- name: Install prerequisites for apt
apt:
update_cache: yes
pkg:
- aptitude
- apt-transport-https

- name: Install prerequisites for docker
apt:
update_cache: yes
pkg:
- ca-certificates
- curl
- gnupg-agent
- software-properties-common

- name: Add key from docker
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present

- name: Print out host architecture
debug:
msg: "Architecture detected: {{ansible_architecture}}"

- name: Add docker repository
when: ansible_architecture == "x86_64"
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable

- name: Install docker CE
apt:
update_cache: yes
pkg:
- docker-ce
- name: Install docker-compose
hosts: sensor
user: root
tasks:
- name: Create docker plugins directory
file:
path: ~/.docker/cli-plugins/
state: directory

- name: Download docker compose binary and set to executable
ansible.builtin.get_url:
url: https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64
dest: ~/.docker/cli-plugins/docker-compose
mode: '755'

- name: Get docker compose version
shell: 'docker compose version'
register: command_output

- name: Print out docker compose version
debug:
var: command_output.stdout_lines
36 changes: 36 additions & 0 deletions ansible/playbooks/start-sensor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Update sensor server
hosts: sensor
user: root
tasks:
- name: Copy .env for staging
ansible.builtin.copy:
src: ../.env.sensor
dest: ~/.env.sensor
mode: '0644'
- name: Copy private package token
ansible.builtin.copy:
src: ../SECRET_read_private_packages_token
dest: ~/SECRET_read_private_packages_token
mode: '0644'
- name: Copy private sensor token
ansible.builtin.copy:
src: ../id_rsa_perfectfitsensor
dest: ~/id_rsa_perfectfitsensor
mode: '0644'
- name: Copy docker compose sensor yml
ansible.builtin.copy:
src: ../sensor/docker-compose.sensor.yml
dest: ~/docker-compose.sensor.yml
mode: '0644'
- name: Log into docker ghcr
shell: cat SECRET_read_private_packages_token | docker login ghcr.io -u USERNAME --password-stdin
- name: Stop docker compose (if up)
shell: 'docker compose -f docker-compose.sensor.yml down --remove-orphans --rmi all -v'
- name: Stop any containers that may have been missed by the "docker compose down"
shell: 'docker stop $(docker container ls -q)'
ignore_errors: true
- name: Prune containers and networks
shell: 'docker system prune -a --volumes -f'
- name: Start docker compose
shell: 'docker compose -f docker-compose.sensor.yml up -d'
65 changes: 65 additions & 0 deletions ansible/sensor/docker-compose.sensor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
version: "3.0" # orig 3.0
services:
db:
image: postgres
expose: ["5432"]
restart: always
environment:
POSTGRES_DB: perfectfit
POSTGRES_USER: root
POSTGRES_PASSWORD: root

manage_db:
build: https://github.com/PerfectFit-project/virtual-coach-db.git#main
tty: true
restart: on-failure
command: ["/app/utils/init-db-tests.sh"]
env_file:
- .env.sensor

rasa_server:
image: ghcr.io/perfectfit-project/rasa_server:sensors_testing
restart: always
expose: ["5005"]
env_file:
- .env.sensor


rasa_actions:
image: ghcr.io/perfectfit-project/rasa_actions:sensors_testing
volumes:
- type: bind
source: ./id_rsa_perfectfitsensor
target: /app/sensorprivatekey
read_only: true
restart: always
expose: ["5055"]
env_file:
- .env.sensor

redis:
image: "redis:alpine"
restart: always
expose: ["6379"]

scheduler:
image: ghcr.io/perfectfit-project/scheduler:sensors_testing
restart: always
expose: ["8080"]
depends_on:
- redis
- rasa_server
env_file:
- .env.sensor

niceday_broker:
image: ghcr.io/perfectfit-project/niceday_broker:latest
restart: always
env_file:
- .env.sensor

niceday_api:
image: ghcr.io/perfectfit-project/niceday_api:latest
restart: always
env_file:
- .env.sensor