Rename wazuh_sources_installation to wazuh_manager sources_installation

This commit is contained in:
Jose M 2019-11-21 15:01:15 +01:00
parent 3acdd20dff
commit 13b2321540
13 changed files with 81 additions and 73 deletions

View File

@ -1,8 +1,8 @@
--- ---
- hosts: <your server host> - hosts: all
roles: roles:
- {role: ../roles/wazuh/ansible-wazuh-manager} # - {role: ../roles/wazuh/ansible-wazuh-manager}
- role: ../roles/wazuh/ansible-filebeat # - role: ../roles/wazuh/ansible-filebeat
filebeat_output_elasticsearch_hosts: localhost:9200 # filebeat_output_elasticsearch_hosts: 172.24.1.2:9200
- {role: ../roles/elastic-stack/ansible-elasticsearch, elasticsearch_network_host: '0.0.0.0', single_node: true} # - {role: ../roles/elastic-stack/ansible-elasticsearch, elasticsearch_network_host: '0.0.0.0', single_node: true}
- { role: ../roles/elastic-stack/ansible-kibana, elasticsearch_network_host: 'localhost' } - { role: ../roles/elastic-stack/ansible-kibana, elasticsearch_network_host: '172.24.1.1', elasticsearch_reachable_host: '172.24.1.2' }

View File

@ -1,6 +1,6 @@
--- ---
wazuh_agent_version: 3.10.2-1 wazuh_agent_version: 3.10.2-1
wazuh_sources_installation: wazuh_manager_sources_installation:
enabled: "true" enabled: "true"
branch: "v3.10.2" branch: "v3.10.2"
user_language: "y" user_language: "y"

View File

@ -20,7 +20,7 @@
when: when:
- ansible_distribution == "Ubuntu" - ansible_distribution == "Ubuntu"
- ansible_distribution_major_version | int == 14 - ansible_distribution_major_version | int == 14
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Installing Wazuh repository key - name: Debian/Ubuntu | Installing Wazuh repository key
apt_key: apt_key:
@ -35,7 +35,7 @@
state: present state: present
update_cache: true update_cache: true
when: when:
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Set Distribution CIS filename for debian - name: Debian/Ubuntu | Set Distribution CIS filename for debian
set_fact: set_fact:

View File

@ -1,7 +1,7 @@
--- ---
- include_tasks: "../tasks/installation_from_sources.yml" - include_tasks: "../tasks/installation_from_sources.yml"
when: when:
- wazuh_sources_installation.enabled - wazuh_manager_sources_installation.enabled
- include_tasks: "RedHat.yml" - include_tasks: "RedHat.yml"
when: ansible_os_family == "RedHat" when: ansible_os_family == "RedHat"
@ -17,7 +17,7 @@
poll: 30 poll: 30
when: when:
- ansible_os_family|lower == "redhat" - ansible_os_family|lower == "redhat"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
tags: tags:
- init - init
@ -28,7 +28,7 @@
cache_valid_time: 3600 cache_valid_time: 3600
when: when:
- ansible_os_family|lower != "redhat" - ansible_os_family|lower != "redhat"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
tags: tags:
- init - init
@ -200,9 +200,9 @@
- include_tasks: "RMRedHat.yml" - include_tasks: "RMRedHat.yml"
when: when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- include_tasks: "RMDebian.yml" - include_tasks: "RMDebian.yml"
when: when:
- ansible_os_family == "Debian" - ansible_os_family == "Debian"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled

View File

@ -10,7 +10,7 @@
when: when:
- (ansible_facts['os_family']|lower == 'redhat') and (ansible_distribution|lower != 'amazon') - (ansible_facts['os_family']|lower == 'redhat') and (ansible_distribution|lower != 'amazon')
- (ansible_distribution_major_version|int <= 5) - (ansible_distribution_major_version|int <= 5)
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
register: repo_v5_installed register: repo_v5_installed
- name: RedHat/CentOS/Fedora | Install Wazuh repo - name: RedHat/CentOS/Fedora | Install Wazuh repo
@ -23,7 +23,7 @@
changed_when: false changed_when: false
when: when:
- repo_v5_installed is skipped - repo_v5_installed is skipped
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: RedHat/CentOS/Fedora | download Oracle Java RPM - name: RedHat/CentOS/Fedora | download Oracle Java RPM
get_url: get_url:

View File

