Browse Source

check requirements before playbook is run

pull/25/head
Nicolas Massé 8 years ago
parent
commit
fb6ffbf4f4
  1. 8
      README.md
  2. 27
      tasks/check_requirements.yml
  3. 2
      tasks/main.yml

8
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

27
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'."

2
tasks/main.yml

@ -1,5 +1,7 @@
---
- import_tasks: check_requirements.yml
- name: Ensure pre-requisites are met
assert:
that:

Loading…
Cancel
Save