- Python 52.9%
- TypeScript 41.5%
- JavaScript 3.4%
- Shell 1.9%
- Mako 0.1%
- Other 0.1%
| .github/workflows | ||
| scripts | ||
| src/eda_server | ||
| tests | ||
| tools | ||
| ui | ||
| .dockerignore | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| alembic.ini | ||
| INSTALL.md | ||
| LICENSE | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README-API.md | ||
| README-DATABASE.md | ||
| README-POSTGRES.md | ||
| README.md | ||
| requirements.txt | ||
| requirements_dev.txt | ||
| requirements_lint.txt | ||
| requirements_test.txt | ||
| setup.cfg | ||
| setup.py | ||
| Taskfile.yaml | ||
| tox.ini | ||
Event Driven Ansible Server
NOTE Maintenance temporarily on hold. This project is being reworked and will be available soon.
Installation
For instructions on how to quickly spin up a preview instance of eda-server, please see INSTALL.md.
Setting up a development environment
The below instructions detail how to setup a development environment for eda-server.
Requirements
- Docker or podman
- Docker-compose:
pip install docker-compose - Taskfile
- Note: For Macs with the M1 or M2 chip make sure you download Task from the arm64 architecture (https://github.com/go-task/task/releases)
- Git
- Python >= 3.9
- python3-pip
- python3-devel
- gcc
- npm >= v16 (NOTE: node v17 does not seem to work with websockets)
NOTE podman users (only for MacOS and Linux):
-
By default all dev scripts use
dockerbinary. Podman users must installpodman-dockerpackage or run the following command:sudo ln -s $(which podman) $(dirname $(which podman))/docker -
DOCKER_HOSTenvironment variable must be defined pointing to the podman socket to be able to usedocker-compose. Example:export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock -
Ensure the
podman.socketservice is enabled and running:systemctl --user enable --now podman.socket
1. Clone the repository
First you need to clone the eda-server repository:
git clone https://github.com/ansible/eda-server.git
cd eda-server
2. Virtual environment
Create virtual environment and install project
python -m venv .venv
source .venv/bin/activate
pip install -e .
Install Ansible and ansible.eda collection:
pip install ansible
ansible-galaxy collection install ansible.eda
3. Set up env variables
Set up the following env variable(s) when testing/running local dev env
export EDA_DEPLOYMENT_TYPE=local
4. Services
Note:
Instead of running the below task steps individually, you can execute all tasks with task dev:all:start and then follow the steps in the
Accessing the UI section.
Start up a PostgreSQL database sever:
task dev:services:start
Then run database migrations:
task dev:run:migrations
5. Start api server
task dev:api:start
6. User interface
Start webpack server:
task dev:ui:start
7. Accessing the UI
- Load a set of RBAC users and roles (config file: tools/initial_data.yml)
Defaults from config file
users:
- email: 'root@example.com'
password: 'secret'
is_superuser: true
- email: 'admin@example.com'
password: 'secret'
roles: ['admin']
- email: 'manager@example.com'
password: 'secret'
roles: ['manager']
- email: 'bob@example.com'
password: 'secret'
task dev:rbac:loaddata
- You can now login to the UI at http://localhost:8080/eda/.
API docs can be accessed at:
You have finished setting up the development environment.
Running tests
If not started, start the PostgreSQL service, which is required for running integration tests.
docker-compose -f tools/docker/docker-compose.yml up postgres
Run all tests:
task test
Or call pytest directly:
python -m pytest
Git pre-commit hooks (optional)
To automatically run linters and code formatter you may use git pre-commit hooks. This project provides a configuration for pre-commit framework to automatically setup hooks for you.
-
First install the
pre-committool:-
Into your virtual environment:
pip install pre-commit -
Into your user directory:
pip install --user pre-commit -
Via pipx tool:
pipx install pre-commit
-
-
Then generate git pre-commit hooks:
pre-commit install
You may run pre-commit manually on all tracked files by calling:
pre-commit run --all-files
Logging
When you start server using the binary eda-server, it will use default project
logging settings. You can change the logging level by setting the environment variable
EDA_LOG_LEVEL. Example:
export EDA_LOG_LEVEL=debug
This will change log level for uvicorn and project loggers, but will not affect 3rd party libraries.
If you need to update the default project logging configuration, you should edit the
src/eda_server/config/logging.yaml file.
When starting server with uvicorn binary directly, you should specify logging configuration
file path in --log-config parameter. Note that in this case --log-level parameter only
affects uvicorn loggers, but not application ones. To change the application loggers levels
you should set EDA_LOG_LEVEL environment variable. Example:
uvicorn --log-config src/eda_server/config/logging.yaml ...