Skip to content

Commit

Permalink
trial run
Browse files Browse the repository at this point in the history
  • Loading branch information
allthingsclowd committed Feb 12, 2019
1 parent 7e31d16 commit 0430129
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
21 changes: 1 addition & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func main() {
portPtr := flag.Int("port", 8080, "Default's to port 8080. Use -port=nnnn to use listen on an alternate port.")
ipPtr := flag.String("ip", "127.0.0.1", "Default's to all interfaces by using 127.0.0.1")
appRoleID = flag.String("appRole", "id-factory", "Application Role Name to be used to bootstrap access to Vault's secrets")
consulACL = flag.String("consulACL", "f8732bef-6085-f2e1-2281-8af91b5b0f6c", "Application ACL from Consul")
consulACL = flag.String("consulACL", "oi-someone-forgot-to-set-me", "Application ACL from Consul")
flag.Parse()
targetPort = strconv.Itoa(*portPtr)
targetIP = *ipPtr
Expand Down Expand Up @@ -173,13 +173,6 @@ func convert4connect(serviceURL string) string {

func getVaultKV(consulClient consul.Client, vaultKey string) string {

// // Get a new Consul client
// consulClient, err := consul.NewClient(consul.DefaultConfig())
// if err != nil {
// fmt.Printf("Failed to contact consul - Please ensure both local agent and remote server are running : e.g. consul members >> %v \n", err)
// goapphealth = "NOTGOOD"
// }

// Read in the Vault service details from consul
vaultService := getConsulSVC(consulClient, "vault")
vaultAddress = "http://" + vaultService
Expand Down Expand Up @@ -262,18 +255,6 @@ func redisInit() (string, string) {
var redisService string
var redisPassword string

// consulTLSConfig, err := consul.SetupTLSConfig(&consul.TLSConfig{
// CAFile: "/usr/local/bootstrap/certificate-config/consul-ca.pem",
// CertFile: "/usr/local/bootstrap/certificate-config/cli.pem",
// KeyFile: "/usr/local/bootstrap/certificate-config/cli-key.pem",
// Address: "127.0.0.1",
// })
// if err != nil {
// panic(fmt.Sprintf("TLS Configuration error 1: %s\n", err))
// }

// fmt.Printf("ConsulTLSConfig: %+v \n", consulTLSConfig)

// Get a new Consul client
consulConfig := consul.DefaultConfig()
consulConfig.Address = "192.168.2.11:8321"
Expand Down
2 changes: 1 addition & 1 deletion nomad_job.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ job "webpagecounter" {
driver = "raw_exec"
config {
command = "/usr/local/bin/webcounter"
args = ["-port=${NOMAD_PORT_http}", "-ip=0.0.0.0"]
args = ["-port=${NOMAD_PORT_http}", "-ip=0.0.0.0", "-consulACL=${CONSUL_ACL_TOKEN}"]
}
resources {
cpu = 20
Expand Down
3 changes: 2 additions & 1 deletion scripts/install_Go_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@ chmod +x /usr/local/bin/webcounter

cp /usr/local/bootstrap/scripts/consul_goapp_verify.sh /usr/local/bin/.

# nomad job run /usr/local/bootstrap/nomad_job.hcl || true
export CONSUL_ACL_TOKEN=${CONSUL_HTTP_TOKEN}
nomad job run /usr/local/bootstrap/nomad_job.hcl || true

9 changes: 8 additions & 1 deletion scripts/install_nomad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ User=${1}
Group=${1}
PIDFile=/var/run/${1}/${1}.pid
PermissionsStartOnly=true
ExecStartPre=-/bin/mkdir -p /var/run/${1}
ExecStartPre=-/bin/mkdir -p /var/run/${1} && export CONSUL_ACL_TOKEN=${CONSUL_HTTP_TOKEN}
ExecStartPre=/bin/chown -R ${1}:${1} /var/run/${1}
ExecStart=${3}
ExecReload=/bin/kill -HUP ${MAINPID}
Expand Down Expand Up @@ -72,6 +72,13 @@ else
LOG="nomad.log"
fi

# Configure consul environment variables for use with certificates
export CONSUL_HTTP_ADDR=https://127.0.0.1:8321
export CONSUL_CACERT=/usr/local/bootstrap/certificate-config/consul-ca.pem
export CONSUL_CLIENT_CERT=/usr/local/bootstrap/certificate-config/cli.pem
export CONSUL_CLIENT_KEY=/usr/local/bootstrap/certificate-config/cli-key.pem
export CONSUL_HTTP_TOKEN=`cat /usr/local/bootstrap/.agenttoken_acl`

which wget unzip &>/dev/null || {
apt-get update
apt-get install -y wget unzip
Expand Down

0 comments on commit 0430129

Please sign in to comment.