zuul-jobs/roles/install-nodejs/tasks/main.yaml

30 lines
843 B
YAML

- name: Check for the presence of node
command: command -v node
register: install_nodejs_node_installed
ignore_errors: true
- name: Check for the presence of npm
command: command -v npm
register: install_nodejs_npm_installed
ignore_errors: true
- name: Install nodejs according to distro
include_tasks: "{{ lookup('first_found', params) }}"
vars:
params:
files:
- "install_{{ ansible_distribution }}.{{ ansible_distribution_major_version }}.yaml"
- "install_{{ ansible_distribution }}.yaml"
- "install_{{ ansible_os_family }}.yaml"
- "install_default.yaml"
paths:
- distros
when:
install_nodejs_node_installed.rc == 1 or install_nodejs_npm_installed == 1
- name: Output node version
command: node --version
- name: Output npm version
command: npm --version