From 3870956f0a8dc7f37ffa16d9907a528814c0eab4 Mon Sep 17 00:00:00 2001 From: jack Date: Sun, 14 Aug 2016 14:13:23 +0300 Subject: [PATCH] google and azure --- azure.yml | 99 ++++++++++++++++++++++++++++ google_cloud.yml | 99 ++++++++++++++++++++++++++++ roles/azure/handlers/main.yml | 0 roles/azure/tasks/main.yml | 45 +++++++++++++ roles/google_cloud/handlers/main.yml | 0 roles/google_cloud/tasks/main.yml | 13 ++++ 6 files changed, 256 insertions(+) create mode 100644 azure.yml create mode 100644 google_cloud.yml create mode 100644 roles/azure/handlers/main.yml create mode 100644 roles/azure/tasks/main.yml create mode 100644 roles/google_cloud/handlers/main.yml create mode 100644 roles/google_cloud/tasks/main.yml diff --git a/azure.yml b/azure.yml new file mode 100644 index 0000000..5e35b77 --- /dev/null +++ b/azure.yml @@ -0,0 +1,99 @@ +- name: Configure the server and install required software + hosts: localhost + gather_facts: false + + vars: + regions: + "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" + + #vars_prompt: + #- name: "azure_subscription_id" + #prompt: "Enter your subscription ID (https://blogs.msdn.microsoft.com/mschray/2015/05/13/getting-your-azure-guid-subscription-id/):\n" + #private: yes + + #- name: "management_cert_path" + #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" + #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: "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" + #prompt: "Name the vpn server:\n" + #default: "algo.local" + #private: no + + #- name: "dns_enabled" + #prompt: "Do you want to use a local DNS resolver to block ads while surfing? (Y or N):\n" + #default: "Y" + #private: no + + #- name: "auditd_enabled" + #prompt: "Do you want to use auditd ? (Y or N):\n" + #default: "Y" + #private: no + + roles: + - azure + +- name: Post-provisioning tasks + hosts: vpn-host + gather_facts: false + become: true + vars_files: + - config.cfg + + pre_tasks: + - name: Install prerequisites + raw: sudo apt-get update -qq && sudo apt-get install -qq -y python2.7 + - name: Configure defaults + raw: sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 + + roles: + - common + - security + - features + - vpn + - { role: logging, when: auditd_enabled is defined and auditd_enabled == 'Y' } + + + + + diff --git a/google_cloud.yml b/google_cloud.yml new file mode 100644 index 0000000..80da93b --- /dev/null +++ b/google_cloud.yml @@ -0,0 +1,99 @@ +- name: Configure the server and install required software + hosts: localhost + gather_facts: false + + vars: + regions: + "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" + + #vars_prompt: + #- name: "azure_subscription_id" + #prompt: "Enter your subscription ID (https://blogs.msdn.microsoft.com/mschray/2015/05/13/getting-your-azure-guid-subscription-id/):\n" + #private: yes + + #- name: "management_cert_path" + #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" + #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: "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" + #prompt: "Name the vpn server:\n" + #default: "algo.local" + #private: no + + #- name: "dns_enabled" + #prompt: "Do you want to use a local DNS resolver to block ads while surfing? (Y or N):\n" + #default: "Y" + #private: no + + #- name: "auditd_enabled" + #prompt: "Do you want to use auditd ? (Y or N):\n" + #default: "Y" + #private: no + + roles: + - google_cloud + +- name: Post-provisioning tasks + hosts: vpn-host + gather_facts: false + become: true + vars_files: + - config.cfg + + pre_tasks: + - name: Install prerequisites + raw: sudo apt-get update -qq && sudo apt-get install -qq -y python2.7 + - name: Configure defaults + raw: sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 + + roles: + - common + - security + - features + - vpn + - { role: logging, when: auditd_enabled is defined and auditd_enabled == 'Y' } + + + + + diff --git a/roles/azure/handlers/main.yml b/roles/azure/handlers/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/roles/azure/tasks/main.yml b/roles/azure/tasks/main.yml new file mode 100644 index 0000000..b17811c --- /dev/null +++ b/roles/azure/tasks/main.yml @@ -0,0 +1,45 @@ +- local_action: + module: azure + name: my-virtual-machine + role_size: Small + image: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-precise-12_04_3-LTS-amd64-server-20131205-en-us-30GB + location: 'East US' + user: ubuntu + ssh_cert_path: "/home/jack/.ssh/upwork.pub" + storage_account: my-storage-account + wait: yes + subscription_id: "02e68d20-1a39-4faa-aa35-6bdd0238b54e" + management_cert_path: "/home/jack/ownCloud/Clouds/azure/manage.cer" + + +#- name: "Creating a virtual machine..." + #azure: + #subscription_id: "02e68d20-1a39-4faa-aa35-6bdd0238b54e" + #name: "algo-vpn" + #role_size: Small + #image: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-16_04-LTS-amd64-server-20160721-en-us-30GB + #location: "West Europe" + #user: ubuntu + #ssh_cert_path: "/home/jack/.ssh/upwork.pub" + #storage_account: 'algo.vpn' + #management_cert_path: "/home/jack/ownCloud/Clouds/azure/manage.cer" + #wait: yes + #state: present + #register: azure_vm + +- debug: msg="{{ azure_vm }}" + +#- name: Add the droplet to an inventory group + #add_host: + #name: "{{ do.droplet.ip_address }}" + #groups: vpn-host + #ansible_ssh_user: root + #ansible_python_interpreter: "/usr/bin/python2.7" + #do_access_token: "{{ do_access_token }}" + #do_droplet_id: "{{ do.droplet.id }}" + #dns_enabled: "{{ dns_enabled }}" + #auditd_enabled: " {{ auditd_enabled }}" + +#- name: Wait for SSH to become available + #local_action: "wait_for port=22 host={{ do.droplet.ip_address }} timeout=320" + diff --git a/roles/google_cloud/handlers/main.yml b/roles/google_cloud/handlers/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/roles/google_cloud/tasks/main.yml b/roles/google_cloud/tasks/main.yml new file mode 100644 index 0000000..ed3b6f3 --- /dev/null +++ b/roles/google_cloud/tasks/main.yml @@ -0,0 +1,13 @@ +- name: Launch instances + gce: + instance_names: dev + zone: us-central1-b + machine_type: n1-standard-1 + image: debian-7-wheezy + service_account_email: e601809@gmail.com + credentials_file: '/home/jack/ownCloud/Clouds/Google/My First Project-72e386228f5e.json' + project_id: algo-833@storied-bearing-140310.iam.gserviceaccount.com + register: google_vm + +- debug: msg="{{ google_vm }}" +