Created
January 13, 2014 01:00
-
-
Save dch/8393012 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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