mirror of
https://github.com/trailofbits/algo.git
synced 2025-08-13 08:13:01 +02:00
added automatic prompt of available zones on the configured provider
This commit is contained in:
parent
e1e355487e
commit
213bd1a11e
3 changed files with 32 additions and 2 deletions
|
@ -1 +1,2 @@
|
||||||
ansible==2.5.2
|
ansible==2.5.2
|
||||||
|
jmespath==0.9.4
|
|
@ -6,6 +6,12 @@
|
||||||
- block:
|
- block:
|
||||||
- name: Include prompts
|
- name: Include prompts
|
||||||
import_tasks: prompts.yml
|
import_tasks: prompts.yml
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
algo_region: >-
|
||||||
|
{% if region is defined %}{{ region }}
|
||||||
|
{%- elif _algo_region.user_input is defined and _algo_region.user_input != "" %}{{ cs_zones[_algo_region.user_input | int -1 ] }}
|
||||||
|
{%- else %}{{ cs_zones[default_region | int - 1] }}{% endif %}
|
||||||
|
|
||||||
- name: Security group created
|
- name: Security group created
|
||||||
local_action:
|
local_action:
|
||||||
|
@ -50,7 +56,7 @@
|
||||||
template: "{{ image_id }}"
|
template: "{{ image_id }}"
|
||||||
ssh_key: "{{ keypair_name }}"
|
ssh_key: "{{ keypair_name }}"
|
||||||
security_groups: "{{ cs_security_group.name }}"
|
security_groups: "{{ cs_security_group.name }}"
|
||||||
zone: "{{ _algo_region.user_input }}"
|
zone: "{{ algo_region }}"
|
||||||
register: cs_server
|
register: cs_server
|
||||||
|
|
||||||
- set_fact:
|
- set_fact:
|
||||||
|
|
|
@ -1,7 +1,30 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
|
- name: List zones on configured cloud provider
|
||||||
|
local_action: shell "{{ cloudstack_venv }}/bin/cs" listZones
|
||||||
|
register: cs_zones_list
|
||||||
|
|
||||||
|
- name: Parse zones from output
|
||||||
|
set_fact:
|
||||||
|
cs_zones: "{{cs_zones_list.stdout | from_json | json_query('zone[*].name')}}"
|
||||||
|
|
||||||
|
- name: Set the default zone
|
||||||
|
set_fact:
|
||||||
|
default_zone: >-
|
||||||
|
{% for z in cs_zones %}
|
||||||
|
{%- if z == "ch-gva-2" %}{{ loop.index }}{% endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
- pause:
|
- pause:
|
||||||
prompt: |
|
prompt: |
|
||||||
What region should the server be located in?
|
What zone should the server be located in?
|
||||||
|
{% for z in cs_zones %}
|
||||||
|
{{ loop.index }}. {{ z }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
Enter the number of your desired 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