Created
November 25, 2012 16:02
-
-
Save arunthampi/4144165 to your computer and use it in GitHub Desktop.
install_node_via_nvm.yml
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: Clone NVM | |
action: git repo=git://github.com/creationix/nvm.git dest=/home/${user}/.nvm | |
- name: Download Node.JS 64-bit | |
action: get_url url=http://nodejs.org/dist/${version}/node-${version}-linux-x64.tar.gz dest=/home/${user}/.nvm/node-${version}-linux-x64.tar.gz | |
- name: Unpack Node | |
action: command tar -xzf node-${version}-linux-x64.tar.gz creates=/home/${user}/.nvm/${version} chdir=/home/${user}/.nvm | |
- name: Rename Node.JS directory to ${version} | |
action: command mv node-${version}-linux-x64 ${version} creates=/home/${user}/.nvm/${version} chdir=/home/${user}/.nvm | |
- name: Check if nvm.sh is present in bash_profile | |
action: shell grep nvm.sh /home/${user}/.bash_profile | |
register: nvm_in_bash_profile | |
ignore_errors: True | |
- name: add nvm.sh in bash_profile | |
action: shell echo "source ~/.nvm/nvm.sh" >> /home/${user}/.bash_profile && chown ${user}:${user} /home/${user}/.bash_profile | |
only_if: "len('${nvm_in_bash_profile.stdout}') == 0" | |
- name: apply nvm.sh and set default version | |
action: shell /bin/bash -c "source /home/${user}/.nvm/nvm.sh && nvm use ${version} && nvm alias default ${version}" | |
- name: set permissions for .nvm | |
action: shell chown $user:$user -R /home/${user}/.nvm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment