You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/06/14 18:05:20 UTC
[trafficcontrol] 08/20: create dbconf.yml
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 581bf6b7200423876dc349276a5956dbaa89d303
Author: Dan Kirkwood <da...@gmail.com>
AuthorDate: Mon Jun 4 20:55:29 2018 +0000
create dbconf.yml
---
.../cdn-in-a-box/traffic_ops/Dockerfile-dbinit | 34 ----------------------
infrastructure/cdn-in-a-box/traffic_ops/config.sh | 22 +++++++++-----
infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh | 31 --------------------
.../cdn-in-a-box/traffic_ops/docker-compose.yml | 17 ++++-------
infrastructure/cdn-in-a-box/traffic_ops/run-go.sh | 3 ++
infrastructure/cdn-in-a-box/traffic_ops/run.sh | 11 +++----
.../cdn-in-a-box/traffic_ops/variables.env | 1 +
7 files changed, 29 insertions(+), 90 deletions(-)
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
deleted file mode 100644
index 8c92b79..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile-dbinit
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-############################################################
-# Dockerfile to initialized Traffic Ops Database container
-# Based on CentOS 7.2
-############################################################
-
-FROM centos/systemd
-
-RUN yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
-
-RUN yum -y install \
- postgresql96 \
- nmap-ncat \
- cpanminus && \
- yum clean all
-
-ADD dbInit.sh /
-CMD /dbInit.sh
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/config.sh b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
index dfccc23..3c2efe0 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/config.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/config.sh
@@ -42,13 +42,6 @@ do
if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
done
-key=/server.key
-crt=/server.crt
-
-useradd -M trafops
-openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
-chown trafops:trafops $key $crt
-
cat <<-EOF >/opt/traffic_ops/app/conf/cdn.conf
{
"hypnotoad" : {
@@ -117,3 +110,18 @@ cat <<-EOF >/opt/traffic_ops/app/conf/production/database.conf
"type": "Pg"
}
EOF
+
+cat <<-EOF >/opt/traffic_ops/app/db/dbconf.yml
+version: "1.0"
+name: dbconf.yml
+
+production:
+ driver: postgres
+ open: host=$DB_SERVER port=$DB_PORT user=$DB_USER password=$DB_USER_PASS dbname=$DB_NAME sslmode=disable
+EOF
+
+key=/server.key
+crt=/server.crt
+
+openssl req -newkey rsa:2048 -nodes -keyout $key -x509 -days 365 -out $crt -subj "/C=$CERT_COUNTRY/ST=$CERT_STATE/L=$CERT_CITY/O=$CERT_COMPANY"
+chown trafops:trafops $key $crt
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh b/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
deleted file mode 100755
index 2398f0c..0000000
--- a/infrastructure/cdn-in-a-box/traffic_ops/dbInit.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env bash
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-############################################################
-# Script for creating the database user account for traffic
-# ops.
-# Used while the Docker Image is initializing itself
-############################################################
-
-while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
- echo "waiting for $DB_SERVER:$DB_PORT"
- sleep 3
-done
-
-psql -h $DB_SERVER -U postgres -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_USER_PASS'"
-createdb $DB_NAME -h $DB_SERVER -U postgres --owner $DB_USER
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
index 579403c..04435ac 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/traffic_ops/docker-compose.yml
@@ -44,6 +44,8 @@ networks:
services:
db:
+ hostname: db
+ domainname: cdn.local
image: postgres:9.6.6
networks:
- tcnet
@@ -53,18 +55,9 @@ services:
ports:
- "5432:5432"
- dbinit:
- networks:
- - tcnet
- env_file:
- - variables.env
- build:
- context: .
- dockerfile: Dockerfile-dbinit
- depends_on:
- - db
-
trafficops-perl:
+ hostname: trafficops-perl
+ domainname: cdn.local
image: trafficops-perl
networks:
- tcnet
@@ -80,6 +73,8 @@ services:
- db
trafficops:
+ hostname: trafficops
+ domainname: cdn.local
image: trafficops-go
networks:
- tcnet
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
index 284ba60..fe5af6a 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run-go.sh
@@ -62,3 +62,6 @@ CDNCONF=/opt/traffic_ops/app/conf/cdn.conf
DBCONF=/opt/traffic_ops/app/conf/production/database.conf
mkdir -p /var/log/traffic_ops
./bin/traffic_ops_golang -cfg $CDNCONF -dbcfg $DBCONF
+
+cat /var/log/traffic_ops/*
+tail -f /dev/null
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index c635ae3..46821c5 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -55,17 +55,14 @@ while ! nc $DB_SERVER $DB_PORT </dev/null; do # &>/dev/null; do
sleep 3
done
-while true; do
- echo "Checking for existence of role $DB_USER"
- psql -U postgres -h $DB_SERVER -p $DB_PORT postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='$DB_USER'" | grep -q 1 && break
- sleep 3
-done
-
TO_DIR=/opt/traffic_ops/app
cat conf/production/database.conf
export PERL5LIB=$TO_DIR/lib:$TO_DIR/local/lib/perl5
-cd $TO_DIR && ./db/admin.pl -env production reset
+export PATH=/usr/local/go/bin:/opt/traffic_ops/go/bin:$PATH
+export GOPATH=/opt/traffic_ops/go
+
+cd $TO_DIR && ./db/admin.pl --env=production reset || echo "DB reset failed!"
cd $TO_DIR && $TO_DIR/local/bin/hypnotoad script/cdn
exec tail -f /var/log/traffic_ops/traffic_ops.log
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/variables.env b/infrastructure/cdn-in-a-box/traffic_ops/variables.env
index 1ca486b..bde6dc3 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/variables.env
+++ b/infrastructure/cdn-in-a-box/traffic_ops/variables.env
@@ -4,6 +4,7 @@ CERT_COMPANY=NotComcast
CERT_COUNTRY=US
CERT_STATE=CO
DB_NAME=traffic_ops
+DB_ROOT_PASS=twelve
DB_USER_PASS=twelve
DB_PORT=5432
DB_SERVER=db
--
To stop receiving notification emails like this one, please contact
dewrich@apache.org.