Created
August 5, 2014 01:26
-
-
Save curious-eyes/10085afc1d17cb2f3365 to your computer and use it in GitHub Desktop.
AnsibleでGCEロードバランシング ref: http://qiita.com/curious-eyes/items/26c3669ab73c62b00c7c
This file contains 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
$ 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 |
This file contains 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
$ 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 |
This file contains 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
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"] |
This file contains 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
#!/bin/bash | |
while true; | |
do | |
curl -s http://$1; | |
echo ""; | |
sleep 0.5; | |
done |
This file contains 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: 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