- name: Ensure we know what version of node to install | |
assert: | |
that: node_version is defined | |
- name: Check installed Node version | |
command: node --version | |
register: node_installed_version | |
failed_when: false | |
- name: Install NodeJS when it is not installed with the required version | |
include_tasks: install-nodejs.yaml | |
when: | |
- node_installed_version.rc != 0 or | |
(node_version | string | trim) != | |
(node_installed_version.stdout | |
| regex_replace('^v(?P<majorVersion>[^.]+).*$', '\\g<majorVersion>') | |
| trim) |