runtime config files moved to conf/ directory

This commit is contained in:
Filip Valder
2016-11-21 22:49:57 +01:00
parent 83db7d07bf
commit f2cd0a3033
7 changed files with 169 additions and 127 deletions

View File

@@ -25,5 +25,5 @@ WORKDIR /opt/module_build_service/
COPY ./requirements.txt /opt/module_build_service/
RUN pip install --user -r ./requirements.txt
RUN ln -s /opt/module_build_service/koji.conf /etc/module_build_service/koji.conf \
&& ln -s /opt/module_build_service/copr.conf /etc/module_build_service/copr.conf
RUN ln -s /opt/module_build_service/conf/koji.conf /etc/module_build_service/koji.conf \
&& ln -s /opt/module_build_service/conf/copr.conf /etc/module_build_service/copr.conf

4
Vagrantfile vendored
View File

@@ -22,8 +22,8 @@ $script = <<SCRIPT
pip install -r /opt/module_build_service/test-requirements.txt
cd /opt/module_build_service
mkdir -p /etc/module_build_service
ln -s /opt/module_build_service/koji.conf /etc/module_build_service/koji.conf
ln -s /opt/module_build_service/copr.conf /etc/module_build_service/copr.conf
ln -s /opt/module_build_service/conf/koji.conf /etc/module_build_service/koji.conf
ln -s /opt/module_build_service/conf/copr.conf /etc/module_build_service/copr.conf
python manage.py upgradedb
python manage.py generatelocalhostcert
systemctl enable fedmsg-relay

2
conf/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
# This file should disappear one day there are no more *.py files left
# here in the conf/ dir.

135
conf/config.py Normal file
View File

