This commit is contained in:
Kyattsukuro 2026-10-27 18:25:17 +01:00
commit e4b7f0c072
10 changed files with 1497 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# opencsv
Superuser must be created manualy by running: `./install.sh create-superuser` after setup!

4
defaults/main.yml Normal file
View File

@ -0,0 +1,4 @@
path: /srv/{{ role_name }}
opencsv_override: {}
opencsv_defaults: {}

9
handlers/main.yml Normal file
View File

@ -0,0 +1,9 @@
- name: restart container
community.docker.docker_compose_v2:
project_src: "{{ path }}"
project_name: "{{ role_name }}"
recreate: "always"
services: ["opencsv"]
state: "restarted"
when: not _opencsv_already_restarted

20
meta/main.yml Normal file
View File

@ -0,0 +1,20 @@
---
galaxy_info:
author: "Niklas Freese <niklas@urmel.de>"
description: opencsv
company: "Urmel Services"
license: AGPL-3.0-or-later
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
# dependencies:
# - role: base

66
tasks/main.yml Normal file
View File

@ -0,0 +1,66 @@
---
- name: "set local variables from overrides and defaults"
set_fact:
opencsv: "{{ (opencsv_defaults | combine(opencsv_override, recursive=True)) if opencsv_override else opencsv_defaults }}"
- name: ensure that path exists
file:
path: "{{ path }}"
state: directory
- name: get opencve form github
git:
repo: git@github.com:opencve/opencve.git
dest: "{{ path }}"
clone: yes
update: yes
- name: template .env files
template:
src: dotenv.j2
dest: "{{ path }}/docker/.env"
- name: template airflow.cfg files
template:
src: airflow.cfg.j2
dest: "{{ path }}/scheduler/airflow.cfg"
- name: template nginx.conf
template:
src: opencve.conf.template.j2
dest: "{{ path }}/docker/conf/opencve.conf.template"
- name: template web .env
template:
src: dotenv_web.j2
dest: "{{ path }}/web/opencve/conf/.env"
- name: template web settings.py
template:
src: web_settings.py
dest: "{{ path }}/web/opencve/conf/settings.py"
- name: init docker stack
shell:
cmd: "bash install.sh init-docker-stack"
chdir: "{{ path }}/docker"
- name: clone reposetorys
shell:
cmd: "bash install.sh clone-repositories"
chdir: "{{ path }}/docker"
- name: ensure container versions
shell:
cmd: "bash install.sh verify-container-versions"
chdir: "{{ path }}/docker"
- name: ensure container versions
shell:
cmd: "bash install.sh verify-container-versions"
chdir: "{{ path }}/docker"
- name: unpause airflow
shell:
cmd: "bash install.sh start-opencve-dag"
chdir: "{{ path }}/docker"

1311
templates/airflow.cfg.j2 Normal file

File diff suppressed because it is too large Load Diff

40
templates/dotenv.j2 Normal file
View File

@ -0,0 +1,40 @@
# OpenCVE docker-compose vars
# OPENCVE_VERSION is set automatically by install.sh prepare (default: master)
COMPOSE_PROJECT_NAME=opencve
OPENCVE_REPOSITORY=https://github.com/opencve/opencve.git
OPENCVE_VERSION=master
OPENCVE_PORT=80
POSTGRES_USER=opencve
POSTGRES_PASSWORD=opencve
POSTGRES_VERSION=15
GUNICORN_CMD_ARGS="--workers 2 --access-logfile '-'"
# Airflow docker-compose vars
AIRFLOW_WEBSERVER_PORT=8080
_AIRFLOW_WWW_USER_USERNAME=airflow
_AIRFLOW_WWW_USER_PASSWORD=airflow
# Airflow configuration vars
AIRFLOW__CORE__EXECUTOR=CeleryExecutor
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/opencve
AIRFLOW__CELERY__RESULT_BACKEND=db+postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/opencve
AIRFLOW__CELERY__BROKER_URL=redis://:@redis/1
AIRFLOW__CORE__FERNET_KEY='ywvTuNQw6bW-UlEyS0ykTqiz9on1cyMlHT7e1Ddo060='
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION='true'
AIRFLOW__CORE__LOAD_EXAMPLES='false'
AIRFLOW__LOGGING__LOGGING_LEVEL=INFO
AIRFLOW__API__AUTH_BACKENDS='airflow.api.auth.backend.basic_auth,airflow.api.auth.backend.session'
AIRFLOW__SCHEDULER__ENABLE_HEALTH_CHECK='true'
# Airflow StatsD (https://github.com/etsy/statsd) integration settings.
#AIRFLOW__METRICS__STATSD_ON='true'
#AIRFLOW__METRICS__STATSD_HOST='localhost'
# Airflow Sentry (https://docs.sentry.io) integration.
#AIRFLOW__SENTRY__SENTRY_ON='true'
#AIRFLOW__SENTRY__SENTRY_DSN='https://public@sentry.example.com/1'
# SQLALCHEMY
SQLALCHEMY_SILENCE_UBER_WARNING=1

19
templates/dotenv_web.j2 Normal file
View File

@ -0,0 +1,19 @@
# PostgreSQL Database URL
OPENCVE_DATABASE_URL=postgresql://opencve:opencve@postgres:5432/opencve
# Django secret key
# Regenerate a new one with `$ python manage.py generate_secret_key`
OPENCVE_SECRET_KEY='django-insecure-8mjeblz2*z@_n&zn^xpo)(id8f90%@elj#t5dg)59hd69(553a'
# OpenCVE repositories paths
OPENCVE_KB_REPO_PATH=/app/repositories/opencve-kb
OPENCVE_MITRE_REPO_PATH=/app/repositories/cvelistV5
OPENCVE_NVD_REPO_PATH=/app/repositories/opencve-nvd
OPENCVE_REDHAT_REPO_PATH=/app/repositories/opencve-redhat
OPENCVE_VULNRICHMENT_REPO_PATH=/app/repositories/vulnrichment
# PostgreSQL DB URL of OpenCVE v1 (used for v1 -> v2 migration)
OPENCVE_V1_DATABASE=postgresql://opencve:opencve@postgres:5432/opencve_v1
# Base URL
OPENCVE_WEB_BASE_URL=https://app.opencve.io

View File

@ -0,0 +1,20 @@
server {
listen 80 default_server;
server_name _;
location / {
proxy_pass http://webserver:8000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
# Django static files
location /static/ {
root /var/www/opencve/;
}
}

View File

@ -0,0 +1,5 @@
"""
This file is used to override the `opencve/conf/base.py` settings.
"""
from opencve.conf.base import * # noqa # pylint: disable=unused-import