Skip to content

Commit

Permalink
[8.0](backport elastic#2111) chore: use preconfigured policy for flee…
Browse files Browse the repository at this point in the history
…t-server's default policy (elastic#2116)

* chore: use preconfigured policy for fleet-server's default policy (elastic#2111)

(cherry picked from commit 5ed1aff)

# Conflicts:
#	e2e/_suites/fleet/fleet.go

* fix: resolve conflicts

Co-authored-by: Manuel de la Peña <mdelapenya@gmail.com>
  • Loading branch information
mergify[bot] and mdelapenya authored Feb 8, 2022
1 parent be7acf3 commit 9b00e41
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
13 changes: 13 additions & 0 deletions cli/config/compose/profiles/fleet/default/kibana.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ xpack.fleet.agents.fleet_server.hosts: ["http://fleet-server:8220"]

xpack.encryptedSavedObjects.encryptionKey: "12345678901234567890123456789012"
xpack.fleet.agents.tlsCheckDisabled: true

xpack.fleet.packages:
- name: fleet_server
version: latest
xpack.fleet.agentPolicies:
- name: Fleet Server policy
id: fleet-server-policy
description: Fleet server policy
namespace: default
package_policies:
- name: Fleet Server
package:
name: fleet_server
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ xpack.fleet.outputs:
type: "elasticsearch"
id: "output-123"
hosts: ["http://elasticsearch:9200"]
xpack.fleet.packages:
- name: fleet_server
version: latest
xpack.fleet.agentPolicies:
- name: Test preconfigured policy
id: "test-preconfigured"
Expand All @@ -32,3 +35,11 @@ xpack.fleet.agentPolicies:
- package:
name: system
name: sytem-1
- name: Fleet Server policy
id: fleet-server-policy
description: Fleet server policy
namespace: default
package_policies:
- name: Fleet Server
package:
name: fleet_server
11 changes: 6 additions & 5 deletions e2e/_suites/fleet/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,13 @@ func bootstrapFleet(ctx context.Context, env map[string]string) error {
}).Fatal("Fleet could not be recreated")
}

fleetServicePolicy, err := kibanaClient.GetDefaultPolicy(ctx, true)
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Fatal("Could not get Fleet Server's default policy")
// these values comes from the kibana.config.yml file at Fleet's profile dir
fleetServicePolicy := kibana.Policy{
ID: "fleet-server-policy",
Name: "Fleet Server Policy",
Description: "Fleet Server policy",
}

log.WithFields(log.Fields{
"id": fleetServicePolicy.ID,
"name": fleetServicePolicy.Name,
Expand Down
1 change: 1 addition & 0 deletions internal/kibana/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Policy struct {
}

// GetDefaultPolicy gets the default policy or optionally the default fleet policy
// deprecated: will be removed in upcoming releases
func (c *Client) GetDefaultPolicy(ctx context.Context, fleetServer bool) (Policy, error) {
span, _ := apm.StartSpanOptions(ctx, "Getting default policy", "fleet.package-policies.get-default", apm.SpanOptions{
Parent: apm.SpanFromContext(ctx).TraceContext(),
Expand Down

0 comments on commit 9b00e41

Please sign in to comment.