Skip to content

Commit

Permalink
Centralize NodeJS installation tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
rshad committed Nov 21, 2019
1 parent 686c02b commit d85d210
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 53 deletions.
4 changes: 4 additions & 0 deletions playbooks/wazuh-manager.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
- hosts: <WAZUH_MANAGER_HOST>
- vars:
- repo_dic:
debian: "deb"
redhat: "rpm"
roles:
- role: ../roles/wazuh/ansible-wazuh-manager
- role: ../roles/wazuh/ansible-filebeat
Expand Down
18 changes: 0 additions & 18 deletions roles/wazuh/ansible-wazuh-manager/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,6 @@
update_cache: true
changed_when: false

- name: Debian/Ubuntu | Installing NodeJS repository
become: true
shell: |
set -o pipefail
curl -sL https://deb.nodesource.com/setup_8.x | bash -
args:
warn: false
executable: /bin/bash
changed_when: false

- name: Debian/Ubuntu | Install NodeJS
apt:
name: "nodejs"
state: present
register: nodejs_package_is_installed
until: nodejs_package_is_installed is succeeded
tags: init

- name: Debian/Ubuntu | Set Distribution CIS filename for Debian/Ubuntu
set_fact:
cis_distribution_filename: cis_debian_linux_rcl.txt
Expand Down
35 changes: 0 additions & 35 deletions roles/wazuh/ansible-wazuh-manager/tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
---
- name: Check if NodeJS service Exists
stat: path=/usr/bin/node
register: node_service_status

- name: Centos | 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_major_version|int > 5 and not node_service_status.stat.exists

- name: AmazonLinux/Fedora| Get Nodejs
shell: |
set -o pipefail
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
args:
warn: false
executable: /bin/bash
when:
- ( ansible_distribution|lower == "amazon" or ansible_distribution|lower == 'fedora' ) and not node_service_status.stat.exists

- name: CentOS/RedHat/Amazon/Fedora | Install NodeJS
package:
name: "nodejs"
state: present
register: nodejs_is_installed
until: nodejs_is_installed is succeeded
tags:
- init
when: not node_service_status.stat.exists

- name: RedHat/CentOS 5 | Install Wazuh repo
yum_repository:
name: wazuh_repo
Expand Down
19 changes: 19 additions & 0 deletions roles/wazuh/ansible-wazuh-manager/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
- include_tasks: "Debian.yml"
when: ansible_os_family == "Debian"

- name: Installing NodeJS repository script
become: true
get_url:
url: "https://{{ repo_dic[ansible_os_family] }}nodesource.com/setup_8.x"
dest: /etc/nodejs.sh
mode: '0775'
changed_when: false

- name: Running NodeJS bash script
script: /etc/nodejs.sh

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

- name: Install expect
package:
name: expect
Expand Down

0 comments on commit d85d210

Please sign in to comment.