Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions agent/configmgr/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ func newFleetConfigManager(logger *slog.Logger, pMgr policymgr.PolicyManager, ba
func (fleetManager *fleetConfigManager) Start(cfg config.Config, backends map[string]backend.Backend) error {
ctx := context.Background()

var err error
cfg.OrbAgent.ConfigManager.Sources.Fleet.TokenURL, err = config.ResolveEnv(cfg.OrbAgent.ConfigManager.Sources.Fleet.TokenURL)
if err != nil {
return err
}
cfg.OrbAgent.ConfigManager.Sources.Fleet.ClientID, err = config.ResolveEnv(cfg.OrbAgent.ConfigManager.Sources.Fleet.ClientID)
if err != nil {
return err
}
cfg.OrbAgent.ConfigManager.Sources.Fleet.ClientSecret, err = config.ResolveEnv(cfg.OrbAgent.ConfigManager.Sources.Fleet.ClientSecret)
if err != nil {
return err
}

fleetManager.logger.Info("starting fleet config manager",
"token_url", cfg.OrbAgent.ConfigManager.Sources.Fleet.TokenURL,
"client_id", cfg.OrbAgent.ConfigManager.Sources.Fleet.ClientID)
Expand Down
1 change: 1 addition & 0 deletions agent/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ RUN pip3 install netboxlabs-device-discovery netboxlabs-orb-worker
COPY --from=builder /build/orb-agent /usr/local/bin/orb-agent
COPY --from=builder /src/orb-agent/agent/docker/orb-agent-entry.sh /usr/local/bin/orb-agent-entry.sh
COPY --from=builder /src/orb-agent/agent/docker/run-agent.sh /run-agent.sh
COPY --from=builder /src/orb-agent/agent/docker/default_config.yaml /opt/orb/default_config.yaml

RUN chmod a+x /run-agent.sh

Expand Down
15 changes: 15 additions & 0 deletions agent/docker/default_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
orb:
config_manager:
active: fleet
sources:
orb:
token_url: ${FLEET_AUTH_URL}
client_id: ${FLEET_CLIENT_ID}
client_secret: ${FLEET_CLIENT_SECRET}
backends:
network_discovery:
device_discovery:
snmp_discovery:
common:
diode:
dry_run: true
35 changes: 34 additions & 1 deletion agent/docker/orb-agent-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,39 @@ if [ -f "asn.mmdb.gz" ]; then
fi

## Agent Configuration ##
DEFAULT_CONFIG_PATH="/opt/orb/default_config.yaml"
agent_args=("$@")

if [ -n "${FLEET_CLIENT_ID}" ] && [ -n "${FLEET_CLIENT_SECRET}" ]; then
# Use packaged default config when fleet credentials are provided without an explicit config file.
config_specified=false
for arg in "${agent_args[@]}"; do
case "${arg}" in
--config|--config=*|-c|-c=*)
config_specified=true
break
;;
esac
done

if [ "${config_specified}" = false ]; then
if [ ${#agent_args[@]} -eq 0 ]; then
agent_args=(run -c "${DEFAULT_CONFIG_PATH}")
else
run_specified=false
for arg in "${agent_args[@]}"; do
if [ "${arg}" = "run" ]; then
run_specified=true
break
fi
done
if [ "${run_specified}" = true ]; then
agent_args+=("--config" "${DEFAULT_CONFIG_PATH}")
fi
fi
fi
fi

trap agentstop1 SIGINT
trap agentstop2 SIGTERM

Expand All @@ -44,7 +77,7 @@ do
# pid file dont exist
if [ ! -f "/var/run/orb-agent.pid" ]; then
# running orb-agent in background
nohup /run-agent.sh "$@" &
nohup /run-agent.sh "${agent_args[@]}" &
sleep 2
if [ -d "/nohup.out" ]; then
tail -f /nohup.out &
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ require (
go.opentelemetry.io/contrib/bridges/otelslog v0.13.0
go.opentelemetry.io/otel v1.38.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0
go.opentelemetry.io/otel/sdk v1.38.0
go.opentelemetry.io/otel/sdk/log v0.14.0
google.golang.org/grpc v1.75.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down Expand Up @@ -112,6 +110,7 @@ require (
golang.org/x/time v0.11.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/grpc v1.75.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gotest.tools/v3 v3.5.2 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0 h1:OMqPldHt79PqWKOMYIAQs3CxAi7RLgPxwfFSwr4ZxtM=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.14.0/go.mod h1:1biG4qiqTxKiUCtoWDPpL3fB3KxVwCiGw81j3nKMuHE=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0 h1:QQqYw3lkrzwVsoEX0w//EhH/TCnpRdEenKBOOEIMjWc=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.14.0/go.mod h1:gSVQcr17jk2ig4jqJ2DX30IdWH251JcNAecvrqTxH1s=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 h1:Ahq7pZmv87yiyn3jeFz/LekZmPLLdKejuO3NcK9MssM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0/go.mod h1:MJTqhM0im3mRLw1i8uGHnCvUEeS7VwRyxlLC78PA18M=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0 h1:bDMKF3RUSxshZ5OjOTi8rsHGaPKsAt76FaqgvIUySLc=
Expand Down
Loading