mirror of
https://github.com/trailofbits/algo
synced 2024-11-18 09:25:38 +00:00
8bdd99c05d
* bump ansible to 2.8.3 * DigitalOcean: move to the latest modules * Add Hetzner Cloud * Scaleway and Lightsail fixes * lint missing roles * Update roles/cloud-hetzner/tasks/main.yml Add api_token Co-Authored-By: phaer <phaer@phaer.org> * Update roles/cloud-hetzner/tasks/main.yml Add api_token Co-Authored-By: phaer <phaer@phaer.org> * Try to run apt until succeeded * Scaleway modules upgrade * GCP: Refactoring, remove deprecated modules * Doc updates (#1552) * Update README.md Adding links and mentions of Exoscale aka CloudStack and Hetzner Cloud. * Update index.md Add the Hetzner Cloud to the docs index * Remove link to Win 10 IPsec instructions * Delete client-windows.md Unnecessary since the deprecation of IPsec for Win10. * Update deploy-from-ansible.md Added sections and required variables for CloudStack and Hetzner Cloud. * Update deploy-from-ansible.md Added sections for CloudStack and Hetzner, added req variables and examples, mentioned environment variables, and added links to the provider role section. * Update deploy-from-ansible.md Cosmetic changes to links, fix typo. * Update GCE variables * Update deploy-from-script-or-cloud-init-to-localhost.md Fix a finer point, and make variables list more readable. * update azure requirements * Python3 draft * set LANG=c to the p12 password generation task * Update README * Install cloud requirements to the existing venv * FreeBSD fix * env->.env fixes * lightsail_region_facts fix * yaml syntax fix * Update README for Python 3 (#1564) * Update README for Python 3 * Remove tabs and tweak instructions * Remove cosmetic command indentation * Update README.md * Update README for Python 3 (#1565) * DO fix for "found unpermitted parameters: id" * Verify Python version * Remove ubuntu 16.04 from readme * Revert back DigitalOcean module * Update deploy-from-script-or-cloud-init-to-localhost.md * env to .env
80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
---
|
|
- pause:
|
|
prompt: |
|
|
Enter the local path to your credentials JSON file
|
|
(https://support.google.com/cloud/answer/6158849?hl=en&ref_topic=6262490#serviceaccounts)
|
|
register: _gce_credentials_file
|
|
when:
|
|
- gce_credentials_file is undefined
|
|
- lookup('env','GCE_CREDENTIALS_FILE_PATH')|length <= 0
|
|
|
|
- set_fact:
|
|
credentials_file_path: "{{ gce_credentials_file | default(_gce_credentials_file.user_input|default(None)) | default(lookup('env','GCE_CREDENTIALS_FILE_PATH'), true) }}"
|
|
ssh_public_key_lookup: "{{ lookup('file', '{{ SSH_keys.public }}') }}"
|
|
|
|
- set_fact:
|
|
credentials_file_lookup: "{{ lookup('file', '{{ credentials_file_path }}') }}"
|
|
|
|
- set_fact:
|
|
service_account_email: "{{ credentials_file_lookup.client_email | default(lookup('env','GCE_EMAIL')) }}"
|
|
project_id: "{{ credentials_file_lookup.project_id | default(lookup('env','GCE_PROJECT')) }}"
|
|
|
|
- block:
|
|
- name: Get regions
|
|
gcp_compute_location_info:
|
|
auth_kind: serviceaccount
|
|
service_account_file: "{{ credentials_file_path }}"
|
|
project: "{{ project_id }}"
|
|
scope: regions
|
|
filters: status=UP
|
|
register: gcp_compute_regions_info
|
|
|
|
- name: Set facts about the regions
|
|
set_fact:
|
|
gce_regions: >-
|
|
[{%- for region in gcp_compute_regions_info.resources | sort(attribute='name') -%}
|
|
'{{ region.name }}'{% if not loop.last %},{% endif %}
|
|
{%- endfor -%}]
|
|
|
|
- name: Set facts about the default region
|
|
set_fact:
|
|
default_region: >-
|
|
{% for region in gce_regions %}
|
|
{%- if region == "us-east1" %}{{ loop.index }}{% endif %}
|
|
{%- endfor %}
|
|
|
|
- pause:
|
|
prompt: |
|
|
What region should the server be located in?
|
|
(https://cloud.google.com/compute/docs/regions-zones/#locations)
|
|
{% for r in gce_regions %}
|
|
{{ loop.index }}. {{ r }}
|
|
{% endfor %}
|
|
|
|
Enter the number of your desired region
|
|
[{{ default_region }}]
|
|
register: _gce_region
|
|
when: region is undefined
|
|
|
|
- name: Set region as a fact
|
|
set_fact:
|
|
algo_region: >-
|
|
{% if region is defined %}{{ region }}
|
|
{%- elif _gce_region.user_input %}{{ gce_regions[_gce_region.user_input | int -1 ] }}
|
|
{%- else %}{{ gce_regions[default_region | int - 1] }}{% endif %}
|
|
|
|
- name: Get zones
|
|
gcp_compute_location_info:
|
|
auth_kind: serviceaccount
|
|
service_account_file: "{{ credentials_file_path }}"
|
|
project: "{{ project_id }}"
|
|
scope: zones
|
|
filters:
|
|
- "name={{ algo_region }}-*"
|
|
- "status=UP"
|
|
register: gcp_compute_zone_info
|
|
|
|
- name: Set random available zone as a fact
|
|
set_fact:
|
|
algo_zone: "{{ (gcp_compute_zone_info.resources | random(seed=algo_server_name + algo_region + project_id) ).name }}"
|