mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 14:40:27 +00:00
Fix conflict
This commit is contained in:
commit
1a6555403c
46
config_template_docker.py
Normal file
46
config_template_docker.py
Normal file
@ -0,0 +1,46 @@
|
||||
import os
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
# BASIC APP CONFIG
|
||||
WTF_CSRF_ENABLED = True
|
||||
SECRET_KEY = 'We are the world'
|
||||
BIND_ADDRESS = '0.0.0.0'
|
||||
PORT = 9393
|
||||
LOGIN_TITLE = "PDNS"
|
||||
|
||||
# TIMEOUT - for large zones
|
||||
TIMEOUT = 10
|
||||
|
||||
# LOG CONFIG
|
||||
LOG_LEVEL = 'DEBUG'
|
||||
LOG_FILE = '/dev/stdout'
|
||||
|
||||
# Upload
|
||||
UPLOAD_DIR = os.path.join(basedir, 'upload')
|
||||
|
||||
# DATABASE CONFIG
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql://root:PowerDNSAdminPassword@mysqldb/powerdns-admin'
|
||||
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
||||
|
||||
# LDAP CONFIG
|
||||
LDAP_TYPE = 'ldap' # use 'ad' for MS Active Directory
|
||||
LDAP_URI = 'ldaps://your-ldap-server:636'
|
||||
LDAP_USERNAME = 'cn=dnsuser,ou=users,ou=services,dc=duykhanh,dc=me'
|
||||
LDAP_PASSWORD = 'dnsuser'
|
||||
LDAP_SEARCH_BASE = 'ou=System Admins,ou=People,dc=duykhanh,dc=me'
|
||||
# Additional options only if LDAP_TYPE=ldap
|
||||
LDAP_USERNAMEFIELD = 'uid'
|
||||
LDAP_FILTER = '(objectClass=inetorgperson)'
|
||||
|
||||
#Default Auth
|
||||
BASIC_ENABLED = True
|
||||
SIGNUP_ENABLED = True
|
||||
|
||||
# POWERDNS CONFIG
|
||||
PDNS_STATS_URL = 'http://powerdns-server:8081'
|
||||
PDNS_API_KEY = 'PowerDNSAPIKey'
|
||||
PDNS_VERSION = '4.0.0'
|
||||
|
||||
# RECORDS ALLOWED TO EDIT
|
||||
RECORDS_ALLOW_EDIT = ['A', 'AAAA', 'CNAME', 'SPF', 'PTR', 'MX', 'TXT']
|
111
create_db.py
111
create_db.py
@ -5,27 +5,90 @@ from config import SQLALCHEMY_MIGRATE_REPO
|
||||
from app import db
|
||||
from app.models import Role, Setting
|
||||
import os.path
|
||||
db.create_all()
|
||||
# create initial user roles and turn off maintenance mode
|
||||
admin_role = Role('Administrator', 'Administrator')
|
||||
user_role = Role('User', 'User')
|
||||
maintenance_setting = Setting('maintenance', 'False')
|
||||
fullscreen_layout_setting = Setting('fullscreen_layout', 'True')
|
||||
record_helper_setting = Setting('record_helper', 'True')
|
||||
login_ldap_first_setting = Setting('login_ldap_first', 'True')
|
||||
default_record_table_size_setting = Setting('default_record_table_size', '15')
|
||||
default_domain_table_size_setting = Setting('default_domain_table_size', '10')
|
||||
db.session.add(admin_role)
|
||||
db.session.add(user_role)
|
||||
db.session.add(maintenance_setting)
|
||||
db.session.add(fullscreen_layout_setting)
|
||||
db.session.add(record_helper_setting)
|
||||
db.session.add(login_ldap_first_setting)
|
||||
db.session.add(default_record_table_size_setting)
|
||||
db.session.add(default_domain_table_size_setting)
|
||||
db.session.commit()
|
||||
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
|
||||
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
|
||||
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
|
||||
else:
|
||||
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
|
||||
import time
|
||||
import sys
|
||||
|
||||
def start():
|
||||
wait_time = get_waittime_from_env()
|
||||
|
||||
if not connect_db(wait_time):
|
||||
print("ERROR: Couldn't connect to database server")
|
||||
exit(1)
|
||||
|
||||
init_records()
|
||||
|
||||
def get_waittime_from_env():
|
||||
return int(os.environ.get('WAITFOR_DB', 1))
|
||||
|
||||
def connect_db(wait_time):
|
||||
for i in xrange(0, wait_time):
|
||||
print("INFO: Wait for database server")
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
db.create_all()
|
||||
return True
|
||||
except:
|
||||
time.sleep(1)
|
||||
|
||||
return False
|
||||
|
||||
def init_roles(db, role_names):
|
||||
|
||||
# Get key name of data
|
||||
name_of_roles = map(lambda r: r.name, role_names)
|
||||
|
||||
# Query to get current data
|
||||
rows = db.session.query(Role).filter(Role.name.in_(name_of_roles)).all()
|
||||
name_of_rows = map(lambda r: r.name, rows)
|
||||
|
||||
# Check which data that need to insert
|
||||
roles = filter(lambda r: r.name not in name_of_rows, role_names)
|
||||
|
||||
# Insert data
|
||||
for role in roles:
|
||||
db.session.add(role)
|
||||
|
||||
def init_settings(db, setting_names):
|
||||
|
||||
# Get key name of data
|
||||
name_of_settings = map(lambda r: r.name, setting_names)
|
||||
|
||||
# Query to get current data
|
||||
rows = db.session.query(Setting).filter(Setting.name.in_(name_of_settings)).all()
|
||||
|
||||
# Check which data that need to insert
|
||||
name_of_rows = map(lambda r: r.name, rows)
|
||||
settings = filter(lambda r: r.name not in name_of_rows, setting_names)
|
||||
|
||||
# Insert data
|
||||
for setting in settings:
|
||||
db.session.add(setting)
|
||||
|
||||
def init_records():
|
||||
# Create initial user roles and turn off maintenance mode
|
||||
init_roles(db, [
|
||||
Role('Administrator', 'Administrator'),
|
||||
Role('User', 'User')
|
||||
])
|
||||
init_settings(db, [
|
||||
Setting('maintenance', 'False'),
|
||||
Setting('fullscreen_layout', 'True'),
|
||||
Setting('record_helper', 'True'),
|
||||
Setting('login_ldap_first', 'True'),
|
||||
Setting('default_record_table_size', '15'),
|
||||
Setting('default_domain_table_size', '10')
|
||||
])
|
||||
|
||||
db_commit = db.session.commit()
|
||||
commit_version_control(db_commit)
|
||||
|
||||
def commit_version_control(db_commit):
|
||||
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
|
||||
api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
|
||||
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
|
||||
elif db_commit is not None:
|
||||
api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
|
||||
|
||||
if __name__ == '__main__':
|
||||
start()
|
||||
>>>>>>> docker
|
||||
|
50
docker-compose.yml
Normal file
50
docker-compose.yml
Normal file
@ -0,0 +1,50 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
|
||||
powerdns-authoritative:
|
||||
image: winggundamth/powerdns-mysql:trusty
|
||||
hostname: powerdns-authoritative
|
||||
depends_on:
|
||||
- powerdns-authoritative-mariadb
|
||||
links:
|
||||
- powerdns-authoritative-mariadb:mysqldb
|
||||
ports:
|
||||
- 172.17.0.1:53:53/udp
|
||||
- 8081:8081
|
||||
environment:
|
||||
- PDNS_DB_HOST=mysqldb
|
||||
- PDNS_DB_USERNAME=root
|
||||
- PDNS_DB_NAME=powerdns
|
||||
- PDNS_DB_PASSWORD=PowerDNSPassword
|
||||
- PDNS_API_KEY=PowerDNSAPIKey
|
||||
|
||||
powerdns-authoritative-mariadb:
|
||||
image: mariadb:10.1.15
|
||||
hostname: powerdns-authoritative-mariadb
|
||||
environment:
|
||||
- MYSQL_DATABASE=powerdns
|
||||
- MYSQL_ROOT_PASSWORD=PowerDNSPassword
|
||||
|
||||
powerdns-admin:
|
||||
image: winggundamth/powerdns-admin:trusty
|
||||
hostname: powerdns-admin
|
||||
depends_on:
|
||||
- powerdns-admin-mariadb
|
||||
- powerdns-authoritative
|
||||
links:
|
||||
- powerdns-admin-mariadb:mysqldb
|
||||
- powerdns-authoritative:powerdns-server
|
||||
volumes:
|
||||
- ./:/home/web/powerdns-admin
|
||||
ports:
|
||||
- 9393:9393
|
||||
environment:
|
||||
- WAITFOR_DB=60
|
||||
|
||||
powerdns-admin-mariadb:
|
||||
image: mariadb:10.1.15
|
||||
hostname: powerdns-admin-mariadb
|
||||
environment:
|
||||
- MYSQL_DATABASE=powerdns-admin
|
||||
- MYSQL_ROOT_PASSWORD=PowerDNSAdminPassword
|
Loading…
Reference in New Issue
Block a user