Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Wazuh API (NodeJS) installation tasks #330

Merged
merged 11 commits into from
Nov 29, 2019
5 changes: 5 additions & 0 deletions roles/wazuh/ansible-wazuh-manager/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,8 @@ wazuh_agent_configs:
format: 'eventchannel'
- location: 'System'
format: 'eventlog'
nodejs:
repo_dic:
debian: "deb"
redhat: "rpm"
repo_url_ext: "nodesource.com/setup_8.x"
26 changes: 0 additions & 26 deletions roles/wazuh/ansible-wazuh-manager/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@
update_cache: true
changed_when: false

- name: Debian/Ubuntu | Installing NodeJS repository key (Ubuntu 14)
become: true
shell: |
set -o pipefail
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
args:
warn: false
executable: /bin/bash
changed_when: false
when:
- ansible_distribution == "Ubuntu"
- ansible_distribution_major_version | int == 14

- name: Debian/Ubuntu | Installing NodeJS repository key
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
when:
- not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14)

- name: Debian/Ubuntu | Add NodeSource repositories for Node.js
apt_repository:
repo: "deb https://deb.nodesource.com/node_6.x {{ ansible_distribution_release }} main"
state: present
update_cache: true
changed_when: false

- name: Debian/Ubuntu | Set Distribution CIS filename for Debian/Ubuntu
set_fact:
cis_distribution_filename: cis_debian_linux_rcl.txt
Expand Down
31 changes: 0 additions & 31 deletions roles/wazuh/ansible-wazuh-manager/tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,4 @@
---
- name: RedHat/CentOS | Install Nodejs repo
yum_repository:
name: NodeJS
description: NodeJS-$releasever
baseurl: https://rpm.nodesource.com/pub_6.x/el/{{ ansible_distribution_major_version }}/x86_64
gpgkey: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
gpgcheck: true
changed_when: false
when:
- ansible_distribution_major_version|int > 5

- name: Fedora | Install Nodejs repo
yum_repository:
name: NodeJS
description: NodeJS-$releasever
baseurl: https://rpm.nodesource.com/pub_6.x/fc/$releasever/x86_64
gpgkey: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
gpgcheck: true
when: ansible_distribution == 'Fedora'

- name: AmazonLinux | Get Nodejs
shell: |
set -o pipefail
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
args:
warn: false
executable: /bin/bash
creates: /etc/yum.repos.d/nodesource-el7.repo
when:
- ansible_distribution|lower == "amazon"

- name: RedHat/CentOS 5 | Install Wazuh repo
yum_repository:
name: wazuh_repo
Expand Down
28 changes: 28 additions & 0 deletions roles/wazuh/ansible-wazuh-manager/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@
- tar
state: present

- name: Check if NodeJS service exists
stat:
path: /usr/bin/node
register: node_service_status

- name: Install NodeJS repository
block:
- name: Download NodeJS repository script
get_url:
url: "https://{{ nodejs['repo_dic'][ansible_os_family|lower] }}.{{ nodejs['repo_url_ext'] }}"
dest: /etc/nodejs.sh
mode: '0775'
changed_when: false

- name: Run NodeJS bash script
command: sh /etc/nodejs.sh
register: nodejs_script
changed_when: nodejs_script.rc == 0
when: not node_service_status.stat.exists

- name: Installing NodeJS
package:
name: nodejs
state: present
register: nodejs_service_is_installed
until: nodejs_service_is_installed is succeeded
tags: init

- include_tasks: "RedHat.yml"
when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 5) or (ansible_os_family == "RedHat" and ansible_distribution == "Amazon")

Expand Down