First commit

This commit is contained in:
Benjamin Bohard 2020-04-03 11:46:15 +02:00
commit 420f155eeb
9 changed files with 560 additions and 0 deletions

26
Makefile Normal file
View File

@ -0,0 +1,26 @@
################################
# Makefile pour XXX-XXX
################################
SOURCE=XXX-XXX
VERSION=X.X
EOLE_VERSION=2.3|2.4
PKGAPPS=non|web|flask
#FLASK_MODULE=<APPLICATION>
################################
# Début de zone à ne pas éditer
################################
include eole.mk
include apps.mk
################################
# Fin de zone à ne pas éditer
################################
# Makefile rules dedicated to application
# if exists
ifneq (, $(strip $(wildcard $(SOURCE).mk)))
include $(SOURCE).mk
endif

90
apps.mk Normal file
View File

@ -0,0 +1,90 @@
#
# NE PAS EDITER CE FICHIER
#
# Utiliser <appli>.mk à inclure à la fin de Makefile
# Le variables suivantes sont a votre disposition :
#
# SRC_APPS : Répertoire des sources de l'application
# SRC_APPS_PLUGIN : Répertoires des plugins pour l'application
# SRC_APPS_LANG : Répértoires des traductions
#
##########################
# Application web envole #
##########################
ifneq (, $(filter oui web, $(PKGAPPS)))
# Envole
sharenvole_PROG_DIR := $(DESTDIR)/usr/share/envole/$(SOURCE)
SRC_APPS := src/$(SOURCE)-$(VERSION)
SRC_APPS_PLUGIN := src/plugins-$(VERSION)
SRC_APPS_LANG := src/lang-$(VERSION)
APPS_DEST := $(DESTDIR)/var/www/html/$(SOURCE)
LANG_DEST := $(APPS_DEST)/lang
PLUGIN_DEST := $(APPS_DEST)/plugin
# Sanity check
ifeq (, $(filter-out X.X, $(strip $(VERSION))))
$(error $$(VERSION) variable has incorrect value '$(VERSION)')
endif
ifeq (, $(strip $(wildcard $(SRC_APPS))))
$(error $$(PKGAPPS) is enable but $$(SRC_APPS)='$(SRC_APPS)' does not exist)
endif
endif
##########################
# Application EOLE flask #
##########################
ifneq (, $(filter flask, $(PKGAPPS)))
# Sanity check
ifeq (, $(filter-out XXX, $(strip $(FLASK_MODULE))))
$(error $$(FLASK_MODULE) variable has incorrect value '$(FLASK_MODULE)')
endif
ifeq (, $(strip $(wildcard src/$(FLASK_MODULE).conf)))
$(error missing eoleflask configuration file 'src/$(FLASK_MODULE).conf')
endif
# Static files
SRC_APPS := src/$(FLASK_MODULE)/static
APPS_MOUNT_POINT:= $(shell sed -ne 's|^"MOUNT_POINT"[[:space:]]*:[[:space:]]*"/\([^"]*\)",|\1|p' \
src/$(FLASK_MODULE).conf)
APPS_DEST := $(DESTDIR)/usr/share/eole/flask/$(APPS_MOUNT_POINT)/static
SRC_APPS_PLUGIN := nonexistent
SRC_APPS_LANG := nonexistent
# eole-flask configuration
src_DATA_DIR := $(DESTDIR)/etc/eole/flask/available
endif
################
# Common rules #
################
ifneq (, $(filter oui web flask, $(PKGAPPS)))
install-apps-dirs::
test ! -d $(SRC_APPS) || $(INSTALL_DIRECTORY) $(APPS_DEST)
test ! -d $(SRC_APPS_LANG) || $(INSTALL_DIRECTORY) $(LANG_DEST)
test ! -d $(SRC_APPS_PLUGIN) || $(INSTALL_DIRECTORY) $(PLUGIN_DEST)
install-apps:: install-apps-dirs
# Installation de l'application
$(call fc_install_file,$(INSTALL_RECURSIVE),$(SRC_APPS),$(APPS_DEST))
# Installation des répertoires de plugins
$(call fc_install_file,$(INSTALL_RECURSIVE),$(SRC_APPS_PLUGIN),$(PLUGIN_DEST))
# Installation des répertoires de traductions (lang)
$(call fc_install_file,$(INSTALL_RECURSIVE),$(SRC_APPS_LANG),$(LANG_DEST))
## Add install-apps
install:: install-apps
endif
.PHONY: install-apps install-apps-dirs

