Google Cloud Engine #27

This commit is contained in:
jack 2016-08-14 16:36:50 +03:00
parent 3870956f0a
commit 89758aaec9
3 changed files with 79 additions and 71 deletions

View file

@ -3,72 +3,64 @@
gather_facts: false gather_facts: false
vars: vars:
regions: zones:
"1": "East US" "1": "us-central1-a"
"2": "West US" "2": "us-central1-b"
"3": "South Central US" "3": "us-central1-c"
"4": "North Europe" "4": "us-central1-f"
"5": "East Asia" "5": "us-east1-b"
"6": "Japan East" "6": "us-east1-c"
"7": "West Europe" "7": "us-east1-d"
"8": "Southeast Asia" "8": "europe-west1-b"
"9": "Japan West" "9": "europe-west1-c"
"10": "North Central US" "10": "europe-west1-d"
"11": "Central US" "11": "asia-east1-a"
"12": "Brazil South" "12": "asia-east1-b"
"13": "East US 2" "13": "asia-east1-c"
"14": "Australia Southeast"
"15": "Australia East"
#vars_prompt: vars_prompt:
#- name: "azure_subscription_id" - name: "credentials_file"
#prompt: "Enter your subscription ID (https://blogs.msdn.microsoft.com/mschray/2015/05/13/getting-your-azure-guid-subscription-id/):\n" prompt: "Enter the local path to your credentials JSON file [ex: ~/gogle_cloud.json] (https://support.google.com/cloud/answer/6158849?hl=en&ref_topic=6262490#serviceaccounts):\n"
#private: yes private: no
- name: "ssh_public_key"
prompt: "Enter the local path to your SSH public key [ex: ~/.ssh/id_rsa.pub] :\n"
private: no
#- name: "management_cert_path" - name: "zone"
#prompt: "Enter the local path to your management cert [ex: ~/.ssh/id_rsa.pub] (https://azure.microsoft.com/en-us/documentation/articles/azure-api-management-certs/):\n" prompt: >
#private: no What zone should the server be located in?
1. Central US (Iowa A)
2. Central US (Iowa B)
3. Central US (Iowa C)
4. Central US (Iowa F)
5. Eastern US (South Carolina B)
6. Eastern US (South Carolina C)
7. Eastern US (South Carolina D)
8. Western Europe (Belgium B)
9. Western Europe (Belgium C)
10. Western Europe (Belgium D)
11. East Asia (Taiwan A)
12. East Asia (Taiwan B)
13. East Asia (Taiwan C)
Please choose the number of your zone. Press enter for default (#8) zone.
default: "8"
private: no
#- name: "ssh_public_key" - name: "server_name"
#prompt: "Enter the local path to your SSH public key [ex: ~/.ssh/id_rsa.pub] :\n" prompt: "Name the vpn server:\n"
#private: no default: "algo"
private: no
#- name: "region"
#prompt: >
#What region should the server be located in?
#1. East US
#2. West US
#3. South Central US
#4. North Europe
#5. East Asia
#6. Japan East
#7. West Europe
#8. Southeast Asia
#9. Japan West
#10. North Central US
#11. Central US
#12. Brazil South
#13. East US 2
#14. Australia Southeast
#15. Australia East
#Enter the number of your desired region:
#default: "7"
#private: no
#- name: "azure_server_name" - name: "dns_enabled"
#prompt: "Name the vpn server:\n" prompt: "Do you want to use a local DNS resolver to block ads while surfing? (Y or N):\n"
#default: "algo.local" default: "Y"
#private: no private: no
#- name: "dns_enabled" - name: "auditd_enabled"
#prompt: "Do you want to use a local DNS resolver to block ads while surfing? (Y or N):\n" prompt: "Do you want to use auditd ? (Y or N):\n"
#default: "Y" default: "Y"
#private: no private: no
#- name: "auditd_enabled"
#prompt: "Do you want to use auditd ? (Y or N):\n"
#default: "Y"
#private: no
roles: roles:
- google_cloud - google_cloud

View file

@ -1,13 +1,29 @@
- name: Launch instances - set_fact:
credentials_file_lookup: "{{ lookup('file', '{{ credentials_file }}') }}"
ssh_public_key_lookup: "{{ lookup('file', '{{ ssh_public_key }}') }}"
- name: "Creating a droplet..."
gce: gce:
instance_names: dev instance_names: "{{ server_name }}"
zone: us-central1-b zone: "{{ zones[zone] }}"
machine_type: n1-standard-1 machine_type: n1-standard-1
image: debian-7-wheezy image: ubuntu-1604
service_account_email: e601809@gmail.com service_account_email: "{{ credentials_file_lookup.client_email }}"
credentials_file: '/home/jack/ownCloud/Clouds/Google/My First Project-72e386228f5e.json' credentials_file: "{{ credentials_file }}"
project_id: algo-833@storied-bearing-140310.iam.gserviceaccount.com project_id: "{{ credentials_file_lookup.project_id }}"
metadata: '{"sshKeys":"root:{{ ssh_public_key_lookup }}"}'
register: google_vm register: google_vm
- debug: msg="{{ google_vm }}" - name: Add the droplet to an inventory group
add_host:
name: "{{ google_vm.instance_data[0].public_ip}}"
groups: vpn-host
ansible_ssh_user: ubuntu
ansible_python_interpreter: "/usr/bin/python2.7"
dns_enabled: "{{ dns_enabled }}"
auditd_enabled: " {{ auditd_enabled }}"
- name: Wait for SSH to become available
local_action: "wait_for port=22 host={{ google_vm.instance_data[0].public_ip }} timeout=320"

4
run
View file

@ -9,8 +9,8 @@ algo_provisioning () {
4. Google-cloud 4. Google-cloud
0. Local installation (non-cloud or a server already deployed) 0. Local installation (non-cloud or a server already deployed)
Enter the number of your desired provider Enter the number of your desired provider
: " : "
read N read N