@ -28,17 +28,17 @@
- name: Download required packages from github.com/wazuh/wazuh - name: Download required packages from github.com/wazuh/wazuh
get_url: get_url:
url: "https://github.com/wazuh/wazuh/archive/{{ wazuh_sources_installation.branch }}.tar.gz" url: "https://github.com/wazuh/wazuh/archive/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
dest: "/tmp/{{ wazuh_sources_installation.branch }}.tar.gz" dest: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
delegate_to: "{{ inventory_hostname }}" delegate_to: "{{ inventory_hostname }}"
- name: Create folder to extract Wazuh branch - name: Create folder to extract Wazuh branch
file: file:
path: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}" path: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
state: directory state: directory
- name: Extract downloaded Wazuh branch from Github # Using shell instead of unarchive due to that module not working properlyh with --strip - 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_sources_installation.branch }}.tar.gz --strip 1 --directory /tmp/wazuh-{{ wazuh_sources_installation.branch }}" command: "tar -xzvf /tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz --strip 1 --directory /tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
register: wazuh_untar register: wazuh_untar
changed_when: wazuh_untar.rc ==0 changed_when: wazuh_untar.rc ==0
args: args:
@ -47,7 +47,7 @@
- name: Clean remaining files from others builds - name: Clean remaining files from others builds
command: "make -C src {{ item }}" command: "make -C src {{ item }}"
args: args:
chdir: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}/src/" chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/src/"
with_items: with_items:
- "clean" - "clean"
- "clean-deps" - "clean-deps"
@ -58,7 +58,7 @@
- name: Render the "preloaded-vars.conf" file - name: Render the "preloaded-vars.conf" file
template: template:
src: "templates/preloaded_vars.conf.j2" src: "templates/preloaded_vars.conf.j2"
dest: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}/etc/preloaded-vars.conf" dest: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/etc/preloaded-vars.conf"
owner: root owner: root
group: root group: root
mode: '644' mode: '644'
@ -68,4 +68,4 @@
register: installation_result register: installation_result
changed_when: installation_result == 0 changed_when: installation_result == 0
args: args:
chdir: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}" chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"

View File

@ -1,4 +1,4 @@
{% for key, value in wazuh_sources_installation.items() %} {% for key, value in wazuh_manager_sources_installation.items() %}
{% if "user_" in key %} {% if "user_" in key %}
{% if value is defined and value is not none %} {% if value is defined and value is not none %}
{{ key|upper }}="{{ value }}" {{ key|upper }}="{{ value }}"

View File

@ -4,7 +4,7 @@ wazuh_manager_version: 3.10.2-1
wazuh_manager_fqdn: "wazuh-server" wazuh_manager_fqdn: "wazuh-server"
wazuh_manager_package_state: present wazuh_manager_package_state: present
wazuh_sources_installation: wazuh_manager_sources_installation:
enabled: true enabled: true
branch: "v3.10.2" branch: "v3.10.2"
user_language: "en" user_language: "en"

View File

@ -1,7 +1,7 @@
--- ---
- include_tasks: "installation_from_sources.yml" - include_tasks: "installation_from_sources.yml"
when: when:
- wazuh_sources_installation.enabled - wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Install apt-transport-https and ca-certificates - name: Debian/Ubuntu | Install apt-transport-https and ca-certificates
apt: apt:
@ -27,14 +27,14 @@
when: when:
- ansible_distribution == "Ubuntu" - ansible_distribution == "Ubuntu"
- ansible_distribution_major_version | int == 14 - ansible_distribution_major_version | int == 14
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Installing Wazuh repository key - name: Debian/Ubuntu | Installing Wazuh repository key
apt_key: apt_key:
url: "{{ wazuh_manager_config.repo.gpg }}" url: "{{ wazuh_manager_config.repo.gpg }}"
when: when:
- not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14)
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Add Wazuh repositories - name: Debian/Ubuntu | Add Wazuh repositories
apt_repository: apt_repository:
@ -44,7 +44,7 @@
update_cache: true update_cache: true
changed_when: false changed_when: false
when: when:
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Installing NodeJS repository key (Ubuntu 14) - name: Debian/Ubuntu | Installing NodeJS repository key (Ubuntu 14)
become: true become: true
@ -58,14 +58,14 @@
when: when:
- ansible_distribution == "Ubuntu" - ansible_distribution == "Ubuntu"
- ansible_distribution_major_version | int == 14 - ansible_distribution_major_version | int == 14
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Installing NodeJS repository key - name: Debian/Ubuntu | Installing NodeJS repository key
apt_key: apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
when: when:
- not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14) - not (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int == 14)
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Add NodeSource repositories for Node.js - name: Debian/Ubuntu | Add NodeSource repositories for Node.js
apt_repository: apt_repository:
@ -74,7 +74,7 @@
update_cache: true update_cache: true
changed_when: false changed_when: false
when: when:
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: Debian/Ubuntu | Set Distribution CIS filename for Debian/Ubuntu - name: Debian/Ubuntu | Set Distribution CIS filename for Debian/Ubuntu
set_fact: set_fact:
@ -139,4 +139,4 @@
until: wazuh_manager_main_packages_installed is succeeded until: wazuh_manager_main_packages_installed is succeeded
tags: init tags: init
when: when:
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled

View File

@ -1,7 +1,7 @@
--- ---
- include_tasks: "../tasks/installation_from_sources.yml" - include_tasks: "../tasks/installation_from_sources.yml"
when: when:
- wazuh_sources_installation.enabled - wazuh_manager_sources_installation.enabled
- name: RedHat/CentOS | Install Nodejs repo - name: RedHat/CentOS | Install Nodejs repo
yum_repository: yum_repository:
@ -45,7 +45,7 @@
when: when:
- (ansible_os_family|lower == 'redhat') and (ansible_distribution|lower != 'amazon') - (ansible_os_family|lower == 'redhat') and (ansible_distribution|lower != 'amazon')
- (ansible_distribution_major_version|int <= 5) - (ansible_distribution_major_version|int <= 5)
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
register: repo_v5_manager_installed register: repo_v5_manager_installed
- name: RedHat/CentOS/Fedora | Install Wazuh repo - name: RedHat/CentOS/Fedora | Install Wazuh repo
@ -58,7 +58,7 @@
changed_when: false changed_when: false
when: when:
- repo_v5_manager_installed is skipped - repo_v5_manager_installed is skipped
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- name: RedHat/CentOS/Fedora | Install openscap - name: RedHat/CentOS/Fedora | Install openscap
package: name={{ item }} state=present package: name={{ item }} state=present
@ -155,7 +155,7 @@
until: wazuh_manager_main_packages_installed is succeeded until: wazuh_manager_main_packages_installed is succeeded
when: when:
- ansible_os_family|lower == "redhat" - ansible_os_family|lower == "redhat"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
tags: tags:
- init - init

View File

@ -29,17 +29,17 @@
- name: Download required packages from github.com/wazuh/wazuh - name: Download required packages from github.com/wazuh/wazuh
get_url: get_url:
url: "https://github.com/wazuh/wazuh/archive/{{ wazuh_sources_installation.branch }}.tar.gz" url: "https://github.com/wazuh/wazuh/archive/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
dest: "/tmp/{{ wazuh_sources_installation.branch }}.tar.gz" dest: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
delegate_to: "{{ inventory_hostname }}" delegate_to: "{{ inventory_hostname }}"
- name: Create folder to extract Wazuh branch - name: Create folder to extract Wazuh branch
file: file:
path: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}" path: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
state: directory state: directory
- name: Extract downloaded Wazuh branch from Github # Using shell instead of unarchive due to that module not working properlyh with --strip - 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_sources_installation.branch }}.tar.gz --strip 1 --directory /tmp/wazuh-{{ wazuh_sources_installation.branch }}" command: "tar -xzvf /tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz --strip 1 --directory /tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
register: wazuh_untar register: wazuh_untar
changed_when: wazuh_untar.rc ==0 changed_when: wazuh_untar.rc ==0
args: args:
@ -48,7 +48,7 @@
- name: Clean remaining files from others builds - name: Clean remaining files from others builds
command: "make -C src {{ item }}" command: "make -C src {{ item }}"
args: args:
chdir: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}/src/" chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/src/"
with_items: with_items:
- "clean" - "clean"
- "clean-deps" - "clean-deps"
@ -59,7 +59,7 @@
- name: Render the "preloaded-vars.conf" file - name: Render the "preloaded-vars.conf" file
template: template:
src: "templates/preloaded_vars.conf.j2" src: "templates/preloaded_vars.conf.j2"
dest: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}/etc/preloaded-vars.conf" dest: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}/etc/preloaded-vars.conf"
owner: root owner: root
group: root group: root
mode: '644' mode: '644'
@ -69,10 +69,16 @@
register: installation_result register: installation_result
changed_when: installation_result == 0 changed_when: installation_result == 0
args: args:
chdir: "/tmp/wazuh-{{ wazuh_sources_installation.branch }}" chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
# Wazuh API # Wazuh API
- name: Check if Wazuh API is already installed
stat:
path: /var/ossec/api/app.js
register: wazuh_api
- name: Install Wazuh API from sources
block:
- 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 }}"
@ -104,3 +110,5 @@
shell: /tmp/install_api.sh download > /tmp/build_api_log.txt shell: /tmp/install_api.sh download > /tmp/build_api_log.txt
register: install_api register: install_api
changed_when: install_api.rc == 0 changed_when: install_api.rc == 0
when:
- not wazuh_api.stat.exists

View File

@ -356,9 +356,9 @@
- include_tasks: "RMRedHat.yml" - include_tasks: "RMRedHat.yml"
when: when:
- ansible_os_family == "RedHat" or ansible_os_family == "Amazon" - ansible_os_family == "RedHat" or ansible_os_family == "Amazon"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled
- include_tasks: "RMDebian.yml" - include_tasks: "RMDebian.yml"
when: when:
- ansible_os_family == "Debian" - ansible_os_family == "Debian"
- not wazuh_sources_installation.enabled - not wazuh_manager_sources_installation.enabled

View File

@ -1,4 +1,4 @@
{% for key, value in wazuh_sources_installation.items() %} {% for key, value in wazuh_manager_sources_installation.items() %}
{% if "user_" in key %} {% if "user_" in key %}
{% if value is defined and value is not none %} {% if value is defined and value is not none %}
{{ key|upper }}="{{ value }}" {{ key|upper }}="{{ value }}"