mirror of
https://github.com/trailofbits/algo.git
synced 2025-08-13 16:23:00 +02:00
initial version of the cloudstack role
This commit is contained in:
parent
dbd177862f
commit
53260c9a82
6 changed files with 80 additions and 0 deletions
|
@ -33,6 +33,8 @@
|
||||||
when: algo_provider == "scaleway"
|
when: algo_provider == "scaleway"
|
||||||
- role: cloud-openstack
|
- role: cloud-openstack
|
||||||
when: algo_provider == "openstack"
|
when: algo_provider == "openstack"
|
||||||
|
- role: cloud-cloudstack
|
||||||
|
when: algo_provider == "cloudstack"
|
||||||
- role: local
|
- role: local
|
||||||
when: algo_provider == "local"
|
when: algo_provider == "local"
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,10 @@ cloud_providers:
|
||||||
openstack:
|
openstack:
|
||||||
flavor_ram: ">=512"
|
flavor_ram: ">=512"
|
||||||
image: Ubuntu-18.04
|
image: Ubuntu-18.04
|
||||||
|
cloudstack:
|
||||||
|
size: Tiny
|
||||||
|
image: Linux Ubuntu 18.04 LTS 64-bit
|
||||||
|
disk: 10
|
||||||
vultr:
|
vultr:
|
||||||
os: Ubuntu 18.04 x64
|
os: Ubuntu 18.04 x64
|
||||||
size: 1024 MB RAM,25 GB SSD,1.00 TB BW
|
size: 1024 MB RAM,25 GB SSD,1.00 TB BW
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
- { name: Google Compute Engine, alias: gce }
|
- { name: Google Compute Engine, alias: gce }
|
||||||
- { name: Scaleway, alias: scaleway}
|
- { name: Scaleway, alias: scaleway}
|
||||||
- { name: OpenStack (DreamCompute optimised), alias: openstack }
|
- { name: OpenStack (DreamCompute optimised), alias: openstack }
|
||||||
|
- { name: CloudStack, alias: cloudstask }
|
||||||
- { name: Install to existing Ubuntu 18.04 server (Advanced), alias: local }
|
- { name: Install to existing Ubuntu 18.04 server (Advanced), alias: local }
|
||||||
vars_files:
|
vars_files:
|
||||||
- config.cfg
|
- config.cfg
|
||||||
|
|
2
roles/cloud-cloudstack/defaults/main.yml
Normal file
2
roles/cloud-cloudstack/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
cloudstack_venv: "{{ playbook_dir }}/configs/.venvs/cloudstack"
|
58
roles/cloud-cloudstack/tasks/main.yml
Normal file
58
roles/cloud-cloudstack/tasks/main.yml
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
---
|
||||||
|
- block:
|
||||||
|
- name: Build python virtual environment
|
||||||
|
import_tasks: venv.yml
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Security group created
|
||||||
|
cs_securitygroup:
|
||||||
|
name: "{{ algo_server_name }}-security_group"
|
||||||
|
description: AlgoVPN security group
|
||||||
|
register: cs_security_group
|
||||||
|
|
||||||
|
- name: Security rules created
|
||||||
|
cs_security_group_rule:
|
||||||
|
security_group: "{{ cs_security_group.name }}"
|
||||||
|
protocol: "{{ item.proto }}"
|
||||||
|
start_port: "{{ item.port_min }}"
|
||||||
|
end_port: "{{ item.port_max }}"
|
||||||
|
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
|
||||||
|
cs_sshkeypair:
|
||||||
|
name: "{{ SSH_keys.comment|regex_replace('@', '_') }}"
|
||||||
|
public_key: "{{ SSH_keys.public }}"
|
||||||
|
register: cs_keypair
|
||||||
|
|
||||||
|
- 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 }}"
|
||||||
|
image: "{{ image_id }}"
|
||||||
|
ssh_key: "{{ keypair_name }}"
|
||||||
|
security_groups: "{{ cs_security_group.name }}"
|
||||||
|
register: cs_server
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
cloud_instance_ip: "{{ cs_server.default_ip }}"
|
||||||
|
ansible_ssh_user: ubuntu
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: "{{ cloudstack_venv }}/lib/python2.7/site-packages/"
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- debug: var=fail_hint
|
||||||
|
tags: always
|
||||||
|
- fail:
|
||||||
|
tags: always
|
13
roles/cloud-cloudstack/tasks/venv.yml
Normal file
13
roles/cloud-cloudstack/tasks/venv.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
- name: Clean up the environment
|
||||||
|
file:
|
||||||
|
dest: "{{ cloudstack_venv }}"
|
||||||
|
state: absent
|
||||||
|
when: clean_environment
|
||||||
|
|
||||||
|
- name: Install requirements
|
||||||
|
pip:
|
||||||
|
name: sc
|
||||||
|
version: 2.5.8
|
||||||
|
virtualenv: "{{ cloudstack_venv }}"
|
||||||
|
virtualenv_python: python2.7
|
Loading…
Add table
Reference in a new issue