148
db/gen/create_tables.sql Normal file
View File

@ -0,0 +1,148 @@
-- Deployment
CREATE TABLE Deployment (
DeploymentId SERIAL PRIMARY KEY,
ProviderType VARCHAR(255) NOT NULL,
TargetType VARCHAR(255) NOT NULL,
TargetName VARCHAR(255) NOT NULL,
FactoryCluster VARCHAR(255),
FactoryNodeName VARCHAR(255),
CPU INTEGER,
VCPU INTEGER,
Memory INTEGER,
Labels VARCHAR(255) [] DEFAULT '{}',
UNIQUE (TargetType, TargetName)
);
CREATE INDEX Deployment_FactoryNodeName_index ON Deployment(FactoryNodeName);
-- Cluster
CREATE TABLE FactoryCluster (
ClusterId SERIAL PRIMARY KEY,
ClusterName VARCHAR(255) NOT NULL UNIQUE,
ClusterDescription VARCHAR(255) NOT NULL,
VirtualIp VARCHAR(15) NOT NULL,
ZoneName VARCHAR(255) NOT NULL
);
-- Node in Cluster
CREATE TABLE FactoryClusterNode (
ClusterNodeId SERIAL PRIMARY KEY,
ClusterId INTEGER NOT NULL,
ServerName VARCHAR(255) NOT NULL UNIQUE,
FOREIGN KEY (ClusterId) REFERENCES FactoryCluster(ClusterId)
);
CREATE INDEX FactoryClusterNode_ServerName_index ON FactoryClusterNode(ServerName);
-- Site
CREATE TABLE Site (
SiteId SERIAL PRIMARY KEY,
SiteName VARCHAR(255) NOT NULL UNIQUE,
SiteDescription VARCHAR(255) NOT NULL
);
-- Zone
CREATE TABLE Zone (
ZoneId SERIAL PRIMARY KEY,
ZoneName VARCHAR(255) NOT NULL UNIQUE,
ZoneDescription VARCHAR(255) NOT NULL,
SitesName VARCHAR(255) [] NOT NULL
);
-- Server
CREATE TABLE Server (
ServerId SERIAL PRIMARY KEY,
ServerName VARCHAR(255) NOT NULL UNIQUE,
ServerDescription VARCHAR(255) NOT NULL,
ServerServermodelName VARCHAR(255) NOT NULL,
ReleaseDistribution VARCHAR(255) NOT NULL,
SiteName VARCHAR(255) NOT NULL,
ZonesName VARCHAR(255) [] NOT NULL,
ZonesIP VARCHAR(255) [] NOT NULL
);
-- Source
CREATE TABLE Source (
SourceId SERIAL PRIMARY KEY,
SourceName VARCHAR(255) NOT NULL UNIQUE,
SourceURL TEXT
);
-- Release
CREATE TABLE Release (
ReleaseId SERIAL PRIMARY KEY,
ReleaseName VARCHAR(255) NOT NULL,
ReleaseSourceId INTEGER NOT NULL,
ReleaseDistribution VARCHAR(20) CONSTRAINT releasedistribution_choice CHECK (ReleaseDistribution IN ('last', 'n-1', 'n-2')),
UNIQUE (ReleaseName, ReleaseSourceId),
UNIQUE (ReleaseDistribution, ReleaseSourceId),
FOREIGN KEY (ReleaseSourceId) REFERENCES Source(SourceId)
);
-- Servermodel
CREATE TABLE Servermodel (
ServermodelId SERIAL PRIMARY KEY,
ServermodelName VARCHAR(255) NOT NULL,
ServermodelDescription VARCHAR(255) NOT NULL,
Osname VARCHAR(255),
Osversion VARCHAR(255),
ISO VARCHAR(255),
ServermodelParents VARCHAR(255) [] DEFAULT '{}',
SourceName VARCHAR(255) NOT NULL,
ReleaseDistribution VARCHAR(255) NOT NULL,
ServermodelApplicationserviceId INTEGER NOT NULL,
UNIQUE (ServermodelName, SourceName, ReleaseDistribution)
);
CREATE INDEX ServermodelApplicationserviceId_index ON Servermodel (ServermodelApplicationserviceId);
-- Applicationservice
CREATE TABLE Applicationservice (
ApplicationserviceId SERIAL PRIMARY KEY,
ApplicationserviceName VARCHAR(255) NOT NULL,
ApplicationserviceDescription VARCHAR(255) NOT NULL,
ApplicationserviceReleaseId INTEGER NOT NULL,
OS JSON,
UNIQUE (ApplicationserviceName, ApplicationserviceReleaseId)
);
CREATE TABLE ApplicationserviceDependency (
ApplicationserviceId INTEGER NOT NULL,
ApplicationserviceDependencyId INTEGER NOT NULL,
UNIQUE(ApplicationserviceId, ApplicationserviceDependencyId),
FOREIGN KEY (ApplicationserviceId) REFERENCES Applicationservice(ApplicationserviceId),
FOREIGN KEY (ApplicationserviceDependencyId) REFERENCES Applicationservice(ApplicationserviceId)
);
-- Log
CREATE TABLE log(
Msg VARCHAR(255) NOT NULL,
Level VARCHAR(10) NOT NULL,
Path VARCHAR(255),
Username VARCHAR(100) NOT NULL,
Data JSON,
Date timestamp DEFAULT current_timestamp
);
-- User, Role and ACL
CREATE TABLE RisottoUser (
UserId SERIAL PRIMARY KEY,
UserLogin VARCHAR(100) NOT NULL UNIQUE,
UserName VARCHAR(100) NOT NULL,
UserSurname VARCHAR(100) NOT NULL
);
CREATE TABLE UserRole (
RoleId SERIAL PRIMARY KEY,
RoleUserId INTEGER NOT NULL,
RoleName VARCHAR(255) NOT NULL,
RoleAttribute VARCHAR(255),
RoleAttributeValue VARCHAR(255),
FOREIGN KEY (RoleUserId) REFERENCES RisottoUser(UserId)
);
CREATE TABLE URI (
URIId SERIAL PRIMARY KEY,
URIName VARCHAR(255) NOT NULL UNIQUE
);
CREATE TABLE RoleURI (
RoleName VARCHAR(255) NOT NULL,
URIId INTEGER NOT NULL,
FOREIGN KEY (URIId) REFERENCES URI(URIId),
PRIMARY KEY (RoleName, URIId)
);

