Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UII] Add proxy args to install snippets (elastic#193922)
## Summary Resolves elastic#184222. This PR: - Ensures custom agent binary download source URI is respected where ever it appears in command snippets, for both Fleet Server and Elastic Agent install instructions - If a proxy is associated with the source URI, the appropriate args are added to the commands as well - For `curl` commands, these are appended as `--proxy <url>` and `--proxy-header "<key>-<value>"` (repeated for each header key/value pair) - For Windows, these are appended as `-Proxy "<url>"` and `-Headers @{"<key1>"="<value1>"; "<key2>"="<value2>"}` - Adjusts Fleet Server `./elastic-agent install` instructions so that: - `--fleet-server-es` is the value of the data output host set on that Fleet Server policy (must be ES output) - If a proxy is associated with that ES output, the corresponding args are appended: `--proxy-url=<url>` and `--proxy-header "<key>-<value>"` (repeated for each header key/value pair) The internal API at `/internal/fleet/settings/enrollment` has new properties added to its response to support this: ``` fleet_server: { es_output?: Output; es_output_proxy?: FleetProxy; }; download_source_proxy?: FleetProxy; ``` ## Examples **Fleet Server install with proxied custom download and proxied ES host:** ``` curl -L -O https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz --proxy http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br" tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz cd elastic-agent-9.0.0-linux-x86_64 sudo ./elastic-agent install \ --fleet-server-es=http://localhost:9999 \ --fleet-server-service-token=REDACTED \ --fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f \ --fleet-server-port=8220 \ --proxy-url=http://some-proxy:1111 \ --proxy-header="Accept-Language=en-US,en;q=0.5" \ --proxy-header="Accept-Encoding=gzip, deflate, br" ``` ``` $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri https://my-agent-binary-source/beats/elastic-agent/elastic-agent-9.0.0-windows-x86_64.zip -OutFile elastic-agent-9.0.0-windows-x86_64.zip -Proxy "http://some-proxy:1111" -Headers @{"Accept-Language"="en-US,en;q=0.5";"Accept-Encoding"="gzip, deflate, br"} Expand-Archive .\elastic-agent-9.0.0-windows-x86_64.zip cd elastic-agent-9.0.0-windows-x86_64 .\elastic-agent.exe install ` --fleet-server-es=http://localhost:9999 ` --fleet-server-service-token=REDACTED ` --fleet-server-policy=027a180f-2f4a-4dd1-a531-bf1d1d64179f ` --fleet-server-port=8220 ` --proxy-url=http://some-proxy:1111 ` --proxy-header="Accept-Language=en-US,en;q=0.5" ` --proxy-header="Accept-Encoding=gzip, deflate, br" ``` **Elastic Agent install with proxied download source and proxied Fleet Server host:** ``` curl -L -O https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-darwin-aarch64.tar.gz --proxy http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br" tar xzvf elastic-agent-8.15.1-darwin-aarch64.tar.gz cd elastic-agent-8.15.1-darwin-aarch64 sudo ./elastic-agent install --url=https://localhost:2222 --enrollment-token=REDACTED --proxy-url=http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br" ``` ``` $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri https://my-agent-binary-source/beats/elastic-agent/elastic-agent-8.15.1-windows-x86_64.zip -OutFile elastic-agent-8.15.1-windows-x86_64.zip -Proxy "http://some-proxy:1111" -Headers @{"Accept-Language"="en-US,en;q=0.5";"Accept-Encoding"="gzip, deflate, br"} Expand-Archive .\elastic-agent-8.15.1-windows-x86_64.zip -DestinationPath . cd elastic-agent-8.15.1-windows-x86_64 .\elastic-agent.exe install --url=https://localhost:2222 --enrollment-token=REDACTED --proxy-url=http://some-proxy:1111 --proxy-header "Accept-Language=en-US,en;q=0.5" --proxy-header "Accept-Encoding=gzip, deflate, br" ``` ### To-do - [x] Unit tests - [x] API integration tests for enrollment settings endpoint
- Loading branch information