Giter Club home page Giter Club logo

ansible-nvm's Introduction

nvm

Downloads Continuous Integration Status

Install nvm and Node.js.

Requirements

git, curl, build-essential, libssl-dev. Requirements are installed by the role.

Role Variables

  • nvm_version nvm version tag, or HEAD | master | latest. Defaults to 0.39.7
  • nvm_node_version Node.js specific version 12.16.0 or use lts | latest. Defaults to 20.14.0
  • nvm_install_path nvm folder path, support absolute and relative path. Defaults to ~/.nvm
  • nvm_shell_init_file The Shell initialization file to add sourcing of NVM to. Defaults to ~/.profile
  • nvm_force_install Boolean. Force reinstall nvm from git, for example if you change some files in nvm_install_path. Defaults to false
  • nvm_install_deps Boolean. Allow to skip dependencies setup and therefore run as a non-root user. Defaults to true

Dependencies

No dependencies.

Example Playbook

- hosts: servers
  roles:
    - role: stephdewit.nvm
      nvm_version: 0.4.0
      nvm_node_version: 0.10

Install latest version always

- hosts: servers
  roles:
    - role: stephdewit.nvm
      nvm_version: 'latest'
      nvm_node_version: 'latest'

When run with another user than the logged one, it may help to set NVM_DIR environment variable to an absolute path:

- hosts: servers
  roles:
    - role: stephdewit.nvm
      become: yes
      become_user: vagrant
      environment:
        NVM_DIR: /home/vagrant/.nvm

License

BSD

Author Information

ansible-nvm's People

Contributors

danmichaelo avatar hypery2k avatar jdrouet avatar jeremyj563 avatar rikukissa avatar stephdewit avatar ukch avatar weslyg avatar wtower avatar xiaoyao9184 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-nvm's Issues

Have to set NVM_DIR

I have to add:

  environment:
    NVM_DIR: '{{ nvm_install_path }}'

to the last three tasks to make them work. Otherwise NVM_DIR is set to /bin and the tasks fail due to permission errors.

Ubuntu 18.04
Ansible 2.8.0

sudo

Hi @stephdewit this query is sort of related to #4

Would it be possible to update the role so that the setup-.yml can be bypassed? This is the only place that the role contains the becomes stanza.

I'm using the role with users that don't have sudo access.

Prior to their use on the host, I can provide the dependencies that are required by this role.

Ideally having a variable nvm_install_deps or nvm_bypass_setup etc. would be great.

- include: setup-redhat.yml
  when: ansible_os_family == "RedHat" and nvm_install_deps == true
  tags: nvm

Thanks for your time.
Damian.

Install as non-root user

Installing in a vagrant environment. Playbook as follows:

   - role: stephdewit.nvm
      become: yes
      become_user: vagrant
      nvm_shell_init_file: ~/.bashrc

Error log:

TASK [nvm : Install Node.js 12.13.0] *****************************************************************
fatal: [192.168.33.22]: FAILED! => {"changed": true, "cmd": ". ~/.bashrc && nvm install 12.13.0", "delta": "0:00:00.001649", "end": "2019-12-30 18:32:02.526579", "msg": "non-zero return code", "rc": 127, "start": "2019-12-30 18:32:02.524930", "stderr": "/bin/sh: 1: nvm: not found", "stderr_lines": ["/bin/sh: 1: nvm: not found"], "stdout": "", "stdout_lines": []}

nvm is installed for the vagrant user, but installing node fails. Installing node as vagrant user via the command line works as expected.

$ nvm install 12.13.0
Downloading and installing node v12.13.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v12.13.0-linux-x64/node-v12.13.0-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v12.13.0-linux-x64/node-v12.13.0-linux-x64.tar.xz
Now using node v12.13.0 (npm v6.12.0)

~/.profile not found

grafik

simply touching that file before running the ansible-role helped.
so perhaps you should ensure the existence of that file before.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.