From f52dd2e5e07551a0d851af56b0bb9766009b8014 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Thu, 21 Mar 2024 12:08:20 +0100 Subject: [PATCH] adding redeploy playbooks and updating the Installation doc --- .../ansible/playbooks/redeploy_backend.yml | 34 +++++ .../ansible/playbooks/redeploy_frontend.yml | 32 +++++ .../ansible/playbooks/redeploy_full.yml | 34 +++++ doc/Installation.md | 129 ++++++++++-------- 4 files changed, 172 insertions(+), 57 deletions(-) create mode 100644 deployment/ansible/playbooks/redeploy_backend.yml create mode 100644 deployment/ansible/playbooks/redeploy_frontend.yml create mode 100644 deployment/ansible/playbooks/redeploy_full.yml diff --git a/deployment/ansible/playbooks/redeploy_backend.yml b/deployment/ansible/playbooks/redeploy_backend.yml new file mode 100644 index 0000000..24dbc0a --- /dev/null +++ b/deployment/ansible/playbooks/redeploy_backend.yml @@ -0,0 +1,34 @@ +# CodeGrader - https://github.com/ooemperor/CodeGrader +# Copyright © 2023, 2024 Michael Kaiser +# +# This file is part of CodeGrader. +# +# CodeGrader is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CodeGrader is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CodeGrader. If not, see . + +# Redeploy CodeGrader Backend as a single Host Installation on Linux Host (Debian) +- name: Setup LXC + import_playbook: lxc_setup.yml + +- name: Install CodeGrader Software Backend + import_playbook: codeGrader_install_backend.yml + +- name: Setup CodeGrader config files + import_playbook: codeGrader_config_setup.yml + +- name: Setup CodeGrader Services + import_playbook: codeGrader_services_setup.yml + +- name: Start CodeGrader Backend Services + import_playbook: codeGrader_services_backend.yml + diff --git a/deployment/ansible/playbooks/redeploy_frontend.yml b/deployment/ansible/playbooks/redeploy_frontend.yml new file mode 100644 index 0000000..6dd8b26 --- /dev/null +++ b/deployment/ansible/playbooks/redeploy_frontend.yml @@ -0,0 +1,32 @@ +# CodeGrader - https://github.com/ooemperor/CodeGrader +# Copyright © 2023, 2024 Michael Kaiser +# +# This file is part of CodeGrader. +# +# CodeGrader is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CodeGrader is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CodeGrader. If not, see . + +# Redeploy CodeGrader Backend as a single Host Installation on Linux Host (Debian) + +- name: Install CodeGrader Software Frontend + import_playbook: codeGrader_install_frontend.yml + +- name: Setup CodeGrader config files + import_playbook: codeGrader_config_setup.yml + +- name: Setup CodeGrader Services + import_playbook: codeGrader_services_setup.yml + +- name: Start CodeGrader Frontend Services + import_playbook: codeGrader_services_frontend.yml + diff --git a/deployment/ansible/playbooks/redeploy_full.yml b/deployment/ansible/playbooks/redeploy_full.yml new file mode 100644 index 0000000..ff094b8 --- /dev/null +++ b/deployment/ansible/playbooks/redeploy_full.yml @@ -0,0 +1,34 @@ +# CodeGrader - https://github.com/ooemperor/CodeGrader +# Copyright © 2023, 2024 Michael Kaiser +# +# This file is part of CodeGrader. +# +# CodeGrader is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CodeGrader is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CodeGrader. If not, see . + +# Redeploy CodeGrader Backend as a single Host Installation on Linux Host (Debian) +- name: Setup LXC + import_playbook: lxc_setup.yml + +- name: Install CodeGrader Software + import_playbook: codeGrader_install_full.yml + +- name: Setup CodeGrader config files + import_playbook: codeGrader_config_setup.yml + +- name: Setup CodeGrader Services + import_playbook: codeGrader_services_setup.yml + +- name: Start CodeGrader Services + import_playbook: codeGrader_services_full.yml + diff --git a/doc/Installation.md b/doc/Installation.md index c14427a..b3dcce2 100644 --- a/doc/Installation.md +++ b/doc/Installation.md @@ -1,69 +1,20 @@ # Installation This file will document the necessary steps to install and run this project. -## Requirements -This Guide will show the necessary steps for installing and running the project on Debian 11 Servers with Python 3.9. +# General +Within this documentation you will find a Guide on how to manually deploy/install the codeGrader. +In case you prefer a automated way to deploy the codeGrader there are ansible playbooks avaible in the deployment folder. +In a productive deployment you might need to change some variables in the playbooks (e.g. Database Password) -It is assumed that you already have setup such a server and have access with a root user. - -## General Steps -``` -apt-get install -y python-dev libpq-dev -apt-get install -y pip -``` - -# Frontend -## Python Packages -``` -pip install -r requirements.txt -``` -# Backend -Running the backend API after Installtion of the package. -``` -cgApiBackend -``` -## Python Packages -``` -pip install -r requirements.txt -``` - -## PostgreSQL 15 -Installing PostgreSQL Version 15 (according to [PostgreSQL Installation](https://www.postgresql.org/download/linux/debian/)) -``` -apt update && sudo apt upgrade -y -sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' -wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - -apt-get update -apt-get install postgresql-15 -``` -By default the only host that can access the database is "localhost". If access to the database shall be established from a different host - -Setting up the database (must be done with postgres user): -``` -createuser --username=postgres --pwprompt codeGrader -createdb --username=postgres --owner=codeGrader codeGraderDB -psql --username=postgres --dbname=codeGraderDB --command='CREATE ROLE codeGrader' -psql --username=postgres --dbname=codeGraderDB --command='GRANT codegrader TO "codeGrader"' -psql --username=postgres --dbname=codeGraderDB --command='ALTER SCHEMA public OWNER TO codeGrader' -psql --username=postgres --dbname=codeGraderDB --command='GRANT SELECT ON pg_largeobject TO codeGrader' - -``` +This Guide will show the necessary steps for installing and running the project on Debian 11 or Debian 12 Servers with Python 3.9 or higher. -## Execution Service -For the execution Service we do need some additional packages,so we can create containers and more. -``` -apt-get install lxc libvirt0 libpam-cgfs bridge-utils uidmap -``` - -The installation of the lxc packages can be verified with the lxc-ls command. If the installation was succesful there should not be any output at this point. -If there was some kind of error during the installation, an error message would be shown. - -## Evaluation Service -The Evaluation Service does not need any additional packages, than what is already specified in the requirements.txt of the backend package. +It is assumed that you already have setup such a server and have access with a root user. # Full Installation Following from here you can find all the needed steps for a full installation on a single host. +Corresponding Ansbile playbook: ```full_setup.yml``` + Install all apt packages including postgres: ``` apt-get install -y libpython3-dev libpq-dev lxc libvirt0 libpam-cgfs bridge-utils uidmap pip git @@ -160,3 +111,67 @@ systemctl start cgUserFrontend.service systemctl start cgAdminFrontend.service ``` +# Redeployment +If you made any changes in the Code and would like to redeploy the Applications, you can use the corresponding playbooks. + +```redeploy_full.yml``` Reinstalls the frontend and backend and restarts it. + +```redeploy_backend.yml``` Reinstall only the backend. + +```redeploy_frontend.yml``` Reinstall only the frontend. + +# Partial Information on specific parts +## General Steps +``` +apt-get install -y python-dev libpq-dev +apt-get install -y pip git +``` + +# Frontend +## Python Packages +``` +pip install -r codeGrader/frontend/requirements.txt +``` +# Backend +Running the backend API after Installtion of the package. +``` +cgApiBackend +``` +## Python Packages +``` +pip install -r codeGrader/backend/requirements.txt +``` + +## PostgreSQL 15 +Installing PostgreSQL Version 15 (according to [PostgreSQL Installation](https://www.postgresql.org/download/linux/debian/)) +``` +apt update && sudo apt upgrade -y +sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - +apt-get update +apt-get install postgresql-15 +``` +By default the only host that can access the database is "localhost". If access to the database shall be established from a different host + +Setting up the database (must be done with postgres user): +``` +createuser --username=postgres --pwprompt codeGrader +createdb --username=postgres --owner=codeGrader codeGraderDB +psql --username=postgres --dbname=codeGraderDB --command='CREATE ROLE codeGrader' +psql --username=postgres --dbname=codeGraderDB --command='GRANT codegrader TO "codeGrader"' +psql --username=postgres --dbname=codeGraderDB --command='ALTER SCHEMA public OWNER TO codeGrader' +psql --username=postgres --dbname=codeGraderDB --command='GRANT SELECT ON pg_largeobject TO codeGrader' + +``` + +## Execution Service +For the execution Service we do need some additional packages,so we can create containers and more. +``` +apt-get install lxc libvirt0 libpam-cgfs bridge-utils uidmap +``` + +The installation of the lxc packages can be verified with the ```lxc-ls --fancy``` command. If the installation was succesful there should not be any output at this point. +If there was some kind of error during the installation, an error message would be shown. + +## Evaluation Service +The Evaluation Service does not need any additional packages, than what is already specified in the requirements.txt of the backend package.