Skip to content

Commit

Permalink
Configure agents correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
iknite committed Feb 4, 2019
1 parent ee472c6 commit 8d90941
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 58 deletions.
4 changes: 2 additions & 2 deletions cmd/agent_auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newAgentAuditorCommand(ctx *cmdContext, config *gossip.Config, agentPreRun

// Bindings
auditorConfig.QEDUrls = v.GetStringSlice("agent.server_urls")
auditorConfig.PubUrls = v.GetStringSlice("agent.publish_urls")
auditorConfig.PubUrls = v.GetStringSlice("agent.alert_urls")
markSliceStringRequired(auditorConfig.QEDUrls, "qedUrls")
markSliceStringRequired(auditorConfig.PubUrls, "pubUrls")

Expand Down Expand Up @@ -79,7 +79,7 @@ func newAgentAuditorCommand(ctx *cmdContext, config *gossip.Config, agentPreRun

// Lookups
v.BindPFlag("agent.server_urls", f.Lookup("qedUrls"))
v.BindPFlag("agent.publish_urls", f.Lookup("pubUrls"))
v.BindPFlag("agent.alert_urls", f.Lookup("pubUrls"))

return cmd
}
4 changes: 2 additions & 2 deletions cmd/agent_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newAgentMonitorCommand(ctx *cmdContext, config *gossip.Config, agentPreRun

// Bindings
monitorConfig.QedUrls = v.GetStringSlice("agent.server_urls")
monitorConfig.PubUrls = v.GetStringSlice("agent.publish_urls")
monitorConfig.PubUrls = v.GetStringSlice("agent.alert_urls")
markSliceStringRequired(monitorConfig.QedUrls, "qedUrls")
markSliceStringRequired(monitorConfig.PubUrls, "pubUrls")

Expand Down Expand Up @@ -80,7 +80,7 @@ func newAgentMonitorCommand(ctx *cmdContext, config *gossip.Config, agentPreRun

// Lookups
v.BindPFlag("agent.server_urls", f.Lookup("qedUrls"))
v.BindPFlag("agent.publish_urls", f.Lookup("pubUrls"))
v.BindPFlag("agent.alert_urls", f.Lookup("pubUrls"))

return cmd
}
4 changes: 2 additions & 2 deletions cmd/agent_publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newAgentPublisherCommand(ctx *cmdContext, config *gossip.Config, agentPreRu
agentPreRun(cmd, args)

// Bindings
endpoints = v.GetStringSlice("agent.publish_urls")
endpoints = v.GetStringSlice("agent.snapshots_store_urls")
markSliceStringRequired(endpoints, "pubUrls")

},
Expand Down Expand Up @@ -76,7 +76,7 @@ func newAgentPublisherCommand(ctx *cmdContext, config *gossip.Config, agentPreRu
"Comma-delimited list of end-publishers ([host]:port), through which an publisher can send requests")

// Lookups
v.BindPFlag("agent.publish_urls", f.Lookup("pubUrls"))
v.BindPFlag("agent.snapshots_store_urls", f.Lookup("pubUrls"))

return cmd
}
3 changes: 0 additions & 3 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
v "github.com/spf13/viper"

Expand Down Expand Up @@ -51,7 +49,6 @@ func newClientCommand(ctx *cmdContext) *cobra.Command {
v.BindPFlag("client.timeout.handshake", f.Lookup("handshake-timeout-seconds"))

clientPreRun := func(cmd *cobra.Command, args []string) {
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>", "client.customprerun")
log.SetLogger("QEDClient", ctx.logLevel)

clientCtx.config.APIKey = ctx.apiKey
Expand Down
3 changes: 0 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
package cmd

import (
"fmt"

"github.com/bbva/qed/log"
homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
Expand All @@ -35,7 +33,6 @@ func NewRootCommand() *cobra.Command {
Short: "QED is a client for the verifiable log server",
TraverseChildren: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>", "root.persistentprerun", ctx.path)

if ctx.configFile != "" {
v.SetConfigFile(ctx.configFile)
Expand Down
1 change: 0 additions & 1 deletion cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func newStartCommand(ctx *cmdContext) *cobra.Command {
Use: "start",
Short: "Start the server for the verifiable log QED",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>", "start.run", ctx.path)
var err error

log.SetLogger("QEDServer", ctx.logLevel)
Expand Down
93 changes: 51 additions & 42 deletions deploy/aws/config_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,59 @@ tdir=$(mktemp -d /tmp/qed_build.XXX)
sign_path=${pub}/id_ed25519
cert_path=${pub}/server.crt
key_path=${pub}/server.key
node_path=${pub}/node_exporter

(
cd ${tdir}

if [ ! -f ${sign_path} ]; then
#build shared signing key
ssh-keygen -t ed25519 -f id_ed25519 -P ''

cp id_ed25519 ${sign_path}
fi


if [ ! -f ${cert_path} ] && [ ! -f ${key_path} ]; then

#build shared server cert
openssl req \
-newkey rsa:2048 \
-nodes \
-days 3650 \
-x509 \
-keyout ca.key \
-out ca.crt \
-subj "/CN=*"
openssl req \
-newkey rsa:2048 \
-nodes \
-keyout server.key \
-out server.csr \
-subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=*"
openssl x509 \
-req \
-days 365 \
-sha256 \
-in server.csr \
-CA ca.crt \
-CAkey ca.key \
-CAcreateserial \
-out server.crt \
-extfile <(echo subjectAltName = IP:127.0.0.1)

cp server.crt ${cert_path}
cp server.key ${key_path}

fi
cd ${tdir}

if [ ! -f ${node_path} ]; then (
mkdir -p ./node_exporter
version=0.17.0
link=https://github.com/prometheus/node_exporter/releases/download/v${version}/node_exporter-${version}.linux-amd64.tar.gz
wget -qO- ${link} | tar xvz -C ./
cp node_exporter-${version}.linux-amd64/node_exporter ${node_path}
) fi

if [ ! -f ${sign_path} ]; then
#build shared signing key
ssh-keygen -t ed25519 -f id_ed25519 -P ''

cp id_ed25519 ${sign_path}
fi

if [ ! -f ${cert_path} ] && [ ! -f ${key_path} ]; then

#build shared server cert
openssl req \
-newkey rsa:2048 \
-nodes \
-days 3650 \
-x509 \
-keyout ca.key \
-out ca.crt \
-subj "/CN=*"
openssl req \
-newkey rsa:2048 \
-nodes \
-keyout server.key \
-out server.csr \
-subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=*"
openssl x509 \
-req \
-days 365 \
-sha256 \
-in server.csr \
-CA ca.crt \
-CAkey ca.key \
-CAcreateserial \
-out server.crt \
-extfile <(echo subjectAltName = IP:127.0.0.1)

cp server.crt ${cert_path}
cp server.key ${key_path}

fi

)

#build server binary
Expand Down
6 changes: 3 additions & 3 deletions deploy/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module "agent-publisher" {
subnet_id = "${element(data.aws_subnet_ids.all.ids, 0)}"
key_name = "${aws_key_pair.qed.key_name}"

command="agent"
command="agent publisher"
config = <<-CONFIG
---
api_key: "terraform_qed"
Expand Down Expand Up @@ -152,7 +152,7 @@ module "agent-monitor" {
subnet_id = "${element(data.aws_subnet_ids.all.ids, 0)}"
key_name = "${aws_key_pair.qed.key_name}"

command="agent"
command="agent monitor"
config = <<-CONFIG
---
api_key: "terraform_qed"
Expand Down Expand Up @@ -182,7 +182,7 @@ module "agent-auditor" {
subnet_id = "${element(data.aws_subnet_ids.all.ids, 0)}"
key_name = "${aws_key_pair.qed.key_name}"

command="agent"
command="agent auditor"
config = <<-CONFIG
---
api_key: "terraform_qed"
Expand Down

0 comments on commit 8d90941

Please sign in to comment.