WIP: Adapting to v4.0
This commit is contained in:
parent
8580a01267
commit
45a14c128c
@ -6,7 +6,7 @@
|
||||
wazuh_managers:
|
||||
- address: <your manager IP>
|
||||
port: 1514
|
||||
protocol: udp
|
||||
protocol: tcp
|
||||
api_port: 55000
|
||||
api_proto: 'http'
|
||||
api_user: ansible
|
||||
|
||||
@ -35,7 +35,7 @@ wazuh_agent_sources_installation:
|
||||
wazuh_managers:
|
||||
- address: 127.0.0.1
|
||||
port: 1514
|
||||
protocol: udp
|
||||
protocol: tcp
|
||||
api_port: 55000
|
||||
api_proto: 'http'
|
||||
api_user: null
|
||||
|
||||
@ -100,7 +100,7 @@ wazuh_manager_config:
|
||||
connection:
|
||||
- type: 'secure'
|
||||
port: '1514'
|
||||
protocol: 'udp'
|
||||
protocol: 'tcp'
|
||||
queue_size: 131072
|
||||
authd:
|
||||
enable: true
|
||||
|
||||
@ -4,9 +4,3 @@
|
||||
name: wazuh-manager
|
||||
state: restarted
|
||||
enabled: true
|
||||
|
||||
- name: restart wazuh-api
|
||||
service:
|
||||
name: wazuh-api
|
||||
state: restarted
|
||||
enabled: true
|
||||
@ -111,25 +111,6 @@
|
||||
- not wazuh_manager_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_manager_enabled
|
||||
|
||||
- include_tasks: "installation_from_sources.yml"
|
||||
when:
|
||||
- wazuh_manager_sources_installation.enabled or wazuh_api_sources_installation.enabled
|
||||
|
||||
- include_tasks: "installation_from_custom_packages.yml"
|
||||
when:
|
||||
- wazuh_custom_packages_installation_manager_enabled or wazuh_custom_packages_installation_api_enabled
|
||||
|
||||
- name: Debian/Ubuntu | Install wazuh-api
|
||||
apt:
|
||||
name:
|
||||
- "wazuh-api={{ wazuh_manager_version }}"
|
||||
state: present
|
||||
cache_valid_time: 3600
|
||||
install_recommends: false
|
||||
register: wazuh_manager_main_packages_installed
|
||||
until: wazuh_manager_main_packages_installed is succeeded
|
||||
tags: init
|
||||
when:
|
||||
- not wazuh_api_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_manager_enabled
|
||||
- wazuh_manager_config.cluster.node_type == "master"
|
||||
@ -10,8 +10,8 @@
|
||||
when:
|
||||
- (ansible_os_family|lower == 'redhat') and (ansible_distribution|lower != 'amazon')
|
||||
- (ansible_distribution_major_version|int <= 5)
|
||||
- not wazuh_manager_sources_installation.enabled or not wazuh_api_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_manager_enabled or not wazuh_custom_packages_installation_api_enabled
|
||||
- not wazuh_manager_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_manager_enabled
|
||||
register: repo_v5_manager_installed
|
||||
|
||||
- name: RedHat/CentOS/Fedora | Install Wazuh repo
|
||||
@ -24,8 +24,8 @@
|
||||
changed_when: false
|
||||
when:
|
||||
- repo_v5_manager_installed is skipped
|
||||
- not wazuh_manager_sources_installation.enabled or not wazuh_api_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_manager_enabled or not wazuh_custom_packages_installation_api_enabled
|
||||
- not wazuh_manager_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_manager_enabled
|
||||
|
||||
- name: RedHat/CentOS/Fedora | Install openscap
|
||||
package: name={{ item }} state=present
|
||||
@ -105,27 +105,9 @@
|
||||
tags:
|
||||
- init
|
||||
|
||||
- include_tasks: "../tasks/installation_from_sources.yml"
|
||||
when:
|
||||
- wazuh_manager_sources_installation.enabled or wazuh_api_sources_installation.enabled
|
||||
|
||||
- include_tasks: "../tasks/installation_from_custom_packages.yml"
|
||||
when:
|
||||
- wazuh_custom_packages_installation_manager_enabled or wazuh_custom_packages_installation_api_enabled
|
||||
|
||||
- name: CentOS/RedHat/Amazon | Install wazuh-api
|
||||
package:
|
||||
name: "wazuh-api-{{ wazuh_manager_version }}"
|
||||
state: "{{ wazuh_manager_package_state }}"
|
||||
register: wazuh_api_main_packages_installed
|
||||
until: wazuh_api_main_packages_installed is succeeded
|
||||
when:
|
||||
- ansible_os_family|lower == "redhat"
|
||||
- not wazuh_api_sources_installation.enabled
|
||||
- not wazuh_custom_packages_installation_api_enabled
|
||||
- wazuh_manager_config.cluster.node_type == "master"
|
||||
tags:
|
||||
- init
|
||||
- wazuh_custom_packages_installation_manager_enabled
|
||||
|
||||
- name: CentOS/RedHat 6 | Enabling python2.7 and sqlite3
|
||||
replace:
|
||||
|
||||
@ -1,185 +0,0 @@
|
||||
---
|
||||
# Wazuh Manager
|
||||
- name: Check if Wazuh Manager is already installed
|
||||
stat:
|
||||
path: /var/ossec/bin/ossec-control
|
||||
register: wazuh_ossec_control
|
||||
|
||||
- name: Installing Wazuh Manager from sources
|
||||
block:
|
||||
- name: Install dependencies to build Wazuh packages
|
||||
package:
|
||||
name:
|
||||
- make
|
||||
- gcc
|
||||
- automake
|
||||
- autoconf
|
||||
- libtool
|
||||
- tar
|
||||
state: present
|
||||
|
||||
- name: Removing old files
|
||||
file:
|
||||
path: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
|
||||
state: absent
|
||||
|
||||
- name: Removing old folders
|
||||
file:
|
||||
path: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
|
||||
state: absent
|
||||
|
||||
- name: Installing policycoreutils-python (RedHat families)
|
||||
package:
|
||||
name:
|
||||
- policycoreutils-python
|
||||
when:
|
||||
- ansible_os_family|lower == "redhat"
|
||||
|
||||
- name: Installing policycoreutils-python-utils (Debian families)
|
||||
package:
|
||||
name:
|
||||
- libc6-dev
|
||||
- curl
|
||||
- policycoreutils
|
||||
when:
|
||||
- ansible_os_family|lower == "debian"
|
||||
|
||||
- name: Remove old repository folder
|
||||
file:
|
||||
path: /tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}
|
||||
state: absent
|
||||
|
||||
- name: Download required packages from github.com/wazuh/wazuh
|
||||
get_url:
|
||||
url: "https://github.com/wazuh/wazuh/archive/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
|
||||
dest: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
|
||||
- name: Create folder to extract Wazuh branch
|
||||
file:
|
||||
path: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
|
||||
state: directory
|
||||
|
||||
# When downloading "v3.11.0" extracted folder name is 3.11.0.
|
||||
|
||||
# Explicitly creating the folder with proper naming and striping first level in .tar.gz file
|
||||
|
||||
- name: Extract downloaded Wazuh branch from Github # Using shell instead of unarchive due to that module not working properlyh with --strip
|
||||
command: >-
|
||||
tar -xzvf /tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz
|
||||
--strip 1
|
||||
--directory /tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}
|
||||
register: wazuh_untar
|
||||
changed_when: wazuh_untar.rc ==0
|
||||
args:
|
||||
warn: false
|
||||
|
||||
- name: Clean remaining files from others builds
|
||||
command: "make -C src {{ item }}"
|
||||
args:
|
||||
chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/src/"
|
||||
with_items:
|
||||
- "clean"
|
||||
- "clean-deps"
|
||||
register: clean_result
|
||||
changed_when: clean_result.rc == 0
|
||||
failed_when: false
|
||||
|
||||
- name: Render the "preloaded-vars.conf" file
|
||||
template:
|
||||
src: "templates/preloaded_vars_manager.conf.j2"
|
||||
dest: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/etc/preloaded-vars.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Executing "install.sh" script to build and install the Wazuh Manager
|
||||
shell: ./install.sh > /tmp/build_wazuh_manager_log.txt
|
||||
register: installation_result
|
||||
changed_when: installation_result == 0
|
||||
args:
|
||||
chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
|
||||
|
||||
- name: Cleanup downloaded files
|
||||
file:
|
||||
path: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
|
||||
state: absent
|
||||
|
||||
- name: Cleanup created folders
|
||||
file:
|
||||
path: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
|
||||
state: absent
|
||||
|
||||
when:
|
||||
- not wazuh_ossec_control.stat.exists
|
||||
- wazuh_manager_sources_installation.enabled
|
||||
tags:
|
||||
- manager
|
||||
|
||||
# Wazuh API
|
||||
|
||||
- name: Check if Wazuh API is already installed
|
||||
stat:
|
||||
path: /var/ossec/api/app.js
|
||||
register: wazuh_api
|
||||
when:
|
||||
- wazuh_manager_config.cluster.node_type == "master" or wazuh_manager_config.cluster.node_type == "worker"
|
||||
|
||||
- name: Install Wazuh API from sources
|
||||
block:
|
||||
- name: Install dependencies to build Wazuh packages
|
||||
package:
|
||||
name:
|
||||
- make
|
||||
- gcc
|
||||
- automake
|
||||
- autoconf
|
||||
- libtool
|
||||
- tar
|
||||
state: present
|
||||
|
||||
- name: Explicitly installing npm for Debian hosts
|
||||
package:
|
||||
name: npm
|
||||
state: present
|
||||
when:
|
||||
- ansible_distribution == "Debian"
|
||||
|
||||
- name: Ensure Git is present in the host
|
||||
package:
|
||||
name: git
|
||||
state: present
|
||||
|
||||
- name: Remove old repository folder
|
||||
file:
|
||||
path: /tmp/wazuh-api
|
||||
state: absent
|
||||
|
||||
- name: Download the Wazuh API repository
|
||||
git:
|
||||
repo: 'https://github.com/wazuh/wazuh-api.git'
|
||||
version: "{{ wazuh_api_sources_installation.branch }}"
|
||||
dest: /tmp/wazuh-api
|
||||
|
||||
- name: Configure Wazuh API installation
|
||||
template:
|
||||
src: "templates/preloaded_vars_api.conf.j2"
|
||||
dest: "/tmp/wazuh-api/configuration/preloaded_vars.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Execute Wazuh API installation script
|
||||
shell: ./install_api.sh > /tmp/build_wazuh_api_log.txt
|
||||
register: install_api
|
||||
changed_when: install_api.rc == 0
|
||||
args:
|
||||
chdir: "/tmp/wazuh-api"
|
||||
notify:
|
||||
- restart wazuh-api
|
||||
when:
|
||||
- not wazuh_api.stat.exists
|
||||
- wazuh_api_sources_installation.enabled
|
||||
- wazuh_manager_config.cluster.node_type == "master"
|
||||
tags:
|
||||
- api
|
||||
@ -175,7 +175,6 @@
|
||||
notify: restart wazuh-api
|
||||
when:
|
||||
- wazuh_manager_config.cluster.node_type == "master"
|
||||
|
||||
tags:
|
||||
- init
|
||||
- config
|
||||
|
||||
Loading…
Reference in New Issue
Block a user