Example of ExaFS installation od RHEL/Centos 9 and deployment in production enviroment. Includes: shibboleth auth, mariadb, uwsgi, supervisord
The default Python for RHEL9 is Python 3.9 Virtualenv with Python39 is used by uWSGI server to keep the packages for app separated from system.
First, choose how to authenticate and authorize users. The application currently supports three options.
Depending on the selected WWW server, set up a proxy. We recommend using Apache + mod_uwsgi. If you use another solution, set up the WWW server as you are used to.
# Proxy everything to the WSGI server
ProxyPass / uwsgi://127.0.0.1:8000/
The ExaFS is using Flask Python Framework. We are using standard deployment for Flask and Apache as is described in the offical docs.
Install dependencies as root.
If you are using Debian or Ubuntu, you must of course use apt and sudo instead yum.
Don't forget to enable mod_proxy_uwsgi module in your Apache httpd config. MariaDB is not a strict requirement, the app is using SQL-Alchemy and therefore you can use another RDBMS if needed.
Install Python, UWSGI and MariaDB.
yum install gcc python3 python3-devel
yum install mod_proxy_uwsgi uwsgi-plugin-python3
yum install mariadb mariadb-server mariadb-devel
Start MariaDB and secure instalation
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
Next step is to install VirtualEnv for Python
pip install virtualenv
Now prepare user for the database. Start mysql client with
mysql -u root -p
Now create the db and user with password
CREATE DATABASE exafs;
ALTER DATABASE exafs CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'exafs'@'localhost' IDENTIFIED BY 'verysecurepassword';
USE exafs;
GRANT ALL PRIVILEGES ON exafs.* TO 'exafs'@'localhost';
FLUSH PRIVILEGES;
exit;
Create a user called deploy in the system, then switch to that user.
su - deploy
There are two ways to install ExaFS. Choose the one that fits your workflow:
Option A — Install from PyPI (recommended)
This is the simplest approach. The flowapp package is installed into the virtualenv. All templates, static files, migrations, and setup commands (exafs-db-init, exafs-create-admin) are included automatically.
mkdir ~/www && cd ~/www
virtualenv --python=python3.9 venv
source venv/bin/activate
pip install exafs
You still need config.py and run.py in the working directory. Download the example files from the repository:
curl -O https://raw.githubusercontent.com/CESNET/exafs/master/config.example.py
curl -O https://raw.githubusercontent.com/CESNET/exafs/master/run.example.py
Option B — Install from source
Use this if you want to track a specific branch, contribute changes, or pin to a git commit.
git clone https://github.com/CESNET/exafs.git www
cd www
virtualenv --python=python3.9 venv
source venv/bin/activate
pip install -e .
Now lets continue as root user once again.
First we need to allow httpd connection in SeLinux
setsebool -P httpd_can_network_connect 1
Prepare the log dir and start httpd if not already running. If you want to use different log dir name, don't forget to update it in the supervisord config.
mkdir /var/log/exafs/
systemctl start httpd
Supervisord is used to run and manage applications, but it is not mandatory for deployment. You can skip this section if you are using a different deployment method, such as Docker.
-
install:
pip install supervisor -
configure:
mkdir -p /etc/supervisord/conf.decho_supervisord_conf > /etc/supervisord/supervisord.confecho "[include]" >> /etc/supervisord/supervisord.confecho "files = conf.d/*.conf" >> /etc/supervisord/supervisord.conf
-
setup as service:
cp docs/supervisor/supervisord.example.service /usr/lib/systemd/system/supervisord.service -
copy exafs.supervisord.conf to /etc/supervisord/
cp docs/supervisor/exafs.supervisord.conf /etc/supervisord/conf.d/ -
start service
systemctl start supervisord -
view service status:
systemctl status supervisord -
auto start service on system startup:
systemctl enable supervisord
-
Copy
config.example.pytoconfig.pyand fill out the DB credentials. -
Copy
run.example.pytorun.py. This is the WSGI entry point used by uWSGI. -
Create and populate database tables (roles, actions, rule states).
PyPI install — run from
~/www(whereconfig.pylives):cd ~/www && source venv/bin/activate exafs-db-initSource install:
cd ~/www && source venv/bin/activate python scripts/db-init.py -
Create the first admin user and organization using the interactive setup script.
PyPI install:
exafs-create-adminSource install:
python scripts/create-admin.pyThe script will prompt you for the admin's UUID (Shibboleth eppn), name, email, phone, and then create or select an organization with its network address range. It assigns the admin role automatically.
Note: Both commands must be run from the directory containing
config.py, as they load the database credentials from that file.
The application is installed and should be working now. The next step is to configure ExaBGP and connect it to the ExaAPI application. We also provide simple service called guarda to reload all the rules in case of ExaBGP restart.