我正在寻找合适的 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/