2022-02-22 18:05:32 +00:00
# This workflow tests enrolling of agents on the supported platforms,
# using the latest version of fleet, fleetctl and orbit.
#
# It starts the latest release of fleet with the "fleetctl preview" command.
# It generates the installers for the latest version of Orbit with the
# "fleetctl package" command.
2022-10-07 15:43:56 +00:00
name : Test Fleetctl, Orbit & Preview
2022-01-13 21:59:22 +00:00
on :
workflow_dispatch : # Manual
schedule :
- cron : '0 2 * * *' # Nightly 2AM UTC
2022-10-07 15:43:56 +00:00
2022-10-24 20:01:00 +00:00
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency :
group : ${{ github.workflow }}-${{ github.head_ref || github.run_id}}
cancel-in-progress : true
2022-10-07 15:43:56 +00:00
defaults :
run :
# fail-fast using bash -eo pipefail. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell : bash
2022-03-28 20:20:31 +00:00
permissions :
contents : read
2022-01-13 21:59:22 +00:00
jobs :
gen :
runs-on : ubuntu-latest
outputs :
subdomain : ${{ steps.gen.outputs.subdomain }}
address : ${{ steps.gen.outputs.address }}
steps :
- id : gen
run : |
UUID=$(uuidgen)
2023-04-26 15:15:23 +00:00
echo "subdomain=fleet-test-$UUID" >> $GITHUB_OUTPUT
echo "address=https://fleet-test-$UUID.fleetuem.com" >> $GITHUB_OUTPUT
2022-10-07 15:43:56 +00:00
2022-01-13 21:59:22 +00:00
run-server :
runs-on : ubuntu-latest
needs : gen
steps :
- name : Start tunnel
2022-10-07 15:43:56 +00:00
env :
2022-01-13 21:59:22 +00:00
CERT_PEM : ${{ secrets.CLOUDFLARE_TUNNEL_FLEETUEM_CERT_B64 }}
run : |
2023-08-30 18:49:47 +00:00
# Increase maximum receive buffer size to roughly 2.5 MB.
# Cloudflared uses quic-go. This buffer holds packets that have been received by the kernel,
# but not yet read by the application (quic-go in this case). Once this buffer fills up, the
# kernel will drop any new incoming packet.
# See https://github.com/quic-go/quic-go/wiki/UDP-Receive-Buffer-Size.
sudo sysctl -w net.core.rmem_max=2500000
2022-01-13 21:59:22 +00:00
# Install cloudflared
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared-linux-amd64.deb
# Add secret
echo "$CERT_PEM" | base64 -d > cert.pem
# Start tunnel
2023-08-30 18:49:47 +00:00
cloudflared tunnel --origincert cert.pem --hostname ${{ needs.gen.outputs.subdomain }} --url http://localhost:1337 --name ${{ needs.gen.outputs.subdomain }} --logfile cloudflared.log &
2022-05-16 21:39:31 +00:00
until [[ $(cloudflared tunnel --origincert cert.pem info -o json ${{ needs.gen.outputs.subdomain }} | jq '.conns[0].conns[0].is_pending_reconnect') = false ]]; do
2022-01-13 21:59:22 +00:00
echo "Awaiting tunnel ready..."
sleep 5
done
# Download fleet and fleetctl binaries from last successful build on main
- name : Download binaries
2023-03-01 19:32:47 +00:00
uses : dawidd6/action-download-artifact@5e780fc7bbd0cac69fc73271ed86edf5dcb72d67
2022-01-13 21:59:22 +00:00
with :
workflow : build-binaries.yaml
branch : main
name : build
path : build
check_artifacts : true
- name : Run Fleet server
2023-09-01 15:25:17 +00:00
timeout-minutes : 10
2022-01-13 21:59:22 +00:00
run : |
chmod +x ./build/fleetctl
./build/fleetctl preview --no-hosts
./build/fleetctl config set --address ${{ needs.gen.outputs.address }}
./build/fleetctl get enroll-secret
docker compose -f ~/.fleet/preview/docker-compose.yml logs --follow fleet01 fleet02 &
# Wait for all of the hosts to be enrolled
2023-09-01 15:25:17 +00:00
EXPECTED=3
2022-01-13 21:59:22 +00:00
until [ $(./build/fleetctl get hosts --json | wc -l | tee hostcount) -ge $EXPECTED ]; do
echo -n "Waiting for hosts to enroll: "
cat hostcount | xargs echo -n
echo " / $EXPECTED"
2023-09-01 15:25:17 +00:00
sleep 20
2022-01-13 21:59:22 +00:00
done
echo "Success! $EXPECTED hosts enrolled."
2023-09-01 15:25:17 +00:00
- name : Show enrolled hosts
if : always()
run : |
./build/fleetctl get hosts --json
2022-04-22 17:39:55 +00:00
- name : Slack Notification
if : failure()
2023-06-23 19:32:30 +00:00
uses : slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
2022-04-22 17:39:55 +00:00
with :
payload : |
{
"text": "${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head.html_url }}" ,
"blocks": [
{
"type": "section" ,
"text": {
"type": "mrkdwn" ,
"text": "Integration test result: ${{ job.status }}\nhttps://github.com/fleetdm/fleet/actions/runs/${{ github.run_id }}\n${{ github.event.pull_request.html_url || github.event.head.html_url }}"
}
}
]
}
env :
2023-03-01 23:14:07 +00:00
SLACK_WEBHOOK_URL : ${{ secrets.SLACK_G_HELP_ENGINEERING_WEBHOOK_URL }}
2022-04-22 17:39:55 +00:00
SLACK_WEBHOOK_TYPE : INCOMING_WEBHOOK
2022-01-13 21:59:22 +00:00
- name : Cleanup tunnel
if : always()
2022-10-07 15:43:56 +00:00
run : cloudflared tunnel --origincert cert.pem delete --force ${{ needs.gen.outputs.subdomain }}
2022-01-13 21:59:22 +00:00
2023-08-30 18:49:47 +00:00
- name : Upload cloudflared logs
if : always()
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2
with :
name : cloudflared.log
path : cloudflared.log
2022-01-13 21:59:22 +00:00
login :
runs-on : ubuntu-latest
needs : gen
outputs :
token : ${{ steps.login.outputs.token }}
steps :
# Download fleet and fleetctl binaries from last successful build on main
- name : Download binaries
2023-03-01 19:32:47 +00:00
uses : dawidd6/action-download-artifact@5e780fc7bbd0cac69fc73271ed86edf5dcb72d67
2022-01-13 21:59:22 +00:00
with :
workflow : build-binaries.yaml
branch : main
name : build
path : build
check_artifacts : true
2022-10-07 15:43:56 +00:00
2022-01-13 21:59:22 +00:00
# Login only here and share the token because otherwise we could hit rate limits.
- id : login
name : Attempt login
timeout-minutes : 5
run : |
chmod +x ./build/fleetctl
./build/fleetctl config set --address ${{ needs.gen.outputs.address }}
2022-05-18 17:03:00 +00:00
until ./build/fleetctl login --email admin@example.com --password preview1337#
2022-01-13 21:59:22 +00:00
do
echo "Retrying in 5s..."
sleep 5
done
TOKEN=$(cat ~/.fleet/config| grep token | awk '{ print $2 }')
2023-04-27 21:11:27 +00:00
echo "token=$TOKEN" >> $GITHUB_OUTPUT
2022-10-07 15:43:56 +00:00
2022-01-13 21:59:22 +00:00
orbit-macos :
2023-08-30 18:49:47 +00:00
timeout-minutes : 10
2022-01-13 21:59:22 +00:00
strategy :
matrix :
2023-09-01 15:25:17 +00:00
# To run multiple VMs that have the same UUID we need to implement
# https://github.com/fleetdm/fleet/issues/8021 (otherwise orbit and osqueryd
# in the same host are enrolled as two hosts in Fleet).
# Until then we will just test the `stable` channel in all components.
#
# Alternatively, we can bring back the `edge` channel when we decide to upgrade
# our worker to macOS 13 in the future, as they changed the virtualization
# layer for 13 and now it has random UUIDs (https://github.com/actions/runner-images/issues/7591).
orbit-channel : [ 'stable' ]
osqueryd-channel : [ 'stable' ]
desktop-channel : [ 'stable' ]
2022-01-13 21:59:22 +00:00
runs-on : macos-latest
needs : [ gen, login]
steps :
2022-05-03 19:46:02 +00:00
- name : Checkout Code
2023-08-31 17:09:21 +00:00
uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
2022-05-03 19:46:02 +00:00
2022-01-13 21:59:22 +00:00
- name : Install dependencies
run : |
npm install -g fleetctl
fleetctl config set --address ${{ needs.gen.outputs.address }} --token ${{ needs.login.outputs.token }}
- name : Install Orbit
run : |
sudo hostname macos-orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}
SECRET_JSON=$(fleetctl get enroll_secret --json --debug)
echo $SECRET_JSON
SECRET=$(echo $SECRET_JSON | jq -r '.spec.secrets[0].secret')
echo "Secret: $SECRET"
echo "Hostname: $(hostname -s)"
2023-09-01 15:25:17 +00:00
fleetctl package --type pkg --fleet-url=${{ needs.gen.outputs.address }} --enroll-secret=$SECRET --orbit-channel=${{ matrix.orbit-channel }} --osqueryd-channel=${{ matrix.osqueryd-channel }} --desktop-channel=${{ matrix.desktop-channel }} --fleet-desktop --debug
2022-01-13 21:59:22 +00:00
sudo installer -pkg fleet-osquery.pkg -target /
until fleetctl get hosts | grep -iF $(hostname -s);
do
echo "Awaiting enrollment..."
2022-05-03 19:46:02 +00:00
sleep 10
2022-01-13 21:59:22 +00:00
done
2022-05-03 19:46:02 +00:00
- name : Collect orbit logs
if : always()
run : |
mkdir orbit-logs
sudo cp /var/log/orbit/* orbit-logs/
- name : Upload Orbit logs
if : always()
2023-04-24 18:27:56 +00:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2
2022-05-03 19:46:02 +00:00
with :
2023-09-01 15:25:17 +00:00
name : orbit-macos-${{ matrix.orbit-channel }}-${{ matrix.osqueryd-channel }}-${{ matrix.desktop-channel }}-logs
2022-05-03 19:46:02 +00:00
path : |
orbit-logs
- name : Uninstall Orbit
run : |
./orbit/tools/cleanup/cleanup_macos.sh
2022-01-13 21:59:22 +00:00
orbit-ubuntu :
2023-08-30 18:49:47 +00:00
timeout-minutes : 10
2022-01-13 21:59:22 +00:00
strategy :
matrix :
2023-09-01 15:25:17 +00:00
# To run multiple VMs that have the same UUID we need to implement
# https://github.com/fleetdm/fleet/issues/8021 (otherwise orbit and osqueryd
# in the same host are enrolled as two hosts in Fleet).
# Until then we will just test the `stable` channel in all components.
orbit-channel : [ 'stable' ]
osqueryd-channel : [ 'stable' ]
desktop-channel : [ 'stable' ]
2022-01-13 21:59:22 +00:00
runs-on : ubuntu-latest
needs : [ gen, login]
steps :
- name : Install dependencies
run : |
npm install -g fleetctl
fleetctl config set --address ${{ needs.gen.outputs.address }} --token ${{ needs.login.outputs.token }}
2022-05-03 19:46:02 +00:00
- name : Install Go
2023-08-31 17:09:21 +00:00
uses : actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
2022-01-13 21:59:22 +00:00
with :
2023-11-03 14:42:27 +00:00
go-version : ${{ vars.GO_VERSION }}
2022-05-03 19:46:02 +00:00
- name : Checkout Code
2023-08-31 17:09:21 +00:00
uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
2022-05-03 19:46:02 +00:00
- name : Build Fleetctl
run : make fleetctl
2022-01-13 21:59:22 +00:00
- name : Install Orbit
run : |
sudo hostname ubuntu-orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}
chmod +x ./build/fleetctl
SECRET_JSON=$(fleetctl get enroll_secret --json --debug)
echo $SECRET_JSON
SECRET=$(echo $SECRET_JSON | jq -r '.spec.secrets[0].secret')
echo "Secret: $SECRET"
echo "Hostname: $(hostname -s)"
2023-09-01 15:25:17 +00:00
./build/fleetctl package --type deb --fleet-url=${{ needs.gen.outputs.address }} --enroll-secret=$SECRET --orbit-channel=${{ matrix.orbit-channel }} --osqueryd-channel=${{ matrix.osqueryd-channel }} --desktop-channel=${{ matrix.desktop-channel }} --fleet-desktop --debug
2022-01-13 21:59:22 +00:00
sudo dpkg -i fleet-osquery*
until fleetctl get hosts | grep -iF $(hostname -s);
do
echo "Awaiting enrollment..."
sudo systemctl status orbit.service || true
2022-05-03 19:46:02 +00:00
sleep 10
2022-01-13 21:59:22 +00:00
done
2022-05-03 19:46:02 +00:00
- name : Collect orbit logs
if : always()
run : |
sudo journalctl -u orbit.service > orbit-logs
- name : Upload Orbit logs
if : always()
2023-04-24 18:27:56 +00:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2
2022-05-03 19:46:02 +00:00
with :
2023-09-01 15:25:17 +00:00
name : orbit-ubuntu-${{ matrix.orbit-channel }}-${{ matrix.osqueryd-channel }}-${{ matrix.desktop-channel }}-logs
2022-05-03 19:46:02 +00:00
path : |
orbit-logs
- name : Uninstall Orbit
run : |
2022-04-19 12:32:47 +00:00
sudo apt remove fleet-osquery -y
2022-01-13 21:59:22 +00:00
orbit-windows-build :
2023-08-30 18:49:47 +00:00
timeout-minutes : 10
2022-01-13 21:59:22 +00:00
strategy :
matrix :
2023-09-01 15:25:17 +00:00
# To run multiple VMs that have the same UUID we need to implement
# https://github.com/fleetdm/fleet/issues/8021 (otherwise orbit and osqueryd
# in the same host are enrolled as two hosts in Fleet).
# Until then we will just test the `stable` channel in all components.
orbit-channel : [ 'stable' ]
osqueryd-channel : [ 'stable' ]
desktop-channel : [ 'stable' ]
2022-01-13 21:59:22 +00:00
runs-on : ubuntu-latest
needs : [ gen, login]
steps :
- name : Install dependencies
run : |
docker pull fleetdm/wix:latest &
npm install -g fleetctl
fleetctl config set --address ${{ needs.gen.outputs.address }} --token ${{ needs.login.outputs.token }}
- name : Build Orbit
run : |
SECRET_JSON=$(fleetctl get enroll_secret --json --debug)
echo $SECRET_JSON
SECRET=$(echo $SECRET_JSON | jq -r '.spec.secrets[0].secret')
echo "Secret: $SECRET"
echo "Hostname: $(hostname -s)"
2023-09-01 15:25:17 +00:00
fleetctl package --type msi --fleet-url=${{ needs.gen.outputs.address }} --enroll-secret=$SECRET --orbit-channel=${{ matrix.orbit-channel }} --osqueryd-channel=${{ matrix.osqueryd-channel }} --desktop-channel=${{ matrix.desktop-channel }} --fleet-desktop --debug
mv fleet-osquery.msi orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}-desktop-${{ matrix.desktop-channel }}.msi
2022-01-13 21:59:22 +00:00
- name : Upload MSI
2023-04-24 18:27:56 +00:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2
2022-01-13 21:59:22 +00:00
with :
2023-09-01 15:25:17 +00:00
name : orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}-desktop-${{ matrix.desktop-channel }}.msi
path : orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}-desktop-${{ matrix.desktop-channel }}.msi
2022-01-13 21:59:22 +00:00
orbit-windows :
2023-08-30 18:49:47 +00:00
timeout-minutes : 10
2022-01-13 21:59:22 +00:00
strategy :
matrix :
2023-09-01 15:25:17 +00:00
# To run multiple VMs that have the same UUID we need to implement
# https://github.com/fleetdm/fleet/issues/8021 (otherwise orbit and osqueryd
# in the same host are enrolled as two hosts in Fleet).
# Until then we will just test the `stable` channel in all components.
orbit-channel : [ 'stable' ]
osqueryd-channel : [ 'stable' ]
desktop-channel : [ 'stable' ]
2022-01-13 21:59:22 +00:00
needs : [ gen, login, orbit-windows-build]
runs-on : windows-latest
steps :
- name : Install dependencies
shell : bash
run : |
npm install -g fleetctl
fleetctl config set --address ${{ needs.gen.outputs.address }} --token ${{ needs.login.outputs.token }} --tls-skip-verify
- name : Download MSI
id : download
2022-04-19 01:59:59 +00:00
uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2
2022-01-13 21:59:22 +00:00
with :
2023-09-01 15:25:17 +00:00
name : orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}-desktop-${{ matrix.desktop-channel }}.msi
2022-10-07 15:43:56 +00:00
2022-01-13 21:59:22 +00:00
- name : Install Orbit
2023-08-30 18:49:47 +00:00
shell : cmd
2022-01-13 21:59:22 +00:00
run : |
2023-09-01 15:25:17 +00:00
msiexec /i ${{steps.download.outputs.download-path}}\orbit-${{ matrix.orbit-channel }}-osqueryd-${{ matrix.osqueryd-channel }}-desktop-${{ matrix.desktop-channel }}.msi /quiet /passive /lv log.txt
2022-01-13 21:59:22 +00:00
sleep 30
# We can't very accurately check the install on these Windows hosts since the hostnames tend to
# overlap and we can't control the hostnames. Instead we just return and have the run-server job
2022-05-03 19:46:02 +00:00
# wait until the expected number of hosts enroll.
2023-08-30 18:49:47 +00:00
- name : Upload orbit install log
if : always()
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2
with :
name : msiexec-install-log
path : log.txt
2022-05-03 19:46:02 +00:00
- name : Upload Orbit logs
if : always()
2023-04-24 18:27:56 +00:00
uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2
2022-05-03 19:46:02 +00:00
with :
2023-09-01 15:25:17 +00:00
name : orbit-windows-${{ matrix.orbit-channel }}-${{ matrix.osqueryd-channel }}-${{ matrix.desktop-channel }}-logs
2022-06-01 16:54:16 +00:00
path : C:\Windows\system32\config\systemprofile\AppData\Local\FleetDM\Orbit\Logs\orbit-osquery.log