66
dicos/50_risotto.xml Normal file
View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<creole>
<files>
<!-- Je suis un commentaire -->
<file filelist='risotto' name='/etc/risotto/risotto.conf' mkdir='True' rm='True'/>
<file filelist='risotto' name='/etc/systemd/system/risotto.service' mkdir='True' rm='True'/>
<file filelist='risotto' name='/etc/eole/eole-db.d/risotto.yml' mkdir='True' rm='True'/>
<file filelist='risotto' name='/etc/eole/eole-db.d/tiramisu.yml' mkdir='True' rm='True'/>
</files>
<variables>
<family name='risotto'>
<variable name='risotto_configuration_dir' type='filename' description='Emplacement des configurations'>
<value>/srv/risotto/configurations</value>
</variable>
<variable name='risotto_temp_dir' type='filename' description='Répertoire temporaire'>
<value>/srv/risotto/tmp</value>
</variable>
<variable name='risotto_default_user' type='string' description='Utilisateur par défaut'>
<value>Anonymous</value>
</variable>
<variable name='risotto_main_dbname' type='string' description='Nom de la base de données'>
<value>risotto</value>
</variable>
<variable name='risotto_db_user' type='string' description='Compte de connexion à la base de risotto'>
<value>risotto</value>
</variable>
<variable name='risotto_tiramisu_db_user' type='string' description='Compte de connexion à la base de tiramisu'>
<value>tiramisu</value>
</variable>
<variable name='risotto_tiramisu_dbname' type='string' description='Nom de la base de données tiramisu'>
<value>tiramisu</value>
</variable>
<variable name='risotto_db_address' type='string' description='Adresse du serveur de base de données postgresql'>
<value>localhost</value>
</variable>
<variable name='risotto_messages_dir' type='filename' description='Emplacement des messages de lAPI'>
<value>/srv/risotto-message/messages</value>
</variable>
<variable name='risotto_cache_dir' type='filename' description='Emplacement du cache'>
<value>/var/cache/risotto</value>
</variable>
<variable name='risotto_seed_dir' type='filename' description='Emplacement des descriptions de services'>
<value>/srv/risotto/seed</value>
</variable>
<variable name='risotto_factory_configuration_dir' type='filename' description='Emplacement de la configuration du provider factory'>
<value>/srv/factory/</value>
</variable>
</family>
</variables>
<constraints>
</constraints>
<help>
<variable name='risotto_configuration_dir'>Aide pour la variable risotto_configuration_dir</variable>
<variable name='risotto_temp_dir'>Aide pour la variable risotto_temp_dir</variable>
<variable name='risotto_default_user'>Aide pour la variable risotto_default_user</variable>
<variable name='risotto_main_dbname'>Aide pour la variable risotto_main_dbname</variable>
<variable name='risotto_tiramisu_dbname'>Aide pour la variable risotto_tiramisu_dbname</variable>
<variable name='risotto_db_user'>Aide pour la variable risotto_db_user</variable>
<variable name='risotto_tiramisu_db_user'>Aide pour la variable risotto_tiramisu_db_user</variable>
<variable name='risotto_db_address'>Aide pour la variable risotto_db_address</variable>
<variable name='risotto_messages_dir'>Aide pour la variable risotto_messages_dir</variable>
<variable name='risotto_cache_dir'>Aide pour la variable risotto_cache_dir</variable>
<variable name='risotto_seed_dir'>Aide pour la variable risotto_seed_dir</variable>
<variable name='risotto_factory_configuration_dir'>Aide pour la variable risotto_factory_configuration_dir</variable>
</help>
</creole>

