From 2482176d90130d62d0178d363e7e047f183bbdac Mon Sep 17 00:00:00 2001 From: Victor Vrantchan Date: Fri, 4 May 2018 13:01:45 -0400 Subject: [PATCH] update ubuntu docs and add notes on systemd (#1702) closes #1593 --- docs/infrastructure/fleet-on-centos.md | 5 +++ docs/infrastructure/fleet-on-ubuntu.md | 12 +++++-- docs/infrastructure/systemd.md | 47 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 docs/infrastructure/systemd.md diff --git a/docs/infrastructure/fleet-on-centos.md b/docs/infrastructure/fleet-on-centos.md index 2b4e97b43b..33a5accf69 100644 --- a/docs/infrastructure/fleet-on-centos.md +++ b/docs/infrastructure/fleet-on-centos.md @@ -135,6 +135,11 @@ $ /usr/bin/fleet serve \ Now, if you go to [https://localhost:8080](https://localhost:8080) in your local browser, you should be redirected to [https://localhost:8080/setup](https://localhost:8080/setup) where you can create your first Fleet user account. +## Running Fleet with systemd + +See [systemd](./systemd.md) for documentation on running fleet as a background process and managing the fleet server logs. + + ## Installing and running osquery > Note that this whole process is outlined in more detail in the [Adding Hosts To Fleet](./adding-hosts-to-fleet.md) document. The steps are repeated here for the sake of a continuous tutorial. diff --git a/docs/infrastructure/fleet-on-ubuntu.md b/docs/infrastructure/fleet-on-ubuntu.md index 54772844db..6adcf68f8e 100644 --- a/docs/infrastructure/fleet-on-ubuntu.md +++ b/docs/infrastructure/fleet-on-ubuntu.md @@ -122,6 +122,11 @@ $ /usr/bin/fleet serve \ Now, if you go to [https://localhost:8080](https://localhost:8080) in your local browser, you should be redirected to [https://localhost:8080/setup](https://localhost:8080/setup) where you can create your first Fleet user account. +## Running Fleet with systemd + +See [systemd](./systemd.md) for documentation on running fleet as a background process and managing the fleet server logs. + + ## Installing and running osquery > Note that this whole process is outlined in more detail in the [Adding Hosts To Fleet](./adding-hosts-to-fleet.md) document. The steps are repeated here for the sake of a continuous tutorial. @@ -129,12 +134,15 @@ Now, if you go to [https://localhost:8080](https://localhost:8080) in your local To install osquery on Ubuntu, you can run the following: ``` -$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1484120AC4E9F8A1A577AEEE97A80C63C9D8B80B -$ sudo add-apt-repository "deb [arch=amd64] https://osquery-packages.s3.amazonaws.com/xenial xenial main" +$ export OSQUERY_KEY=1484120AC4E9F8A1A577AEEE97A80C63C9D8B80B +$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $OSQUERY_KEY +$ sudo add-apt-repository 'deb [arch=amd64] https://pkg.osquery.io/deb deb main' $ sudo apt-get update $ sudo apt-get install osquery ``` +If you're having trouble with the above steps, check the official [downloads](https://osquery.io/downloads) link for a direct download of the .deb. + You will need to set the osquery enroll secret and osquery server certificate. If you head over to the manage hosts page on your Fleet instance (which should be [https://localhost:8080/hosts/manage](https://localhost:8080/hosts/manage)), you should be able to click "Add New Hosts" and see a modal like the following: ![Add New Host](../images/add-new-host-modal.png) diff --git a/docs/infrastructure/systemd.md b/docs/infrastructure/systemd.md new file mode 100644 index 0000000000..32ae263f1b --- /dev/null +++ b/docs/infrastructure/systemd.md @@ -0,0 +1,47 @@ +## Running with systemd + +Once you've verified that you can run fleet in your shell, you'll likely want to keep fleet running in the background and after the server reboots. To do that we recommend using [systemd](https://coreos.com/os/docs/latest/getting-started-with-systemd.html). + +Below is a sample unit file. + +``` +[Unit] +Description=Kolide Fleet +After=network.target + +[Service] +ExecStart=/usr/local/bin/fleet serve \ + --mysql_address=127.0.0.1:3306 \ + --mysql_database=kolide \ + --mysql_username=root \ + --mysql_password=toor \ + --redis_address=127.0.0.1:6379 \ + --server_cert=/tmp/server.cert \ + --server_key=/tmp/server.key \ + --auth_jwt_key=this_string_is_not_secure_replace_it \ + --logging_json + +[Install] +WantedBy=multi-user.target +``` + +Once you created the file, you need to move it to `/etc/systemd/system/fleet.service` and start the service. + +``` +sudo mv fleet.service /etc/systemd/system/fleet.service +sudo systemctl start fleet.service +sudo systemctl status fleet.service + +sudo journalctl -u fleet.service -f +``` + +## Making changes + +Sometimes you'll need to update the systemd unit file defining the service. To do that, first open /etc/systemd/system/fleet.service in a text editor, and make your modifications. + +Then, run + +``` +sudo systemctl daemon-reload +sudo systemctl restart fleet.service +```