mirror of
https://github.com/trailofbits/algo.git
synced 2025-06-05 06:33:56 +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:
|
- block:
|
||||||
- name: Build python virtual environment
|
- set_fact:
|
||||||
import_tasks: venv.yml
|
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
|
- name: Security group created
|
||||||
import_tasks: prompts.yml
|
cs_securitygroup:
|
||||||
|
name: "{{ algo_server_name }}-security_group"
|
||||||
|
description: AlgoVPN security group
|
||||||
|
register: cs_security_group
|
||||||
|
|
||||||
- block:
|
- name: Security rules created
|
||||||
- set_fact:
|
cs_securitygroup_rule:
|
||||||
algo_region: >-
|
security_group: "{{ cs_security_group.name }}"
|
||||||
{% if region is defined %}{{ region }}
|
protocol: "{{ item.proto }}"
|
||||||
{%- elif _algo_region.user_input is defined and _algo_region.user_input | length > 0 %}{{ cs_zones[_algo_region.user_input | int -1 ]['name'] }}
|
start_port: "{{ item.start_port }}"
|
||||||
{%- else %}{{ cs_zones[default_zone | int - 1]['name'] }}{% endif %}
|
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
|
- name: Keypair created
|
||||||
cs_securitygroup:
|
cs_sshkeypair:
|
||||||
name: "{{ algo_server_name }}-security_group"
|
name: "{{ SSH_keys.comment|regex_replace('@', '_') }}"
|
||||||
description: AlgoVPN security group
|
public_key: "{{ lookup('file', '{{ SSH_keys.public }}') }}"
|
||||||
register: cs_security_group
|
register: cs_keypair
|
||||||
|
|
||||||
- name: Security rules created
|
- name: Set facts
|
||||||
cs_securitygroup_rule:
|
set_fact:
|
||||||
security_group: "{{ cs_security_group.name }}"
|
image_id: "{{ cloud_providers.cloudstack.image }}"
|
||||||
protocol: "{{ item.proto }}"
|
size: "{{ cloud_providers.cloudstack.size }}"
|
||||||
start_port: "{{ item.start_port }}"
|
disk: "{{ cloud_providers.cloudstack.disk }}"
|
||||||
end_port: "{{ item.end_port }}"
|
keypair_name: "{{ cs_keypair.name }}"
|
||||||
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: Keypair created
|
- name: Server created
|
||||||
cs_sshkeypair:
|
cs_instance:
|
||||||
name: "{{ SSH_keys.comment|regex_replace('@', '_') }}"
|
name: "{{ algo_server_name }}"
|
||||||
public_key: "{{ lookup('file', '{{ SSH_keys.public }}') }}"
|
root_disk_size: "{{ disk }}"
|
||||||
register: cs_keypair
|
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:
|
||||||
set_fact:
|
cloud_instance_ip: "{{ cs_server.default_ip }}"
|
||||||
image_id: "{{ cloud_providers.cloudstack.image }}"
|
ansible_ssh_user: ubuntu
|
||||||
size: "{{ cloud_providers.cloudstack.size }}"
|
environment:
|
||||||
disk: "{{ cloud_providers.cloudstack.disk }}"
|
CLOUDSTACK_CONFIG: "{{ algo_cs_config }}"
|
||||||
keypair_name: "{{ cs_keypair.name }}"
|
CLOUDSTACK_REGION: "{{ algo_cs_region }}"
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
|
@ -51,5 +51,4 @@
|
||||||
[{{ default_zone }}]
|
[{{ default_zone }}]
|
||||||
register: _algo_region
|
register: _algo_region
|
||||||
when: region is undefined
|
when: region is undefined
|
||||||
environment:
|
|
||||||
PYTHONPATH: "{{ cloudstack_venv }}/lib/python2.7/site-packages/"
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue