kindredgroup / puppet-go

Puppet module for managing Thoughtworks Go
Other
8 stars 12 forks source link

go-agent package inistalling default config for agent #2

Closed ainestal closed 8 years ago

ainestal commented 8 years ago

When installing the package from ::go::agent there is a default configuration that is in /etc/default/go-agent

This is the manifest I'm using:

package { 'java-1.8.0-openjdk':
  ensure => 'installed',
} ->

class { '::go::agent':
  manage_package_repo => true,
} ->

::go::agent::instance { 'agent1':
  ensure          => 'present',
  path            => '/opt/go',
  go_server_host  => '192.168.33.100',
  go_server_port  => 8153,
  manage_user     => true,
}

After applying I have 2 configuration files

# cat /etc/default/go-agent
GO_SERVER=127.0.0.1
export GO_SERVER
GO_SERVER_PORT=8153
export GO_SERVER_PORT
AGENT_WORK_DIR=/var/lib/${SERVICE_NAME:-go-agent}
export AGENT_WORK_DIR
DAEMON=Y
VNC=N
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-2.b17.el7_1.x86_64/jre" # SET_BY_GO_INSTALLER__DONT_REMOVE

and

# cat /etc/default/agent1
# MANAGED BY PUPPET
export GO_SERVER=192.168.33.100
export GO_SERVER_PORT=8153
export JAVA_HOME=/usr
export AGENT_WORK_DIR=/opt/go/agent1/go-agent
export PATH
DAEMON=Y
VNC=N

The default config comes with the go-agent package:

# rpm -qf /etc/default/go-agent
go-agent-15.2.0-2248.noarch

The problem is that the agent is trying to connect to 127.0.0.1 instead of the IP of the server so it crashes.

I tried to overwrite that default configuration calling my instance 'go-agent' but I got the error when applying: ==> agent1: Error: Duplicate declaration: Service[go-agent] is already declared in file /etc/puppet/modules/go/manifests/agent/service.pp:10; cannot redeclare at /etc/puppet/modules/go/manifests/agent/instance.pp:236 on node agent1.

jlyheden commented 8 years ago

I updated the modules agent integration test to catch this situation but was unable to reproduce your error. The agent1 startup script should source /etc/default/agent1 and thus shouldn't matter whatever config is in the go-agent packages instance.

My test manifest:

::go::agent::instance { 'goinstance1':
  ensure          => present,
  path            => '/opt/go-instances',
  go_server_host  => 'localhost.localdomain',
  go_server_port  => '8153'
}

Log output in /opt/go-instances/goinstance1/go-agent/*.log

go-agent-launcher.log:2015-12-03 16:02:14,380 [main     ] ERROR go.agent.launcher.ServerCall:69 - Couldn't access Go Server with base url: http://localhost.localdomain:8153/go/admin/agent-launcher.jar: java.net.UnknownHostException: localhost.localdomain

Last time I checked Go didn't support Java 8, could you try with Java 7 and see if it fixes it?

ainestal commented 8 years ago

I now know what the problem is. For some reason I was executing the following manifest

class { '::go::agent':
  ensure              => 'present',
  service_ensure      => 'running',
  service_enable      => true,
  manage_package_repo => true,
} ->

::go::agent::instance { 'agent1':
  ensure          => 'present',
  path            => '/opt/go',
  go_server_host  => '192.168.33.100',
  go_server_port  => 8153,
  # autoregister    => true,
  manage_user     => true,
}

this tries to use the default config and fails to connect to the server if it's not installed in localhost.

To create a new instance that connects to a server in a different host the following manifest works just fine

package { 'java-1.7.0-openjdk':
  ensure => 'installed',
} ->

class { '::go::agent':
  manage_package_repo => true,
} ->

::go::agent::instance { 'agent1':
  ensure          => 'present',
  path            => '/opt/go',
  go_server_host  => '192.168.33.100',
  go_server_port  => 8153,
  manage_user     => true,
}

BTW, I tried with Java 7 and 8, both are working.

Thank you for your help @jlyheden