Skip to content

Instantly share code, notes, and snippets.

@curious-eyes
Created August 5, 2014 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curious-eyes/10085afc1d17cb2f3365 to your computer and use it in GitHub Desktop.
Save curious-eyes/10085afc1d17cb2f3365 to your computer and use it in GitHub Desktop.
AnsibleでGCEロードバランシング ref: http://qiita.com/curious-eyes/items/26c3669ab73c62b00c7c
$ cd ~/gce_ansible
$ ./play.sh master.yml
PLAY [Create new GCE instances] ******************
...(略)...
TASK: [Create LoadBalancer] **********************
changed: [127.0.0.1] => {"changed": true, "external_ip": "107.167.187.229", ...
PLAY RECAP ***************************************
107.167.178.56 : ok=9 changed=4 unreachable=0 failed=0
107.167.182.216 : ok=9 changed=4 unreachable=0 failed=0
127.0.0.1 : ok=5 changed=3 unreachable=0 failed=0
$ cd ~/gce_ansible
$ ./lb-test.sh 107.167.187.229
Hi, I am www3
Hi, I am www2
Hi, I am www3
Hi, I am www3
Hi, I am www2
Hi, I am www2
Hi, I am www2
Hi, I am www3
Hi, I am www2
Hi, I am www2
^C
names: www2,www3
type: f1-micro
image: debian-7
zone: asia-east1-a
region: asia-east1
members: ["asia-east1-a/www2", "asia-east1-a/www3"]
#!/bin/bash
while true;
do
curl -s http://$1;
echo "";
sleep 0.5;
done
- name: Set up the load-balancer
hosts: localhost
gather_facts: no
vars_files:
- "vars/instance.yml"
- "vars/gce_auth.yml"
tasks:
- name: Create LoadBalancer
local_action:
module: gce_lb
name: lb
httphealthcheck_name: hc
httphealthcheck_port: 80
httphealthcheck_path: "/isup.html"
region: "{{ region }}"
members: "{{ members }}"
service_account_email: "{{ service_account_email }}"
pem_file: "{{ pem_file }}"
project_id: "{{ project_id }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment