Ansible and Google Calendar Integration for Change Management

Networking, Cloud & Automation
The Startup
Published in
3 min readSep 16, 2020

--

Is anytime a good time to execute your automation workflow? The answer is probably no, for different reasons.

If you want to avoid simultaneous changes to minimize the impact on critical business processes and reduce the risk of unintended service disruptions, then no one else should be attempting to make changes at the same time.

In some scenarios, there could be an ongoing scheduled maintenance window. Or maybe there is a big event coming up, a critical business time, a holiday, or you prefer not to make changes on a Friday night.

Whatever the reason is, we want to signal this to our Automation platform and prevent the execution of periodic or ad-hoc tasks on specific time slots. In Change Management jargon we are talking about blackout windows when change activity should not occur.

Calendar in Ansible

How can we accomplish this in Ansible? While there is no Calendar function per se, however, Ansible’s extensibility will allow us to integrate with any Calendar application that has an API.

The goal is this: Before we execute any automation or change activity, we execute a pre-task that checks whether there is something already scheduled in the Calendar going on or soon enough, or to confirm we are not in the middle of a blocked timeslot.

Let’s pretend a fictitious module named calendar exists, and that it can connect to a remote calendar, like Google Calendar, to determine if the supplied time has been marked as busy. Then we could write a playbook that looks like this:

Ansible facts will give us ansible_date_time which we pass to the calendar module to verify the time availability. We register the response (output) to use in subsequent tasks.

If our calendar looked like this:

Then the output of this task would highlight the fact this timeslot is taken (busy: true).

Preventing tasks from running

Next, Ansible Conditionals will help us prevent the execution of any further tasks. As a simple example, you could use a when statement on the next task to enforce that it runs only when the field busy in the previous output is not true.

Conclusion

Like we mentioned in the previous post, Ansible is a framework to wire things together, interconnecting different building blocks to orchestrate an end-to-end automation workflow.

In this opportunity, we looked at how your Playbooks can integrate or talk to a Calendar application to check availability. However, we are just scratching the surface! For example, your tasks could also block a timeslot in the calendar… the sky is the limit.

In the next post, we will dig into how we actually built this calendar module and how other programming languages can be used with Ansible. Stay tuned if you are a Go fan like me!

--

--

Networking, Cloud & Automation
The Startup

Proud dad working at Red Hat (CCIE, CCDE). Sharing content I create about: networking, automation, programming, golang, ipv6, and open source software.