Skip to content
Open
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
1 change: 1 addition & 0 deletions home/.chezmoi.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ data:
docker:
doRegion: nyc1
domain: "{{ $domain }}"
elastic_fleet_server: "https://es-fleet.megabyte.space:8220"
headless: {{ $headless }}
home: "{{ .chezmoi.homeDir }}"
homeParentFolder: "{{ if eq .chezmoi.os "linux" }}/home{{ else if eq .chezmoi.os "darwin" }}/Users{{ else }}C:\Users{{ end }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if and (ne .host.distro.family "windows") (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (or (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "ELASTIC_TOKEN")) (env "ELASTIC_TOKEN")) -}}
#!/usr/bin/env bash
# @file Netdata
# @brief Enrolls Elastic Agent with Elastic Fleet Server
# @description
# This script enrolls Elastic Agent with Elastic Fleet Server if Elastic Agent is installed, the `ELASTIC_TOKEN` is provided, and the
# `elastic_fleet_server` is defined.
#
# Fleet provides a web-based UI in Kibana for centrally managing Elastic Agents and their policies. Fleet Server is the mechanism
# to connect Elastic Agents to Fleet. All communication between the Fleet UI and Fleet Server happens through Elasticsearch.
#
# [Integrations](https://www.elastic.co/guide/en/fleet/current/integrations.html) and [Policies](https://www.elastic.co/guide/en/fleet/current/agent-policy.html)
# are configured using Fleet UI in Kibana. The [enrollment-token](https://www.elastic.co/guide/en/fleet/current/install-fleet-managed-elastic-agent.html)
# can be obtained from Fleet UI, and, one token can be used to add multiple agents to the corresponding policy.

{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}

### Enroll Elastic Agent with Elastic Fleet Server
if command -v elastic-agent > /dev/null; then
ELASTIC_TOKEN="{{- if (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "ELASTIC_TOKEN")) -}}{{- includeTemplate "secrets/ELASTIC_TOKEN" | decrypt | trim -}}{{- else -}}{{- env "ELASTIC_TOKEN" -}}{{- end -}}"
FLEET_URL="{{ .host.data.elastic_fleet_server }}"
logg info 'Enrolling Elastic Agent'
sudo elastic-agent install --url="$FLEET_URL" --enrollment-token="$ELASTIC_TOKEN"
else
logg info '`elastic-agent` is not installed or it is not available in the PATH'
fi

{{ end -}}