Skip to content

Instantly share code, notes, and snippets.

@dch
Created January 13, 2014 01:00
Show Gist options
  • Save dch/8393012 to your computer and use it in GitHub Desktop.
Save dch/8393012 to your computer and use it in GitHub Desktop.
- name: Create two new GCE instances
hosts: localhost
gather_facts: no
vars:
names: tmp
type: n1-standard-1
image: debian-7
zone: us-central1-a
tasks:
- name: Launch instances
local_action: gce instance_names={{ names }} machine_type={{ type }} image={{ image }} zone={{ zone }}
register: gce
- name: Wait for SSH to be available
local_action: wait_for host={{ item.public_ip }} port=22 delay=10 timeout=60 state=started
with_items: gce.instance_data
- name: Install apache, set a custom index.html
hosts: gce_instances
sudo: yes
tasks:
- name: Install apache
apt: pkg=apache2 state=present
- name: custom index.html
copy: dest=/var/www/index.html content='Hi, I am {{ ansible_hostname }}'
- name: set file stats on index.html
file: path=/var/www/html/index.html owner=root group=root mode=0644
- name: start apache
service: name=apache2 state=started
[localhost]
127.0.0.1
[gce_instances]
tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment