2022-08-05 14:03:38 +02:00
|
|
|
---
|
|
|
|
# Copyright (c) Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: 'Remove any node modules'
|
|
|
|
file:
|
|
|
|
path: '{{ remote_dir }}/node_modules'
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- vars:
|
|
|
|
# sample: node-v8.2.0-linux-x64.tar.xz
|
2021-07-25 13:53:38 +02:00
|
|
|
node_path: '{{ remote_dir }}/{{ nodejs_path }}/bin'
|
2020-03-09 10:11:07 +01:00
|
|
|
package: 'iconv-lite'
|
|
|
|
block:
|
|
|
|
- shell: npm --version
|
|
|
|
environment:
|
|
|
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
|
|
|
register: npm_version
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: npm_version.stdout
|
|
|
|
|
|
|
|
- name: 'Install simple package without dependency'
|
|
|
|
npm:
|
|
|
|
path: '{{ remote_dir }}'
|
2021-07-25 13:53:38 +02:00
|
|
|
executable: '{{ node_path }}/npm'
|
2020-03-09 10:11:07 +01:00
|
|
|
state: present
|
|
|
|
name: '{{ package }}'
|
|
|
|
environment:
|
2021-07-25 13:53:38 +02:00
|
|
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
2020-03-09 10:11:07 +01:00
|
|
|
register: npm_install
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- npm_install is success
|
|
|
|
- npm_install is changed
|
|
|
|
|
|
|
|
- name: 'Reinstall simple package without dependency'
|
|
|
|
npm:
|
|
|
|
path: '{{ remote_dir }}'
|
|
|
|
executable: '{{ node_path }}/npm'
|
|
|
|
state: present
|
|
|
|
name: '{{ package }}'
|
|
|
|
environment:
|
2021-07-25 13:53:38 +02:00
|
|
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
2020-03-09 10:11:07 +01:00
|
|
|
register: npm_reinstall
|
|
|
|
|
|
|
|
- name: Check there is no change
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- npm_reinstall is success
|
|
|
|
- not (npm_reinstall is changed)
|
|
|
|
|
|
|
|
- name: 'Manually delete package'
|
|
|
|
file:
|
|
|
|
path: '{{ remote_dir }}/node_modules/{{ package }}'
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: 'reinstall simple package'
|
|
|
|
npm:
|
|
|
|
path: '{{ remote_dir }}'
|
|
|
|
executable: '{{ node_path }}/npm'
|
|
|
|
state: present
|
|
|
|
name: '{{ package }}'
|
|
|
|
environment:
|
2021-07-25 13:53:38 +02:00
|
|
|
PATH: '{{ node_path }}:{{ ansible_env.PATH }}'
|
2020-03-09 10:11:07 +01:00
|
|
|
register: npm_fix_install
|
|
|
|
|
|
|
|
- name: Check result is changed and successful
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- npm_fix_install is success
|
|
|
|
- npm_fix_install is changed
|