Using Ansible to Automate Google Compute Engine
Monday, May 5, 2014
Today's guest post comes from Michael Dehaan, the original author of Ansible and CTO of Ansible, Inc.
Ansible is an easy to use IT automation platform that provides the ability to deploy applications, configure systems, and orchestrate complex workflows. Ansible has had support for Google Cloud Platform for about a year, and we’d like to share a bit of information about how to use it.
Examples are available in our Google Cloud Platform Guide -- as well as several “gc” prefixed modules in our Cloud Module Index.
Users have a lot of choices in picking how they want to manage their cloud infrastructure. When automating in the cloud, some of the most important things to consider are dealing with the challenges of the management stack itself, and how the management stack interacts and scales as the nature of cloud deployments increase in complexity. Not only do you need a system that is easy to maintain, but also a system where the automation content is easy to write and evolve.
Ansible is designed around SSH because SSH is cloud native -- which works well with Google Cloud Platform in many ways.
By using SSH to manage your nodes, there are no additional daemons to install, or security packages to manage. SSH keys can be easily injected upon virtual machine instantiation. No additional resources are consumed on remote nodes, and there’s never the problem of a management agent “falling over” and the user not having a way to automate the box. There are no additional open ports, and when a box is not being managed by Ansible, nothing extra is running. Ansible enables this not by logging into your boxes and running commands, but by connecting to them over SSH to transfer modules, run them, and parse out responses. It then cleans up after itself leaving nothing behind but logs.

One of Ansible’s main focuses is around application deployment of complex multi-tier applications. This includes not only cloud provisioning (as illustrated in the Compute Engine guide) but also working with zero-downtime rolling updates involving load-balanced infrastructure -- which there is also an Ansible module for the Compute Engine Load-Balancer. Instances can either be updated in place, or new machines can be spun up and added to load balancers while others are spun down. Additionally storage and networking can be worked with as well.
Another way that Ansible integrates with Compute Engine, also as documented in the Google Cloud Platform Guide, is the ability to query inventory dynamically from the Google cloud. In getting the most out of cloud, it’s important to treat instances as cattle, not pets. Having groups of machines sorted by tag, rather than instance hostnames, greatly decreases management complexity as scale changes.

If you’d like to find out more about Ansible generally, see docs.ansible.com, and also explore some of the community roles found at galaxy.ansible.com. Ansible Galaxy is a site where users can create and share automation roles with each other, which can help jumpstart new deployments.
If you have specific questions about Ansible and Compute Engine, you may wish to join the Ansible Project Google Group.
-Contributed by Michael DeHaan, original author of Ansible, and CTO of Ansible, Inc.
Ansible is an easy to use IT automation platform that provides the ability to deploy applications, configure systems, and orchestrate complex workflows. Ansible has had support for Google Cloud Platform for about a year, and we’d like to share a bit of information about how to use it.
Examples are available in our Google Cloud Platform Guide -- as well as several “gc” prefixed modules in our Cloud Module Index.
Users have a lot of choices in picking how they want to manage their cloud infrastructure. When automating in the cloud, some of the most important things to consider are dealing with the challenges of the management stack itself, and how the management stack interacts and scales as the nature of cloud deployments increase in complexity. Not only do you need a system that is easy to maintain, but also a system where the automation content is easy to write and evolve.
Ansible is designed around SSH because SSH is cloud native -- which works well with Google Cloud Platform in many ways.
By using SSH to manage your nodes, there are no additional daemons to install, or security packages to manage. SSH keys can be easily injected upon virtual machine instantiation. No additional resources are consumed on remote nodes, and there’s never the problem of a management agent “falling over” and the user not having a way to automate the box. There are no additional open ports, and when a box is not being managed by Ansible, nothing extra is running. Ansible enables this not by logging into your boxes and running commands, but by connecting to them over SSH to transfer modules, run them, and parse out responses. It then cleans up after itself leaving nothing behind but logs.
One of Ansible’s main focuses is around application deployment of complex multi-tier applications. This includes not only cloud provisioning (as illustrated in the Compute Engine guide) but also working with zero-downtime rolling updates involving load-balanced infrastructure -- which there is also an Ansible module for the Compute Engine Load-Balancer. Instances can either be updated in place, or new machines can be spun up and added to load balancers while others are spun down. Additionally storage and networking can be worked with as well.
Another way that Ansible integrates with Compute Engine, also as documented in the Google Cloud Platform Guide, is the ability to query inventory dynamically from the Google cloud. In getting the most out of cloud, it’s important to treat instances as cattle, not pets. Having groups of machines sorted by tag, rather than instance hostnames, greatly decreases management complexity as scale changes.
If you’d like to find out more about Ansible generally, see docs.ansible.com, and also explore some of the community roles found at galaxy.ansible.com. Ansible Galaxy is a site where users can create and share automation roles with each other, which can help jumpstart new deployments.
If you have specific questions about Ansible and Compute Engine, you may wish to join the Ansible Project Google Group.
-Contributed by Michael DeHaan, original author of Ansible, and CTO of Ansible, Inc.