187
eole.mk Normal file
View File

@ -0,0 +1,187 @@
#
# NE PAS EDITER CE FICHIER
#
# Utiliser <appli>.mk à inclure à la fin de Makefile
#################
# Sanity checks #
#################
ifeq (, $(DESTDIR))
$(warning $$(DESTDIR) is empty, installation will be done in /)
endif
ifeq (, $(filter-out XXX-XXX, $(strip $(SOURCE))))
$(error $$(SOURCE) variable has incorrect value '$(SOURCE)')
endif
#########################
# Variables definitions #
#########################
INSTALL := install
INSTALL_DATA := install -m 644
INSTALL_PROGRAM := install -m 755
INSTALL_DIRECTORY := install -m 755 -d
INSTALL_RECURSIVE := cp -dr --no-preserve=ownership
# Base
eole_DIR := $(DESTDIR)/usr/share/eole
ifeq ($(strip $(EOLE_VERSION)), 2.3)
diagnose_PROG_DIR := $(eole_DIR)/diagnose/module
else
diagnose_PROG_DIR := $(eole_DIR)/diagnose/
endif
# Creole
creole_DIR := $(eole_DIR)/creole
dicos_DATA_DIR := $(creole_DIR)/dicos
tmpl_DATA_DIR := $(creole_DIR)/distrib
pretemplate_PROG_DIR := $(eole_DIR)/pretemplate
posttemplate_PROG_DIR := $(eole_DIR)/posttemplate
postservice_PROG_DIR := $(eole_DIR)/postservice
firewall_DATA_DIR := $(eole_DIR)/firewall
bacula_restore_DATA_DIR := $(eole_DIR)/bacula/restore
bacula_fichier_DATA_DIR := $(DESTDIR)/etc/bacula/baculafichiers.d
schedule_pre_PROG_DIR := $(eole_DIR)/schedule/pre
schedule_post_PROG_DIR := $(eole_DIR)/schedule/post
extra_REC_DIR := $(creole_DIR)/extra
# Zéphir
zephir_DATA_DIR := $(DESTDIR)/usr/share/zephir
zephir_configs_DATA_DIR := $(zephir_DATA_DIR)/monitor/configs
zephir_srv_DATA_DIR := $(zephir_configs_DATA_DIR)/services
# SSO
sso_DATA_DIR := $(DESTDIR)/usr/share/sso
sso_filtres_DATA_DIR := $(sso_DATA_DIR)/app_filters
sso_user-info_DATA_DIR := $(sso_DATA_DIR)/user_infos
# EAD
ead_DATA_DIR := $(DESTDIR)/usr/share/ead2/backend/config
ead_actions_DATA_DIR := $(ead_DATA_DIR)/actions
ead_perms_DATA_DIR := $(ead_DATA_DIR)/perms
ead_roles_DATA_DIR := $(ead_DATA_DIR)/roles
# Program libraries goes under /usr/lib/<PROGRAM>/
lib_$(SOURCE)_DATA_DIR := $(DESTDIR)/usr/lib/$(SOURCE)
# Scripts Eole
scripts_PROG_DIR := $(eole_DIR)/sbin
lib_eole_DATA_DIR := $(DESTDIR)/usr/lib/eole
# LDAP
ldap_passwords_DATA_DIR := $(eole_DIR)/annuaire/password_files
# LXC
lxc_DATA_DIR := $(eole_DIR)/lxc
lxc_fstab_DATA_DIR := $(lxc_DATA_DIR)/fstab
lxc_hosts_DATA_DIR := $(lxc_DATA_DIR)/hosts
# SQL
sql_DATA_DIR := $(eole_DIR)/mysql/$(SOURCE)
sql_gen_DATA_DIR := $(sql_DATA_DIR)/gen
sql_updates_DATA_DIR := $(sql_DATA_DIR)/updates
sql_conf_gen_DATA_DIR := $(eole_DIR)/applications/gen
sql_conf_passwords_DATA_DIR := $(eole_DIR)/applications/passwords
sql_conf_updates_DATA_DIR := $(eole_DIR)/applications/updates/$(SOURCE)
# Certifs
certs_DATA_DIR := $(eole_DIR)/certs
# Logrotate
logrotate_DATA_DIR := $(DESTDIR)/etc/logrotate.d
# Python modules
ifneq ($(DESTDIR),)
PYTHON_OPTS := --root $(DESTDIR)
endif
#############################################
# Common directories and files installation #
#############################################
all:
install:: install-dirs install-files
# $1 = command to run
# $2 = source directory
# $3 = destination directory
define fc_install_file
if [ -d $2 ]; then \
for file in `ls -1 $2/`; do \
$1 $2/$$file $3 || true; \
done; \
fi
endef
##
## Directory creation
##
# use % to catch local name in $*
# data, program and recursive directory require a corresponding
# directory in local sources
%_DATA_DIR %_PROG_DIR %REC_DIR:
test ! -d $(subst _,/,$*) || $(INSTALL_DIRECTORY) $($@)
# Create the directory referenced by the variable without a local one.
%_DIR:
$(INSTALL_DIRECTORY) $($@)
##
## Install files present directly under data, program and recursive directories
##
# $* : name of variable
# $($*): value of variable
%-instdata:
$(call fc_install_file, $(INSTALL_DATA), $(subst _,/,$(subst _DATA_DIR,,$*)), $($*))
%-instprog:
$(call fc_install_file, $(INSTALL_PROGRAM), $(subst _,/,$(subst _PROG_DIR,,$*)), $($*))
%-instrec:
$(call fc_install_file, $(INSTALL_RECURSIVE), $(subst _,/,$(subst _REC_DIR,,$*)), $($*))
# Use second expansion as variables may be created in included
# Makefiles
.SECONDEXPANSION:
# List of all directories
installdirs_LIST = $(foreach V, $(filter %_DIR, $(.VARIABLES)), \
$(if $(filter file, $(origin $(V))), \
$(V)))
# List of data directories
installdata_LIST = $(filter %_DATA_DIR, $(installdirs_LIST))
# List of program directories
installprog_LIST = $(filter %_PROG_DIR, $(installdirs_LIST))
# List of recursive directories
installrec_LIST = $(filter %_REC_DIR, $(installdirs_LIST))
# Expand directories to create as dependency
# Use double-colon to permit user to define additionnal install-dirs
install-dirs:: $$(installdirs_LIST)
# Expand files to install as dependency
# Use double-colon to permit user to define additionnal install-files
install-files:: install-data-files install-prog-files install-rec-dirs
install-data-files: $$(patsubst %,%-instdata,$$(installdata_LIST))
install-prog-files: $$(patsubst %,%-instprog,$$(installprog_LIST))
install-rec-dirs: $$(patsubst %,%-instrec,$$(installrec_LIST))
# Installation of python modules
ifeq ($(shell test -f setup.py && echo 0), 0)
install-files::
python setup.py install --no-compile --install-layout=deb $(PYTHON_OPTS)
endif
.PHONY: install install-dirs install-files install-data-files install-prog-files install-rec-dirs

