GithubHelp home page GithubHelp logo

marverix / ansible-role-nodejs Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 9 KB

Ansible role that installs Node.js and configures npm

Home Page: https://galaxy.ansible.com/marverix/nodejs

License: ISC License

HTML 100.00%
ansible ansible-role ansible-galaxy-role nodejs npm npm-config

ansible-role-nodejs's Introduction

Ansible Role: Node.js

Build Status Ansible Quality Score Ansible Role License: ISC

Ansible role that installs on linux Node.js, npm and optionally does basic npm configuration.

Features

  • ✔️ Installing Node.js
    • You can define which version should be installed
    • Double-check that the newest version of npm is installed
  • ✔️ npm configuration
    • Set global registry for an user
    • Set prefix for an user
    • Set default scope for an user
    • Configure scopes for an user
  • ✔️ Installing global npm packages that you wish
  • ✔️ Making sure that nodejs alias is available
  • ✔️ Tested with Molecule Verify

Supported Platforms

  • ✔️ Ubuntu 16.04 (Xenial)
  • ✔️ Ubuntu 18.04 (Bionic)
  • ✔️ Ubuntu 20.04 (Focal)
  • ✔️ CentOS 7
  • ✔️ CentOS 8

Requirements

None

Role Variables

Variable Description Default Value
nodejs_version Version of Node.js to be installed 14
nodejs_npm_install_globally List of npm packages that should be installed globally []
nodejs_npm_config List on npm configurations - See in section How to configure npm []

How to configure npm

nodejs_npm_config must be an array of objects. Here is how each object should look like:

Property Description Required
user User (one npm config per user) Yes
prefix npm prefix No
registry npm registry URL No
scopes List of scopes. Each scope must have name (without @) and registry. Look at playbook examples below. No
default_scope Default scope No

Dependencies

None

Example Playbook

  1. The simplest one

    ---
    - hosts: all
      roles:
        - marverix.nodejs
    
  2. Install globally mocha and eslint

    ---
    - hosts: all
      roles:
        - role: marverix.nodejs
          vars:
            nodejs_npm_install_globally:
              - mocha
              - eslint
  3. Set npm registry for user root, set prefix, configure scopes and set default scope:

    ---
    - hosts: all
      roles:
        - role: marverix.nodejs
          vars:
            nodejs_npm_config:
              - user: root
                prefix: /home/root/.node
                registry: https://nexus.example.org/repository/npm/
                scopes:
                  - name: example-int
                    registry: https://nexus.example.org/repository/npm-int/
                  - name: example2-int
                    registry: https://nexus.example2.org/repository/npm-int/
                default_scope: example-int

    BTW: Here is good blog post how to setup Nexus as your npm registry: https://blog.sonatype.com/using-nexus-3-as-your-repository-part-2-npm-packages

License

ISC

ansible-role-nodejs's People

Contributors

marverix avatar

Watchers

 avatar  avatar

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.