hey gang! I am trying to test out some Fleet Calen...
# fleet
b
hey gang! I am trying to test out some Fleet Calendar Integration automations, but I am having trouble getting the calendar event to show up a second time after the event passes once during the day. https://fleetdm.com/guides/automations#basic-article This says that the
Fleet checks whether to trigger policy automations once per day by default.
Is there any way to get this to trigger manually? Or at least not every 24 hours for the sake of testing?
Also is this only triggered once per day, per account or per device? I have a second macbook that I spun up to test this and it isn't getting the calendar event now either and it has the same google account loaded into it
k
Hi @Billy H! This is a two step process. 1. Reset the automation trigger so that all hosts are seen as newly failing a. https://fleetdm.com/docs/rest-api/rest-api#run-automation-for-all-failing-hosts-of-a-policy i. Note: I've got a PR in to update the wording of this endpoint to indicate that it resets the status rather than triggering automations to run. 2. Trigger the calendar automation manually a.
fleetctl trigger --name calendar
b
excellent this is exactly what I was looking for! Thanks Kathy!!
hey @Kathy Satterlee so I just got this going but it still hasn't retriggered the calendar event yet, any ideas?
Copy code
import json
import urllib.request
import urllib.error

def reset_automations(api_key, team_ids, policy_ids):
    fleet_api_url = "<https://fleet.website.com/api/v1/fleet/automations/reset>"
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }
    data = json.dumps({
        "team_ids": team_ids,
        "policy_ids": policy_ids
    }).encode('utf-8')
    req = urllib.request.Request(fleet_api_url, data=data, headers=headers, method='POST')

    try:
        with urllib.request.urlopen(req) as response:
            response_body = response.read().decode('utf-8')
            print(f"Response Status: {response.status}")
            print(f"Response Body: {response_body}")
            return response.status, response_body
    except urllib.error.HTTPError as e:
        error_body = e.read().decode('utf-8')
        print(f"HTTP Error: {e.code} - {e.reason}")
        print(f"Error Body: {error_body}")
        return e.code, None
    except urllib.error.URLError as e:
        print(f"URL Error: {e.reason}")
        return None, None

policy_ids = [2103]
team_ids = [8]
fleet_api_key = "apikeygoeshere"

reset_automations(fleet_api_key, team_ids, policy_ids)
Output:
Copy code
Response Status: 200
Response Body: {}
fleetctl trigger --name calendar
Output:
[+] Sent request to trigger calendar schedule
k
Just to verify, do you have hosts in that team that are failing the policy currently?
I'd also like to see what happens with:
fleetctl trigger --name automations
b
yes I can confirm 2 hosts on the team that are failing the policy. just tried doing it all again and adding in the automations trigger, I'll keep you posted
ok so i ran all three of those and still no dice. It is not creating a new calendar event.
@Kathy Satterlee Alright well 3rd days the charm, I got my workflow working today so I wont need more testing. But would be nice to have some way to reset this flow for future testing