Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
- name: Install prerequisites
ansible.builtin.package:
name: xz
state: present
become: true
when: ansible_os_family == 'RedHat'
- name: Create directory
ansible.builtin.file:
state: directory
owner: root
group: root
mode: 'u=rwx,go=rx'
path: "{{ nodejs_install_path }}"
become: true
- name: Download Node.js artifact
ansible.builtin.get_url:
url: "{{ nodejs_download_url }}"
checksum: "{{ nodejs_checksum }}"
mode: 'u=rwx,go=rx'
dest: /tmp
register: downloaded_file
changed_when: false
- name: Extract artifact
ansible.builtin.unarchive:
src: "{{ downloaded_file.dest }}"
dest: "{{ nodejs_install_path }}"
owner: "root"
group: "root"
mode: "u=rwx,go=rx"
remote_src: yes
extra_opts: ["--strip-components=1", "-J"]
become: true
- name: Create node symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/node"
dest: /usr/local/bin/node
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Create npm symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/npm"
dest: /usr/local/bin/npm
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Create npx symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/npx"
dest: /usr/local/bin/npx
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Create corepack symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/corepack"
dest: /usr/local/bin/corepack
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true
- name: Clean up temporary files
ansible.builtin.file:
path: "{{ downloaded_file.dest }}"
state: absent
changed_when: false
- name: Install yarn
community.general.npm:
name: yarn
global: true
executable: /usr/local/bin/npm
environment:
PATH: /usr/local/bin:{{ ansible_env.PATH }}
become: true
- name: Create yarn symlink
ansible.builtin.file:
src: "{{ nodejs_install_path }}/bin/yarn"
dest: /usr/local/bin/yarn
owner: "root"
group: "root"
mode: 'u=rwx,go=rx'
state: link
become: true