@@ -0,0 +1,135 @@
from os import path
# FIXME: workaround for this moment till confdir, dbdir (installdir etc.) are
# declared properly somewhere/somehow
confdir = path.abspath(path.dirname(__file__))
# use parent dir as dbdir else fallback to current dir
dbdir = path.abspath(path.join(confdir, '..')) if confdir.endswith('conf') \
else confdir
class BaseConfiguration(object):
# Make this random (used to generate session keys)
SECRET_KEY = '74d9e9f9cd40e66fc6c4c2e9987dce48df3ce98542529fd0'
SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(path.join(
dbdir, 'module_build_service.db'))
SQLALCHEMY_TRACK_MODIFICATIONS = True
# Where we should run when running "manage.py runssl" directly.
HOST = '127.0.0.1'
PORT = 5000
# Global network-related values, in seconds
NET_TIMEOUT = 120
NET_RETRY_INTERVAL = 30
SYSTEM = 'koji'
MESSAGING = 'fedmsg' # or amq
KOJI_CONFIG = '/etc/module_build_service/koji.conf'
KOJI_PROFILE = 'koji'
KOJI_ARCHES = ['i686', 'armv7hl', 'x86_64']
KOJI_PROXYUSER = True
COPR_CONFIG = '/etc/module_build_service/copr.conf'
PDC_URL = 'http://modularity.fedorainfracloud.org:8080/rest_api/v1'
PDC_INSECURE = True
PDC_DEVELOP = True
SCMURLS = ["git://pkgs.stg.fedoraproject.org/modules/"]
# How often should we resort to polling, in seconds
# Set to zero to disable polling
POLLING_INTERVAL = 600
# Determines how many builds that can be submitted to the builder
# and be in the build state at a time. Set this to 0 for no restrictions
NUM_CONSECUTIVE_BUILDS = 5
RPMS_DEFAULT_REPOSITORY = 'git://pkgs.fedoraproject.org/rpms/'
RPMS_ALLOW_REPOSITORY = False
RPMS_DEFAULT_CACHE = 'http://pkgs.fedoraproject.org/repo/pkgs/'
RPMS_ALLOW_CACHE = False
SSL_ENABLED = True
SSL_CERTIFICATE_FILE = 'server.crt'
SSL_CERTIFICATE_KEY_FILE = 'server.key'
SSL_CA_CERTIFICATE_FILE = 'cacert.pem'
PKGDB_API_URL = 'https://admin.stg.fedoraproject.org/pkgdb/api'
FAS_URL = 'https://admin.stg.fedoraproject.org/accounts'
REQUIRE_PACKAGER = True
# Available backends are: console, file, journal.
LOG_BACKEND = 'journal'
# Path to log file when LOG_BACKEND is set to "file".
LOG_FILE = 'module_build_service.log'
# Available log levels are: debug, info, warn, error.
LOG_LEVEL = 'info'
# Settings for Kerberos
KRB_KEYTAB = None
KRB_PRINCIPAL = None
KRB_CCACHE = None
# AMQ prefixed variables are required only while using 'amq' as messaging backend
# Addresses to listen to
AMQ_RECV_ADDRESSES = ['amqps://messaging.mydomain.com/Consumer.m8y.VirtualTopic.eng.koji',
'amqps://messaging.mydomain.com/Consumer.m8y.VirtualTopic.eng.module_build_service']
# Address for sending messages
AMQ_DEST_ADDRESS = 'amqps://messaging.mydomain.com/Consumer.m8y.VirtualTopic.eng.module_build_service'
AMQ_CERT_FILE = '/etc/module_build_service/msg-m8y-client.crt'
AMQ_PRIVATE_KEY_FILE = '/etc/module_build_service/msg-m8y-client.key'
AMQ_TRUSTED_CERT_FILE = '/etc/module_build_service/Root-CA.crt'
class DevConfiguration(BaseConfiguration):
LOG_BACKEND = 'console'
LOG_LEVEL = 'debug'
HOST = '0.0.0.0'
# Global network-related values, in seconds
NET_TIMEOUT = 5
NET_RETRY_INTERVAL = 1
# Uncomment next line for local builds
# SYSTEM = 'mock'
if path.exists('/home/fedora/modularity.keytab'):
KRB_PRINCIPAL = 'modularity@STG.FEDORAPROJECT.ORG'
KRB_KEYTAB = '/home/fedora/modularity.keytab'
KRB_CCACHE = '/var/tmp/krb5cc'
else:
# This requires that your principal be listed server side in
# ProxyPrincipals, and that is only true for our modularity system
# user. See: https://infrastructure.fedoraproject.org/cgit/ansible.git/commit/?id=a28a93dad75248c30c1792ec35f588c8e317c067
KOJI_PROXYUSER = False
REQUIRE_PACKAGER = False
# You only need these FAS options if you turn on authorization
# with REQUIRE_PACKAGER=True
# FAS_USERNAME = 'put your fas username here'
# FAS_PASSWORD = 'put your fas password here....'
# FAS_PASSWORD = os.environ('FAS_PASSWORD') # you could store it here
# FAS_PASSWORD = commands.getoutput('pass your_fas_password').strip()
KOJI_ARCHES = ['x86_64']
class TestConfiguration(BaseConfiguration):
LOG_BACKEND = 'console'
LOG_LEVEL = 'debug'
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
DEBUG = True
# Global network-related values, in seconds
NET_TIMEOUT = 3
NET_RETRY_INTERVAL = 1
KOJI_CONFIG = './conf/koji.conf'
KOJI_PROFILE = 'staging'
KOJI_REPOSITORY_URL = 'https://kojipkgs.stg.fedoraproject.org/repos'
class ProdConfiguration(BaseConfiguration):
FAS_USERNAME = 'TODO'
# FAS_PASSWORD = 'another password'

151
config.py
View File

