Commit a7e98bfb authored by Nikhil Doifode's avatar Nikhil Doifode
Browse files

Added checks to check the current version of Golang, NPM and Node

parent 90618df8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ helm_version: "3.3/stable"
go_version: "1.15.3"
golangci_lint_version: "v1.18.0"

# Node
# Node and NPM
node_version: "10.16.3"
npm_version: "6.14.8"
eslint_version: "5.16.0"
 No newline at end of file
+11 −1
Original line number Diff line number Diff line
@@ -7,6 +7,16 @@
      - ansible_distribution_version == '18.04'
    quiet: yes

- name: Install Go
- name: Check if golang is installed
  command: /bin/bash -c "source /home/{{ ansible_user }}/.profile; go version | awk '{print $3}' | cut -c 3-"
  register: go_check
  failed_when: "'command not found' in go_check.stdout"

- debug:
    msg: "[WARNING] Current golang version is lower than recommended version {{ go_version }}"
  when: go_check.stdout != '' and go_check.stdout is version_compare(go_version, '<')

- name: Install golang if go command not found
  include_tasks:
    file: install.yml
  when: go_check.stdout == ''
+20 −5
Original line number Diff line number Diff line
@@ -7,10 +7,25 @@
      - ansible_distribution_version == '18.04'
    quiet: yes

- name: Install Node
- name: Check if node is installed
  command: /bin/bash -c "source /home/{{ ansible_user }}/.nvm/nvm.sh; node -v | cut -c 2-"
  register: node_check
  failed_when: "'command not found' in node_check.stdout"

- debug:
    msg: "[WARNING] Current node version is lower than recommended version {{ node_version }}"
  when: node_check.stdout != '' and node_check.stdout is version_compare(node_version, '<')

- name: Check if npm is installed
  command: /bin/bash -c "source /home/{{ ansible_user }}/.nvm/nvm.sh; npm -v"
  register: npm_check
  failed_when: "'command not found' in npm_check.stdout"

- debug:
    msg: "[WARNING] Current npm version is lower than recommended version {{ npm_version }}"
  when: npm_check.stdout != '' and npm_check.stdout is version_compare(npm_version, '<')

- name: Install Node and NPM if node or npm command not found
  include_tasks:
    file: install.yml

# - name: Remove Node
#   include_tasks:
#     file: uninstall.yml
  when: node_check.stdout == '' or npm_check.stdout == ''