Enroll command failed with exit code: 1

Hello, i hope you are doing well
This my infra

ELASTIC

v-elkmaster01.sys.u-bordeaux.fr
v-elkmaster02.sys.u-bordeaux.fr
v-elkmaster03.sys.u-bordeaux.fr
p-elkhot01.sys.u-bordeaux.fr
p-elkhot02.sys.u-bordeaux.fr
p-elkwarm01.sys.u-bordeaux.fr

KIBANA
v-kibana01.sys.u-bordeaux.fr

Elastic has self-signed certificate
kibana has public cerficate

For Elasitc and kibana all is good

Now i'm trying to set up a fleet server using kibana

FLEET
v-elkfleet01.sys.u-bordeaux.fr
has a public certificate

  1. Login to Kibana and navigate to Fleet>Agents tab.
  2. Add host ip:https://elkfleet.sys.u-bordeaux.fr:8220.
    
  3. Generate token and copy fleet server install command for windows.
    
  4. Run agent install command and observe Error: enroll command failed with exit code: 1.
    

this is the command

 ./elastic-agent install --url=https://172.29.52.250:8220 \
  --fleet-server-es=https://172.29.52.38:9200 \
  --fleet-server-service-token=************************************************ \
  --fleet-server-policy=fleet-server-policy \
  --fleet-server-es-ca-trusted-fingerprint=******************************************* \
  --certificate-authorities=/etc/elasticsearch/certs/Chain_Intermediate_Root_Sectigo.crt \
  --fleet-server-cert=/etc/elasticsearch/certs/elkfleet_sys_u-bordeaux_fr.crt \
  --fleet-server-cert-key=/etc/elasticsearch/certs/elkfleet_sys_u-bordeaux_fr.key \
  --fleet-server-port=8220

And the logs

Elastic Agent will be installed at /opt/Elastic/Agent and will run as a service. Do you want to continue? [Y/n]:Y
{"log.level":"info","@timestamp":"2023-10-10T14:54:09.416+0200","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":807},"message":"Fleet Server - Starting","ecs.version":"1.6.0"}
{"log.level":"info","@timestamp":"2023-10-10T14:54:13.418+0200","log.origin":{"file.name":"cmd/enroll_cmd.go","file.line":807},"message":"Fleet Server - Waiting on fleet-server input to be added to policy: fleet-server-policy","ecs.version":"1.6.0"}
Error: fleet-server failed: context canceled
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.10/fleet-troubleshooting.html
Error: enroll command failed with exit code: 1
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/8.10/fleet-troubleshooting.html

Hi Jean-Claude,

It seems something went wrong with the fleet-server-policy creation.
Can you try to reset it with this API call from kibana console or curl?

POST kbn:/api/internal/fleet/reset_preconfigured_agent_policies/fleet-server-policy

And after check that the result of this query has the inputs array populated?

GET .fleet-policies/_search?q=policy_id:fleet-server-policy
{
  "size": 1, 
  "sort": [
    {
      "revision_idx": {
        "order": "desc"
      }
    }
  ]
}

Hello Julia
Thanks for the reply

When i try this the reset command i got

{
  "statusCode": 404,
  "error": "Not Found",
  "message": "Not Found"
}

Is it normal ?

I don't understand why after deleting the fleet-server-policy
via kibana -> fleet -> agent policy
i see nothing

but when icheck with

GET .fleet-policies/_search?q=policy_id:fleet-server-policy
{
  "size": 1, 
  "sort": [
    {
      "revision_idx": {
        "order": "desc"
      }
    }
  ]
}

I got a result

The .fleet-policies index contains previous versions of the policy, even after deleted.
The reset might not work if the agent policy was not preconfigured.
You can try recreating a new agent policy with Fleet Server integration, and use the policy id when trying to enroll a Fleet Server.
If you use the Add Fleet Server button on the UI, it should help guide with recreating the policy.

Thanks a lot
it was a problem with fleet-server-policy
After creating a new policy with a new name
it works

Best regards

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.