-
-
Save peasead/33394868ddbd773c39bedde4011b4f6a to your computer and use it in GitHub Desktop.
#!/bin/bash -eux | |
# Single script to install the Elastic Agent on macOS | |
# Downloads the Elastic Agent and saves it to your computer in the current directory (example in Downloads, Desktop, etc.) | |
curl -OL https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.2.0-darwin-x86_64.tar.gz | |
# Uses the Tar command to decompress the Elastic Agent and prepare it for installation | |
tar zxf elastic-agent-8.2.0-darwin-x86_64.tar.gz | |
# Enters the Elastic Agent directory that was decompressed in the previous step | |
cd elastic-agent-8.2.0-darwin-x86_64 | |
# Uses "super user do" to install the Elastic Agent, sends data to Elastic Cloud, and enrolls it in Fleet so that updates to the Agent can be managed within Kibana | |
sudo ./elastic-agent install -f --kibana-url=fleet-server-address --enrollment-token=enrollment-token |
Hey @jbeas408
I can't speak to the Jamf portion, but a bit of *NIX-like systems info (sorry if you know this) - when you run a shell script, you're running in a sub-shell. So, if you took the script above and added a pwd
at the end, you'd see the shell script is in the right directory.
#!/bin/bash -eux
curl -OL https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.2.0-darwin-x86_64.tar.gz
tar zxf elastic-agent-8.2.0-darwin-x86_64.tar.gz
cd elastic-agent-8.2.0-darwin-x86_64
pwd
$ sh script.sh
/path/to/elastic-agent-8.2.0-darwin-x86_64 <- this is the pwd output and you can see, we're in the right directory
Once the script stops, the sub-shell is exited and you're back to your normal directory.
Another way to accomplish this would be by running . script.sh
, which leverages the source
architecture and will have more of a result like you're probably expecting.
Again, I'm not entirely sure how Jamf does things, but that's how you'd do it natively on the command-line.
If I deploy the script natively on Terminal it works but it asks :
Elastic Agent will be installed at /Library/Elastic/Agent and will run as a service. Do you want to continue? [Y/n]
so when I deploy it using Jamf it shows nothing thus it does nothing !
@jbeas408 did you manage to fix it?
@yassermkh did you use the -f
flag? That should do a force installation.
$ elastic-agent install --help
Usage:
elastic-agent install [flags]
...
-f, --force Force overwrite the current and do not prompt for confirmation
...
no didn't use that argument but I managed to make it work by answering that message with Y using :
yes | ./elastic-agent install -f --kibana-url=fleet-server-address --enrollment-token=enrollment-token
Anyone managed to grey out the elastic-agent in the login items in Ventura!?
Hey @yassermkh you might get better support on the Elastic Agent Discuss site. https://discuss.elastic.co/tags/c/elastic-stack/beats/28/elastic-agent
"Elastic Agent provides commands for running Elastic Agent, managing Fleet Server, and doing common tasks."
https://www.elastic.co/guide/en/fleet/current/elastic-agent-cmd-options.html
Hi @peasead did this ever work for you? I used this script but updated the version # and it seems to download/extract the tar.gz file but that's about it. I don't believe it is doing the cd or after that step. Also I noticed If I push this from Jamf and not force the policy sync (sudo Jamf policy) it never installs but errors out (first screenshot). If I force the policy I get the second error.
Force sync policy log