Hybrid Operations with Ansible

Hybrid Operations with Ansible

One of the most common questions I hear while talking about Ansible's support for cloud providers is whether it will work in hybrid environments. You may not be able to use the ec2 module to create an instance in your datacenter, but Ansible has modules for RHV, OpenStack, and VMWare to talk to virtualization tools in your datacenter. I love working in AWS, Azure, and Google Cloud but most environments I've worked in have had on-prem systems as well.

That's what I've been invited to Red Hat Summit to talk about -- best practices for automating all the infrastructure at your disposal, not just the cloud services. My demos will feature a couple new Ansible Core/Engine 2.5 features, as well as preview new 2.6-only features.

My favorite feature to show off is part of the new ec2_instance module. In the demo we'll have a look at how Ansible Tower provisioning callbacks are now built in to the ec2_instance module, making provisioning brand new instances as easy as:

- ec2_instance:
    id: "{{ latest_centos.image_id }}"
  key_name: my-secret-key
  instance_type: t2.large
  name: call-me-maybe
    - demo-web-sg
    host_config_key: "{{ your_secret_here }}"
    job_template_id: "configure-web-server"
    tower_address: mytower.mysite.com

This makes it easy to separate the service-provider layer of your provisioning playbooks from the on-instance work of installing packages, templating configs, and so forth. Before Ansible Tower callbacks, you'd need to provision new instances in the same playbook using a pattern like:

- ec2_instance:
    ... arguments ...
  register: ec2

# use dynamic inventory to get the host now that it's running in EC2
- meta: refresh_inventory
# wait for it to be available via SSH
- delegate_to: new-host-name
# finally, time to provision!
- delegate_to: new-host-name
  become: yes
  yum: name=nginx state=latest

After this AWS demo, we'll talk about managing multiple points of presence across AWS, Google Cloud, and RHV with Ansible. Each of these providers has wide support for virtual networking, compute, and storage.

I gave this presentation at Red Hat Summit - so if you missed the presentation, you can still see the demo repository

Happy automating!