Ansible 用の NodeJS LTS のインストール 質問する

Ansible 用の NodeJS LTS のインストール 質問する

Ubuntu 16.04.3 xenial システムに NodeJS LTS をインストールするための適切な Ansible Role または Ansible YAML ファイルを探しています。Galaxy から 10 を超える Ansible Role を試しましたが、どれも機能しませんでした (次のようなエラーがスローされます) potentially dangerous to add this PPA etc.

Ubuntu 16.04 に NodeJS LTS をインストールするための Ansible プレイブックを提供したり、ロールを提案したりしてくれる人はいますか?

ベストアンサー1

実際の例は以下になります:

---
- 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

お役に立てれば幸いです

おすすめ記事