diff --git a/README.md b/README.md index 581311d..d67f0bd 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,14 @@ you can install it with: pip install jmespath ``` -A recent version of Jinja (2.8) is also required. You can install it with: +A recent version of Jinja (2.8) is also required. You can upgrade your Jinja version with: ``` -pip install jinja2 +pip install -U Jinja2 ``` -If your control node runs on RHEL7, you can run +If your control node runs on RHEL7, you can run [this playbook](https://github.com/nmasse-itix/OpenShift-Lab/blob/master/common/verify-local-requirements.yml) -to install the missing dependencies. +to install the missing dependencies. ## Example: Deploy an API on 3scale SaaS with hosted APIcast gateways diff --git a/tasks/check_requirements.yml b/tasks/check_requirements.yml new file mode 100644 index 0000000..9584460 --- /dev/null +++ b/tasks/check_requirements.yml @@ -0,0 +1,27 @@ +--- + +- name: Check if jmespath is installed locally + debug: msg={{dummy|json_query('@')}} + register: check_jmespath + ignore_errors: yes + vars: + dummy: Hello World + +- name: Check if jinja 2.8 is installed locally + debug: msg={{(dummy|selectattr("id", "equalto", "hello")|first)['value']}} + vars: + dummy: + - id: hello + value: Hello World + register: check_jinja28 + ignore_errors: yes + +- assert: + that: + - 'check_jmespath is success' + msg: "The JMESPath library is required by this role. Please install the JMESPath library with 'pip install jmespath'." + +- assert: + that: + - 'check_jinja28 is success' + msg: "At least Jinja v2.8 is required by this role. Please update Jinja with 'pip install -U Jinja2'." diff --git a/tasks/main.yml b/tasks/main.yml index 6578025..54cdf72 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,7 @@ --- +- import_tasks: check_requirements.yml + - name: Ensure pre-requisites are met assert: that: