mirror of
https://github.com/trailofbits/algo.git
synced 2025-04-18 15:17:07 +02:00
fixed code to work with python3.7 (#1608)
* fixed code to work with python3.7 * removed trailing whitespaces and re-run ansible-linter
This commit is contained in:
parent
b65e6b1351
commit
43aafdfce1
2 changed files with 56 additions and 64 deletions
|
@ -1,70 +1,63 @@
|
|||
---
|
||||
- name: Build python virtual environment
|
||||
import_tasks: venv.yml
|
||||
|
||||
- name: Include prompts
|
||||
import_tasks: prompts.yml
|
||||
|
||||
- block:
|
||||
- name: Build python virtual environment
|
||||
import_tasks: venv.yml
|
||||
- set_fact:
|
||||
algo_region: >-
|
||||
{% if region is defined %}{{ region }}
|
||||
{%- elif _algo_region.user_input is defined and _algo_region.user_input | length > 0 %}{{ cs_zones[_algo_region.user_input | int -1 ]['name'] }}
|
||||
{%- else %}{{ cs_zones[default_zone | int - 1]['name'] }}{% endif %}
|
||||
|
||||
- name: Include prompts
|
||||
import_tasks: prompts.yml
|
||||
- name: Security group created
|
||||
cs_securitygroup:
|
||||
name: "{{ algo_server_name }}-security_group"
|
||||
description: AlgoVPN security group
|
||||
register: cs_security_group
|
||||
|
||||
- block:
|
||||
- set_fact:
|
||||
algo_region: >-
|
||||
{% if region is defined %}{{ region }}
|
||||
{%- elif _algo_region.user_input is defined and _algo_region.user_input | length > 0 %}{{ cs_zones[_algo_region.user_input | int -1 ]['name'] }}
|
||||
{%- else %}{{ cs_zones[default_zone | int - 1]['name'] }}{% endif %}
|
||||
- name: Security rules created
|
||||
cs_securitygroup_rule:
|
||||
security_group: "{{ cs_security_group.name }}"
|
||||
protocol: "{{ item.proto }}"
|
||||
start_port: "{{ item.start_port }}"
|
||||
end_port: "{{ item.end_port }}"
|
||||
cidr: "{{ item.range }}"
|
||||
with_items:
|
||||
- { proto: tcp, start_port: 22, end_port: 22, range: 0.0.0.0/0 }
|
||||
- { proto: udp, start_port: 4500, end_port: 4500, range: 0.0.0.0/0 }
|
||||
- { proto: udp, start_port: 500, end_port: 500, range: 0.0.0.0/0 }
|
||||
- { proto: udp, start_port: "{{ wireguard_port }}", end_port: "{{ wireguard_port }}", range: 0.0.0.0/0 }
|
||||
|
||||
- name: Security group created
|
||||
cs_securitygroup:
|
||||
name: "{{ algo_server_name }}-security_group"
|
||||
description: AlgoVPN security group
|
||||
register: cs_security_group
|
||||
- name: Keypair created
|
||||
cs_sshkeypair:
|
||||
name: "{{ SSH_keys.comment|regex_replace('@', '_') }}"
|
||||
public_key: "{{ lookup('file', '{{ SSH_keys.public }}') }}"
|
||||
register: cs_keypair
|
||||
|
||||
- name: Security rules created
|
||||
cs_securitygroup_rule:
|
||||
security_group: "{{ cs_security_group.name }}"
|
||||
protocol: "{{ item.proto }}"
|
||||
start_port: "{{ item.start_port }}"
|
||||
end_port: "{{ item.end_port }}"
|
||||
cidr: "{{ item.range }}"
|
||||
with_items:
|
||||
- { proto: tcp, start_port: 22, end_port: 22, range: 0.0.0.0/0 }
|
||||
- { proto: udp, start_port: 4500, end_port: 4500, range: 0.0.0.0/0 }
|
||||
- { proto: udp, start_port: 500, end_port: 500, range: 0.0.0.0/0 }
|
||||
- { proto: udp, start_port: "{{ wireguard_port }}", end_port: "{{ wireguard_port }}", range: 0.0.0.0/0 }
|
||||
- name: Set facts
|
||||
set_fact:
|
||||
image_id: "{{ cloud_providers.cloudstack.image }}"
|
||||
size: "{{ cloud_providers.cloudstack.size }}"
|
||||
disk: "{{ cloud_providers.cloudstack.disk }}"
|
||||
keypair_name: "{{ cs_keypair.name }}"
|
||||
|
||||
- name: Keypair created
|
||||
cs_sshkeypair:
|
||||
name: "{{ SSH_keys.comment|regex_replace('@', '_') }}"
|
||||
public_key: "{{ lookup('file', '{{ SSH_keys.public }}') }}"
|
||||
register: cs_keypair
|
||||
- name: Server created
|
||||
cs_instance:
|
||||
name: "{{ algo_server_name }}"
|
||||
root_disk_size: "{{ disk }}"
|
||||
template: "{{ image_id }}"
|
||||
ssh_key: "{{ keypair_name }}"
|
||||
security_groups: "{{ cs_security_group.name }}"
|
||||
zone: "{{ algo_region }}"
|
||||
service_offering: "{{ size }}"
|
||||
register: cs_server
|
||||
|
||||
- name: Set facts
|
||||
set_fact:
|
||||
image_id: "{{ cloud_providers.cloudstack.image }}"
|
||||
size: "{{ cloud_providers.cloudstack.size }}"
|
||||
disk: "{{ cloud_providers.cloudstack.disk }}"
|
||||
keypair_name: "{{ cs_keypair.name }}"
|
||||
|
||||
- name: Server created
|
||||
cs_instance:
|
||||
name: "{{ algo_server_name }}"
|
||||
root_disk_size: "{{ disk }}"
|
||||
template: "{{ image_id }}"
|
||||
ssh_key: "{{ keypair_name }}"
|
||||
security_groups: "{{ cs_security_group.name }}"
|
||||
zone: "{{ algo_region }}"
|
||||
service_offering: "{{ size }}"
|
||||
register: cs_server
|
||||
|
||||
- set_fact:
|
||||
cloud_instance_ip: "{{ cs_server.default_ip }}"
|
||||
ansible_ssh_user: ubuntu
|
||||
environment:
|
||||
CLOUDSTACK_CONFIG: "{{ algo_cs_config }}"
|
||||
CLOUDSTACK_REGION: "{{ algo_cs_region }}"
|
||||
|
||||
rescue:
|
||||
- debug: var=fail_hint
|
||||
tags: always
|
||||
- fail:
|
||||
tags: always
|
||||
- set_fact:
|
||||
cloud_instance_ip: "{{ cs_server.default_ip }}"
|
||||
ansible_ssh_user: ubuntu
|
||||
environment:
|
||||
CLOUDSTACK_CONFIG: "{{ algo_cs_config }}"
|
||||
CLOUDSTACK_REGION: "{{ algo_cs_region }}"
|
||||
|
|
|
@ -51,5 +51,4 @@
|
|||
[{{ default_zone }}]
|
||||
register: _algo_region
|
||||
when: region is undefined
|
||||
environment:
|
||||
PYTHONPATH: "{{ cloudstack_venv }}/lib/python2.7/site-packages/"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue