Created
January 14, 2018 00:48
-
-
Save cmndrsp0ck/0f396fd16859fc15d198e9ef373e709d to your computer and use it in GitHub Desktop.
install a specific version of nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: nodejs install block | |
block: | |
- name: Check for nodejs | |
stat: | |
path: "{{ node_path }}/node" | |
register: node_check | |
- name: Install nodejs | |
unarchive: | |
src: "https://nodejs.org/dist/v{{ node_version }}/node-v{{ node_version }}-linux-x64.tar.xz" | |
dest: "{{ node_install_location }}" | |
remote_src: yes | |
owner: root | |
group: root | |
when: node_check.stat.exists == false | |
- name: Install NPM modules (global) | |
npm: | |
name: "{{ item }}" | |
global: yes | |
state: present | |
with_items: | |
- knex-migrator | |
- ghost-cli | |
- name: Adding node_path to PATH | |
template: | |
src: nodejs.sh.j2 | |
dest: /etc/profile.d/nodejs.sh | |
owner: root | |
group: root | |
mode: 0644 | |
- name: Adjusting secure_path in sudoers | |
lineinfile: | |
path: /etc/sudoers | |
owner: root | |
group: root | |
mode: 0440 | |
state: present | |
regexp: 'secure_path' | |
line: 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:{{ node_path }}"' | |
when: inventory_dir | basename in ['dev', 'packer'] | |
environment: | |
PATH: "{{ ansible_env.PATH }}:{{ node_path }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PATH=${PATH}:{{ node_path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
node_version: "8.9.4" | |
node_install_location: /usr/local | |
node_path: "{{ node_install_location }}/node-v{{ node_version }}-linux-x64/bin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment