Update installation_from_sources conditionals and blocks
This commit is contained in:
parent
628dcb2ccc
commit
380d4d1430
@ -1,75 +1,98 @@
|
|||||||
---
|
---
|
||||||
# Wazuh Manager
|
# Wazuh Manager
|
||||||
- name: Install dependencies to build Wazuh packages
|
- name: Check if Wazuh Manager is already installed
|
||||||
package:
|
stat:
|
||||||
name:
|
path: /var/ossec/bin/ossec-control
|
||||||
- make
|
register: wazuh_ossec_control
|
||||||
- gcc
|
|
||||||
- automake
|
|
||||||
- autoconf
|
|
||||||
- libtool
|
|
||||||
- tar
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Installing policycoreutils-python (RedHat families)
|
- name: Installing Wazuh Manager from sources
|
||||||
package:
|
block:
|
||||||
name:
|
- name: Install dependencies to build Wazuh packages
|
||||||
- policycoreutils-python
|
package:
|
||||||
|
name:
|
||||||
|
- make
|
||||||
|
- gcc
|
||||||
|
- automake
|
||||||
|
- autoconf
|
||||||
|
- libtool
|
||||||
|
- tar
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- 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.10.2" extracted folder name is 3.10.2.
|
||||||
|
# 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: '644'
|
||||||
|
|
||||||
|
- name: Executing "install.sh" script to build and install the Wazuh Manager
|
||||||
|
shell: ./install.sh > /tmp/build_manager_log.txt
|
||||||
|
register: installation_result
|
||||||
|
changed_when: installation_result == 0
|
||||||
|
args:
|
||||||
|
chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family|lower == "redhat"
|
- not wazuh_ossec_control.stat.exists
|
||||||
|
- wazuh_manager_sources_installation.enabled
|
||||||
- name: Installing policycoreutils-python-utils (Debian families)
|
tags:
|
||||||
package:
|
- manager
|
||||||
name:
|
|
||||||
- libc6-dev
|
|
||||||
- curl
|
|
||||||
- policycoreutils
|
|
||||||
when:
|
|
||||||
- ansible_os_family|lower == "debian"
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- 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.conf.j2"
|
|
||||||
dest: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/etc/preloaded-vars.conf"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: '644'
|
|
||||||
|
|
||||||
- name: Executing "install.sh" script to build and install the Wazuh Manager
|
|
||||||
shell: ./install.sh > /tmp/build_log.txt
|
|
||||||
register: installation_result
|
|
||||||
changed_when: installation_result == 0
|
|
||||||
args:
|
|
||||||
chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
|
|
||||||
|
|
||||||
# Wazuh API
|
# Wazuh API
|
||||||
- name: Check if Wazuh API is already installed
|
- name: Check if Wazuh API is already installed
|
||||||
@ -79,6 +102,11 @@
|
|||||||
|
|
||||||
- name: Install Wazuh API from sources
|
- name: Install Wazuh API from sources
|
||||||
block:
|
block:
|
||||||
|
- name: Ensure Git is present in the host
|
||||||
|
package:
|
||||||
|
name: git
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Download script to install Nodejs repository
|
- name: Download script to install Nodejs repository
|
||||||
get_url:
|
get_url:
|
||||||
url: "{{ node_js_repository_url }}"
|
url: "{{ node_js_repository_url }}"
|
||||||
@ -100,15 +128,35 @@
|
|||||||
register: allow_root_npm
|
register: allow_root_npm
|
||||||
changed_when: allow_root_npm.rc == 0
|
changed_when: allow_root_npm.rc == 0
|
||||||
|
|
||||||
- name: Download the installation script to install Wazuh API
|
- name: Remove old repository folder
|
||||||
get_url:
|
file:
|
||||||
url: "https://raw.githubusercontent.com/wazuh/wazuh-api/v{{ wazuh_manager_version[:-2] }}/install_api.sh"
|
path: /tmp/wazuh-api
|
||||||
dest: "/tmp/install_api.sh"
|
state: absent
|
||||||
mode: "0700"
|
|
||||||
|
- 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: '644'
|
||||||
|
|
||||||
- name: Execute Wazuh API installation script
|
- name: Execute Wazuh API installation script
|
||||||
shell: /tmp/install_api.sh download > /tmp/build_api_log.txt
|
shell: ./install_api.sh > /tmp/build_api_log.txt
|
||||||
register: install_api
|
register: install_api
|
||||||
changed_when: install_api.rc == 0
|
changed_when: install_api.rc == 0
|
||||||
|
args:
|
||||||
|
chdir: "/tmp/wazuh-api"
|
||||||
|
notify:
|
||||||
|
- restart wazuh-api
|
||||||
when:
|
when:
|
||||||
- not wazuh_api.stat.exists
|
- not wazuh_api.stat.exists
|
||||||
|
- wazuh_api_sources_installation.enabled
|
||||||
|
tags:
|
||||||
|
- api
|
||||||
Loading…
Reference in New Issue
Block a user