From 1519bf11fe1bbd47eae91023228274190418e1bc Mon Sep 17 00:00:00 2001 From: milkmix Date: Tue, 19 Mar 2019 08:46:28 +0100 Subject: [PATCH] added prompt to ask for cloudastack.ini file location if none specified in env --- roles/cloud-cloudstack/tasks/main.yml | 2 ++ roles/cloud-cloudstack/tasks/prompts.yml | 27 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/roles/cloud-cloudstack/tasks/main.yml b/roles/cloud-cloudstack/tasks/main.yml index b40d75e8..daec763d 100644 --- a/roles/cloud-cloudstack/tasks/main.yml +++ b/roles/cloud-cloudstack/tasks/main.yml @@ -61,6 +61,8 @@ ansible_ssh_user: ubuntu environment: PYTHONPATH: "{{ cloudstack_venv }}/lib/python2.7/site-packages/" + CLOUDSTACK_CONFIG: "{{ _cs_config }}" + CLOUDSTACK_REGION: "{{ _cs_region.user_input }}" rescue: - debug: var=fail_hint diff --git a/roles/cloud-cloudstack/tasks/prompts.yml b/roles/cloud-cloudstack/tasks/prompts.yml index db2303bf..54f566f8 100644 --- a/roles/cloud-cloudstack/tasks/prompts.yml +++ b/roles/cloud-cloudstack/tasks/prompts.yml @@ -1,5 +1,28 @@ --- - block: + - set_fact: + _cs_config: "{{ lookup('env', 'CLOUDSTACK_CONFIG') }}" + + - pause: + prompt: | + Enter path for cloudstack.ini file + [~/.cloudstack.ini] + register: _cs_config_input + when: _cs_config == "" + + - set_fact: + _cs_config_input: "{% if _cs_config_input.user_input == ''%}{{ '~/.cloudstack.ini' }}{% else %}{{ _cs_config_input.user_input }}{% endif %}" + when: _cs_config == "" + + - set_fact: + _cs_config: "{% if _cs_config == '' %}{{ _cs_config_input }}{% else %}{{ _cs_config }}{% endif %}" + + - pause: + prompt: | + Specify region to use in cloudstack.ini_file + [default] + register: _cs_region + - name: Parse zones from output set_fact: _cs_zones: "{{ _cloudstack_zones | from_json }}" @@ -19,8 +42,8 @@ prompt: | What zone should the server be located in? {% for z in cs_zones %} - {{ loop.index }}. {{ z['name'] }} - {% endfor %} + {{ loop.index }}. {{ z['name'] }} + {% endfor %} Enter the number of your desired zone [{{ default_zone }}]