Installing a Current Version of Node Using Ansible
On of my client's servers requires nodejs for Gulp and the version in Ubuntu's repos are old (even Trusty uses version 0.10.25). I created a role in Ansible to install a more current version. I was able to get it down to just a task/main.yml file which is below. The tasks file should be easily changed to allow for other packages.
---
- name: Install Dependencies
apt: pkg= update_cache=yes cache_valid_time=86400 state=present
with_items:
- gcc
- make
- build-essential
- name: Download Source
get_url: url=https://nodejs.org/dist/v/node-v.tar.gz
dest=/usr/local/src/nodejs-.tar.gz
- name: Extract Source
shell: tar xf /usr/local/src/nodejs-.tar.gz -C /usr/local/src
creates=/usr/local/src/node-v
- name: Install
command: creates=/usr/local/bin/node
args:
chdir: /usr/local/src/node-v
with_items:
- ./configure
- make
- make install
When you include this in your project you'll need to add it as roles/nodejs/tasks/main.yml and then in your playbook you can add it like this:
- {role: nodejs, nodejs_version: 4.2.1}
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
RSS
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows