From 56fc8f188f83ddef8b4656ae4d91dc4ebb8d9f0a Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 22 Oct 2023 01:01:19 +0200 Subject: [PATCH] Assert all environment variables are not empty. --- gen_bootstrap.yml | 25 ++++++++++++------------- tasks/assert_env_var_not_empty.yml | 6 ++++++ 2 files changed, 18 insertions(+), 13 deletions(-) create mode 100755 tasks/assert_env_var_not_empty.yml diff --git a/gen_bootstrap.yml b/gen_bootstrap.yml index b62900c..4c402d5 100755 --- a/gen_bootstrap.yml +++ b/gen_bootstrap.yml @@ -12,20 +12,19 @@ with_items: - KEY - DOC_KEY + + - name: Assert environment variable is not empty + ansible.builtin.include_tasks: "tasks/assert_env_var_not_empty.yml" + with_items: + - OS_AUTH_URL + - OS_IDENTITY_API_VERSION + - OS_TENANT_NAME + - OS_USERNAME + - OS_PASSWORD + - OS_REGION_NAME + - SECRETS_ARCHIVE_PASSPHRASE - DUPLICITY_PASSPHRASE - - - name: Assert SECRETS_ARCHIVE_PASSPHRASE environment variable is set - ansible.builtin.assert: - that: - - lookup('env','SECRETS_ARCHIVE_PASSPHRASE') | length > 0 - msg: "SECRETS_ARCHIVE_PASSPHRASE environment variable must be set" - - - name: Assert OS_AUTH_URL environment variable is set - ansible.builtin.assert: - that: - - lookup('env','OS_AUTH_URL') | length > 0 - msg: "OS_AUTH_URL environment variable must be set" - + - name: Download secrets.tar.gz.enc ansible.builtin.get_url: url: "https://{{ CLOUD_SERVER }}/s/{{ KEY }}/download?path=%2F&files=secrets.tar.gz.enc" diff --git a/tasks/assert_env_var_not_empty.yml b/tasks/assert_env_var_not_empty.yml new file mode 100755 index 0000000..1b73ef4 --- /dev/null +++ b/tasks/assert_env_var_not_empty.yml @@ -0,0 +1,6 @@ +--- +- name: Assert {{ item }} environment variable is set + ansible.builtin.assert: + that: + - lookup('env','{{ item }}') | length > 0 + msg: "{{ item }} environment variable must be set"