node.js - 为 Ansible 安装 NodeJS LTS

标签 node.js ansible ansible-role

我正在寻找合适的 Ansible Role 或 Ansible YAML 文件,以便在 Ubuntu 16.04.3 xenial 系统上安装 NodeJS LTS。我尝试了 Galaxy 中的 10 多个 Ansible 角色,但没有发现它们中的任何一个在工作(抛出错误,例如 potentially dangerous to add this PPA etc.

任何人都可以提供任何 Ansible 剧本或建议我在 Ubuntu 16.04 上安装 NodeJS LTS 的角色吗?

最佳答案

这是工作示例:

---
- hosts: all
  gather_facts: yes
  become: yes
  vars:
    NODEJS_VERSION: "8"
  tasks:
    - name: Install the gpg key for nodejs LTS
      apt_key:
        url: "https://deb.nodesource.com/gpgkey/nodesource.gpg.key"
        state: present
    
    - name: Install the nodejs LTS repos
      apt_repository:
        repo: "deb https://deb.nodesource.com/node_{{ NODEJS_VERSION }}.x {{ ansible_distribution_release }} main"
        state: present
        update_cache: yes

    - name: Install the nodejs
      apt:
        name: nodejs
        state: present

希望对你有帮助

关于node.js - 为 Ansible 安装 NodeJS LTS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45840664/

相关文章:

node.js - Mongoose:无法转换 ISO 日期

node.js - 在处理请求之前确定请求大小

nginx - 在 http {} 内的 nginx 配置文件 ansible 中插入行

Ansible:在角色执行时应用标签

node.js - 找不到模块 Bootstrap

javascript - 根据对象数组中的数据计算平均值并存储在对象的特定键中

python - parse_cli_textfsm 过滤器需要安装 TextFSM 库

windows - 如何使用ansible扩展windows路径变量

vagrant - 是否可以忽略 Ansible 中缺失的角色?