Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ansible with Google

Eric Johnson
October 22, 2013

Ansible with Google

Introducing Ansible modules supporting Google Compute Engine and a brief overview of the Google Cloud Platform. Presented at AnsibleFest 2013 in San Francisco by Eric Johnson.

Eric Johnson

October 22, 2013
Tweet

More Decks by Eric Johnson

Other Decks in Technology

Transcript

  1. Ansible and the Power of Google Cloud Platform Eric Johnson

    Program Manager, Google Compute Engine
  2. Cloud Platform Agenda • Why Google? • Whirlwind tour of

    Google Cloud Platform • Introducing the new Ansible Modules
  3. For the past 15 years, Google has been building out

    a massively fast, powerful, and reliable cloud infrastructure across the planet. Images by Connie Zhou
  4. Cloud Platform Developing our infrastructure while respecting our ecosystem •

    Pioneering data center efficiency • Financed over 250 Megawatts of new wind power • First data centers to receive IOS 14001 certification • 100% carbon neutral
  5. 2002 2004 2006 2008 2010 2012 Colossus Dremel MapReduce Spanner

    Big Table GFS Driving Technology Forward Cloud Platform
  6. Google Cloud Platform Storage Cloud Storage Cloud SQL Cloud Datastore

    Persistent Disk App Services BigQuery Cloud Endpoints Caching Queues Cloud Platform Compute App Engine Compute Engine
  7. Cloud Platform • BLOB Storage, Immutable Objects • Strong read-after-write

    consistency • API and Web UI Accessible • Versioning • Static Sites, ACLs • Resumable Transfers • Object Change Notifications • Object lifecycle management Google Cloud Storage
  8. • Fully managed, MySQL(like) • Ease of Use and Development

    • Highly Reliable • Flexible Charging • Security, Availability, Durability • EU and US Data Centers • Easy Migration & Data Portability • Control Cloud Platform Cloud SQL
  9. Cloud Platform • Schemaless, Non-relational NoSQL Access • Auto-scale •

    Authentication That Just Works • Fast and Easy Provisioning • RESTful Endpoints • ACID Transactions • Query Language (akin to SQL) • Local Development Tools • Built-in Redundancy Cloud Datastore
  10. Cloud Platform • Fully Managed Big Data Analytics Service •

    Fast • Scalable • Flexible and Familiar • Security and Reliability BigQuery
  11. Cloud Platform • Fully Managed Platform • Easy Development &

    Deployment • Focus On Your Code Not Your Server • Automatic Scaling • Popular Programming Language Support • Services (Cron, Queue, Memcache, etc) • Datastore • Versioning and Traffic Splitting • Local Developer Tools • Third-party Frameworks and Extensions App Engine
  12. Cloud Platform • Sub-hour Billing • Up to 10TB Persistent

    Disk • Over 64 Instance Types • Standard Linux Distributions • Advanced Networking • Instance Metadata and Startup Scripts • Load Balancing • Persistent Disks, snapshots • Fast and Easy Provisioning • Consistent Performance Google Compute Engine
  13. Cloud Platform New Ansible Modules New in Ansible 1.4(*) •

    Google Compute Engine ◦ gce - Instance (VM) management ◦ gce_pd - Manage Persistent Disks ◦ gce_net - Networks and Firewall Rules ◦ gce_lb - Traffic Load-balancing of Instances • Google Cloud Storage ◦ gc_storage - Manage your Buckets and Objects (*) Depends on unreleased libcloud (0.14.0-beta1 coming soon)
  14. Cloud Platform Module: gce Instance Management • Create ◦ Blocks

    until RUNNING • Destroy • Specifying instances ◦ `name` for single instances ◦ `instance_names` for >1 • With/without PD boot disk Module Parameters: image instance_names machine_type metadata name network persistent_boot_disk state tags zone
  15. Cloud Platform Inventory Plugin Instance Information • Supports --host and

    --list • Auth credentials in gce.ini • Does *not* use a local cache --list categorizes instances by • Zones, Machine Types, Networks, etc --host attributes: gce_description gce_id gce_image gce_machine_type gce_metadata gce_name gce_network gce_private_ip gce_public_ip gce_status gce_tags gce_uuid gce_zone
  16. Cloud Platform Module: gce_pd Persistent Disk Management • Unformatted Only

    • Create, Destroy • Attach / Detach • RW / RO Module Parameters: detach_only instance_name mode name size_gb state zone
  17. Cloud Platform Module: gce_net Networks and Firewalls • Create /

    Destroy Networks ◦ Networks are global ◦ User defined network ranges • Create / Destroy FW Rules ◦ FW Rules require a network ◦ Custom protocol/ports ◦ Tags / ranges supported Module Parameters: allowed ipv4_range fwname name src_range src_tags state
  18. Cloud Platform Module: gce_lb Manage Load-balancing • Instance / member

    list • Protocol / port range • HTTP HealthChecking Module Parameters: httphealthcheck_name httphealthcheck_port httphealthcheck_path httphealthcheck_interval httphealthcheck_timeout httphealthcheck_unhealthy_count httphealthcheck_healthy_count httphealthcheck_host name protocol region external_ip port_range members state
  19. Cloud Platform Module: gc_storage Google Cloud Storage • Manage Buckets

    / Objects • Upload / Download Objects • Interoperable Mode • Uses ‘boto’ library Module Parameters: bucket dest expiration force gcs_access_key gcs_secret_key mode object permission src
  20. Cloud Platform Demo Time! Using the new Ansible GCE Modules,

    let’s build a trivial load-balanced web site • Spin up two GCE instances • Install Apache and custom index.html page • Create a custom Health Check URL • Create a Load Balancer and open up TCP:80
  21. $ cat inv.ini [localhost] 127.0.0.1 [gce_instances] www1 www2 Cloud Platform

    Putting it all together... localhost inv.ini ------- gce.yml ------- Ansible + GCE www1 www2 Google API’s screencast in case of emergency
  22. Cloud Platform Putting it all together... 1 - name: Create

    two new GCE instances 2 hosts: localhost 3 gather_facts: no 4 vars: 5 names: www1,www2 6 type: n1-standard-1 7 image: centos-6 8 zone: us-central1-a 9 tasks: 10 - name: Launch instances 11 local_action: gce instance_names={{ names }} machine_type={{ type }} 12 image={{ image }} zone={{ zone }} 13 register: gce 14 - name: Wait for SSH to be available 15 local_action: wait_for host={{ item.public_ip }} port=22 delay=3 16 timeout=9 state=started 17 with_items: gce.instance_data gce.yml, part 1: Create two GCE Instances
  23. Cloud Platform Putting it all together... 1 - name: Install

    apache, set a custom index.html 2 hosts: gce_instances 3 sudo: yes 4 tasks: 5 - name: Install apache 6 yum: pkg=httpd state=present 7 - name: custom index.html 8 copy: dest=/var/www/html/index.html content='Hi, I am {{ ansible_hostname }}' 9 - name: set file stats on index.html 10 file: path=/var/www/html/index.html owner=root group=root mode=0644 11 - name: custom healthstatus 12 copy: dest=/var/www/html/isup.html content='ALIVE' 13 - name: set file stats on healthstatus 14 file: path=/var/www/html/isup.html owner=root group=root mode=0644 15 - name: start apache 16 service: name=httpd state=started gce.yml, part 2: Install Apache and Health Check URL
  24. Cloud Platform Putting it all together... 1 - name: Create

    a firewall rule to allow HTTP 2 hosts: localhost 3 gather_facts: no 4 tasks: 5 - name: Allow HTTP 6 local_action: gce_net fwname=all-http name=default allowed=tcp:80 7 8 9 - name: Set up the load-balancer 10 hosts: localhost 11 gather_facts: no 12 tasks: 13 - name: Create LB 14 local_action: gce_lb httphealthcheck_name=hc httphealthcheck_path=/isup.html 15 name=lb region=us-central2 16 members=”{{ gce.zone }}/www1,{{ gce.zone }}/www2” gce.yml, part 3: Open TCP:80 and set up Loadbalancer
  25. Cloud Platform And finally... Google + Ansible = Awesome! •

    Use the platform and send us feedback ◦ https://cloud.google.com/ • Help improve Ansible+Google modules Thank you!