14
tmpl/risotto.conf Normal file
View File

@ -0,0 +1,14 @@
CONFIGURATION_DIR=%%getVar('risotto_configuration_dir')
PROVIDER_FACTORY_CONFIG_DIR=%%getVar('risotto_factory_configuration_dir')
TMP_DIR=%%getVar('risotto_temp_dir')
DEFAULT_USER=%%getVar('risotto_default_user')
RISOTTO_DB_NAME=%%getVar('risotto_main_dbname')
RISOTTO_DB_USER=%%getVar('risotto_db_user')
RISOTTO_DB_PASSWORD=replace_me
TIRAMISU_DB_NAME=%%getVar('risotto_tiramisu_dbname')
TIRAMISU_DB_USER=%%getVar('risotto_tiramisu_db_user')
TIRAMISU_DB_PASSWORD=replace_me
DB_ADDRESS=%%getVar('risotto_db_address')
MESSAGE_PATH=%%getVar('risotto_messages_dir')
CACHE_ROOT_PATH=%%getVar('risotto_cache_dir')
SRV_SEED_PATH=%%getVar('risotto_seed_dir')

9
tmpl/risotto.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=risotto
[Service]
EnvironmentFile=/etc/risotto/risotto.conf
ExecStart=/usr/bin/risotto-server
[Install]
WantedBy=multi-user.target

10
tmpl/risotto.yml Normal file
View File

@ -0,0 +1,10 @@
---
dbuser: %%getVar('risotto_db_user')
dbhost: %%getVar('risotto_db_address')
dbport: 5432
dbtype: postgres
dbname: %%getVar('risotto_main_dbname')
template: 'postgres'
sqlscripts: ['/usr/share/eole/db/risotto/gen/create_tables.sql']
pwd_files:
- {'file': '/etc/risotto/risotto.conf', 'pattern': 'RISOTTO_DB_PASSWORD='}

10
tmpl/tiramisu.yml Normal file
View File

@ -0,0 +1,10 @@
---
dbuser: %%getVar('risotto_tiramisu_db_user')
dbhost: %%getVar('risotto_db_address')
dbport: 5432
dbtype: postgres
dbname: %%getVar('risotto_tiramisu_dbname')
template: 'postgres'
pwd_files:
- {'file': '/etc/risotto/risotto.conf', 'pattern': 'TIRAMISU_DB_PASSWORD='}