본문 바로가기

Automation Tools/Ansible

8.4 ansible | [playbook] nodejs, npm 설치

반응형

## nodejs 14.15.4, npm 6.14.10
---
- name: "NPM, NODEJS INSTALL"
  become: true
  hosts : all
  gather_facts: no
  tasks:
    - name: "install wget"
      yum:
        name: wget
        state: installed
    - name: "repo download"
      get_url:
        url: https://rpm.nodesource.com/setup_lts.x
        dest: /tmp/node_setup.sh
    - name: "repo install"
      shell: /bin/bash /tmp/node_setup.sh
    - name: "install nodejs"
      yum:
        name: "{{ item }}"
        state: installed
      loop:
        - nodejs-14.15.4
    - name: "result"
      command: "{{ item }}"
      register: abc
      with_items:
        - npm --version
        - node --version
    - debug:
        msg:
          - "npm version : {{ abc.results[0].stdout }}"
          - "nodejs version : {{ abc.results[1].stdout }}"
#        var: abc | json_query('results[0].stdout')
반응형