Demo: Ansible and Google Compute Engine
(*) See other modules such as gce_pd, gce_net, gce_lb, gc_storage, gc_dns
Example: Install Apache
1 - name: Set up webservers
2 hosts: web
3 sudo: yes
4 tasks:
5 - name: Install Apache
6 action: apt pkg=apache state=present
7 - name: Lay down custom index.html
8 copy: dest=/var/www/index.html content='Hello, World'
9 - name: Start Apache
10 service: name=apache state=started
Example: Create a Compute Engine instance
1 - name: Compute Engine demo
2 hosts: local
3 gather_facts: False
4 vars:
5 pid: graphite-demos
6 email: 1234567890-xxxxxxxxxxxxx@developer.gserviceaccount.com
7 pem: /etc/ansible/pkey.pem
8 tasks:
9 - name: Create instance
10 gce:
11 instance_names: demo1,demo2
12 zone: us-central1-b
13 machine_type: n1-standard-1
14 image: debian-7-wheezy
15 project_id: "{{ pid }}"
16 pem_file: "{{ pem }}"
17 service_account_email: "{{ email }}"