Merge "Add possibility to use private key for accessing gerrit"
diff --git a/tcp_tests/helpers/utils.py b/tcp_tests/helpers/utils.py
index f2311d4..480a646 100644
--- a/tcp_tests/helpers/utils.py
+++ b/tcp_tests/helpers/utils.py
@@ -356,6 +356,12 @@
return var
+ def basename(path):
+ return os.path.basename(path)
+
+ def dirname(path):
+ return os.path.dirname(path)
+
if options is None:
options = {}
options.update({'os_env': os_env, })
@@ -366,6 +372,9 @@
environment = jinja2.Environment(
loader=jinja2.FileSystemLoader([path, os.path.dirname(path)],
followlinks=True))
+ environment.filters['basename'] = basename
+ environment.filters['dirname'] = dirname
+
template = environment.get_template(filename).render(options)
if required_env_vars and log_env_vars:
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 80acaaf..ab5feb5 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -9,7 +9,9 @@
{% set SALT_MODELS_SYSTEM_COMMIT = os_env('SALT_MODELS_SYSTEM_COMMIT','') %}
{% set SALT_MODELS_SYSTEM_REF_CHANGE = os_env('SALT_MODELS_SYSTEM_REF_CHANGE','') %}
{% set SALT_MODELS_SYSTEM_TAG = os_env('SALT_MODELS_SYSTEM_TAG','') %}
-{% set COOKIECUTTER_TEMPLATES_REPOSITORY = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY','https://gerrit.mcp.mirantis.com/mk/cookiecutter-templates') %}
+{% set COOKIECUTTER_TEMPLATES_REPOSITORY_USER = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY_USER','mcp-gerrit') %}
+{% set COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH','') %}
+{% set COOKIECUTTER_TEMPLATES_REPOSITORY = os_env('COOKIECUTTER_TEMPLATES_REPOSITORY','ssh://' + COOKIECUTTER_TEMPLATES_REPOSITORY_USER +'@gerrit.mcp.mirantis.com:29418/mk/cookiecutter-templates') %}
{% set COOKIECUTTER_REF_CHANGE = os_env('COOKIECUTTER_REF_CHANGE','') %}
{% set COOKIECUTTER_TAG = os_env('COOKIECUTTER_TAG','') %}
{% set COOKIECUTTER_TEMPLATE_COMMIT = os_env('COOKIECUTTER_TEMPLATE_COMMIT','') %}
@@ -365,12 +367,23 @@
retry: {count: 1, delay: 1}
skip_fail: false
+- description: "Upload {{ COOKIECUTTER_TEMPLATES_REPOSITORY_USER }} key"
+ upload:
+ local_path: {{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | dirname }}/
+ local_filename: {{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | basename }}
+ remote_path: /tmp/
+ node_name: {{ HOSTNAME_CFG01 }}
+
- description: Create cluster model from cookiecutter templates
cmd: |
set -e;
set -x;
sudo apt-get install python-setuptools -y
pip install cookiecutter
+
+ chmod 0600 /tmp/{{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | basename }}
+ eval $(ssh-agent)
+ ssh-add /tmp/{{ COOKIECUTTER_TEMPLATES_REPOSITORY_KEY_PATH | basename }}
export GIT_SSL_NO_VERIFY=true; git clone {{ COOKIECUTTER_TEMPLATES_REPOSITORY }} /root/cookiecutter-templates
{%- if COOKIECUTTER_REF_CHANGE != '' %}