@@ -1,126 +1,31 @@
from os import path
# Copyright (c) 2016 Red Hat, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Written by Filip Valder <fvalder@redhat.com>
# TODO: Convert conf/config.py to some sort of flat conf file, JSON or whatever
# and implement parsing/loading here. (fm-orchestrator#192)
class BaseConfiguration(object):
# Make this random (used to generate session keys)
SECRET_KEY = '74d9e9f9cd40e66fc6c4c2e9987dce48df3ce98542529fd0'
basedir = path.abspath(path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format(path.join(
basedir, 'module_build_service.db'))
SQLALCHEMY_TRACK_MODIFICATIONS = True
# Where we should run when running "manage.py runssl" directly.
HOST = '127.0.0.1'
PORT = 5000
# TODO: module_build_service.config defaults & logic should go here.
# This also covers the decision point whether we are dev/test/prod
# instance which should be centralized here. (fm-orchestrator#191)
# See module_build_service.config._init_app_config().
# Global network-related values, in seconds
NET_TIMEOUT = 120
NET_RETRY_INTERVAL = 30
SYSTEM = 'koji'
MESSAGING = 'fedmsg' # or amq
KOJI_CONFIG = '/etc/module_build_service/koji.conf'
KOJI_PROFILE = 'koji'
KOJI_ARCHES = ['i686', 'armv7hl', 'x86_64']
KOJI_PROXYUSER = True
COPR_CONFIG = '/etc/rida/copr.conf'
PDC_URL = 'http://modularity.fedorainfracloud.org:8080/rest_api/v1'
PDC_INSECURE = True
PDC_DEVELOP = True
SCMURLS = ["git://pkgs.stg.fedoraproject.org/modules/"]
# How often should we resort to polling, in seconds
# Set to zero to disable polling
POLLING_INTERVAL = 600
# Determines how many builds that can be submitted to the builder
# and be in the build state at a time. Set this to 0 for no restrictions
NUM_CONSECUTIVE_BUILDS = 5
RPMS_DEFAULT_REPOSITORY = 'git://pkgs.fedoraproject.org/rpms/'
RPMS_ALLOW_REPOSITORY = False
RPMS_DEFAULT_CACHE = 'http://pkgs.fedoraproject.org/repo/pkgs/'
RPMS_ALLOW_CACHE = False
SSL_ENABLED = True
SSL_CERTIFICATE_FILE = 'server.crt'
SSL_CERTIFICATE_KEY_FILE = 'server.key'
SSL_CA_CERTIFICATE_FILE = 'cacert.pem'
PKGDB_API_URL = 'https://admin.stg.fedoraproject.org/pkgdb/api'
FAS_URL = 'https://admin.stg.fedoraproject.org/accounts'
REQUIRE_PACKAGER = True
# Available backends are: console, file, journal.
LOG_BACKEND = 'journal'
# Path to log file when LOG_BACKEND is set to "file".
LOG_FILE = 'module_build_service.log'
# Available log levels are: debug, info, warn, error.
LOG_LEVEL = 'info'
# Settings for Kerberos
KRB_KEYTAB = None
KRB_PRINCIPAL = None
KRB_CCACHE = None
# AMQ prefixed variables are required only while using 'amq' as messaging backend
# Addresses to listen to
AMQ_RECV_ADDRESSES = ['amqps://messaging.mydomain.com/Consumer.m8y.VirtualTopic.eng.koji',
'amqps://messaging.mydomain.com/Consumer.m8y.VirtualTopic.eng.module_build_service']
# Address for sending messages
AMQ_DEST_ADDRESS = 'amqps://messaging.mydomain.com/Consumer.m8y.VirtualTopic.eng.module_build_service'
AMQ_CERT_FILE = '/etc/module_build_service/msg-m8y-client.crt'
AMQ_PRIVATE_KEY_FILE = '/etc/module_build_service/msg-m8y-client.key'
AMQ_TRUSTED_CERT_FILE = '/etc/module_build_service/Root-CA.crt'
class DevConfiguration(BaseConfiguration):
LOG_BACKEND = 'console'
LOG_LEVEL = 'debug'
HOST = '0.0.0.0'
# Global network-related values, in seconds
NET_TIMEOUT = 5
NET_RETRY_INTERVAL = 1
if path.exists('/home/fedora/modularity.keytab'):
KRB_PRINCIPAL = 'modularity@STG.FEDORAPROJECT.ORG'
KRB_KEYTAB = '/home/fedora/modularity.keytab'
KRB_CCACHE = '/var/tmp/krb5cc'
else:
# This requires that your principal be listed server side in
# ProxyPrincipals, and that is only true for our modularity system
# user. See: https://infrastructure.fedoraproject.org/cgit/ansible.git/commit/?id=a28a93dad75248c30c1792ec35f588c8e317c067
KOJI_PROXYUSER = False
REQUIRE_PACKAGER = False
# You only need these FAS options if you turn on authorization
# with REQUIRE_PACKAGER=True
# FAS_USERNAME = 'put your fas username here'
# FAS_PASSWORD = 'put your fas password here....'
# FAS_PASSWORD = os.environ('FAS_PASSWORD') # you could store it here
# FAS_PASSWORD = commands.getoutput('pass your_fas_password').strip()
KOJI_ARCHES = ['x86_64']
class TestConfiguration(BaseConfiguration):
LOG_BACKEND = 'console'
LOG_LEVEL = 'debug'
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
DEBUG = True
# Global network-related values, in seconds
NET_TIMEOUT = 3
NET_RETRY_INTERVAL = 1
KOJI_CONFIG = './koji.conf'
KOJI_PROFILE = 'staging'
KOJI_REPOSITORY_URL = 'https://kojipkgs.stg.fedoraproject.org/repos'
class ProdConfiguration(BaseConfiguration):
FAS_USERNAME = 'TODO'
# FAS_PASSWORD = 'another password'
from conf.config import DevConfiguration, TestConfiguration, ProdConfiguration