Implement blocks to cleanup old files

This commit is contained in:
Jose M 2019-11-25 18:11:09 +01:00
commit dc0aa448d0
2 changed files with 38 additions and 29 deletions

View File

@ -9,6 +9,14 @@
- libtool
- tar
state: present
- name: Removing old files
file: "/tmp/{{ wazuh_agent_sources_installation.branch }}.tar.gz"
state: absent
- name: Removing old folders
file: "/tmp/wazuh-{{ wazuh_agent_sources_installation.branch }}"
state: absent
- name: Installing policycoreutils-python (RedHat families)
package:
@ -75,4 +83,12 @@
register: installation_result
changed_when: installation_result == 0
args:
chdir: "/tmp/wazuh-{{ wazuh_agent_sources_installation.branch }}"
chdir: "/tmp/wazuh-{{ wazuh_agent_sources_installation.branch }}"
- name: Cleanup downloaded files
file: "/tmp/{{ wazuh_agent_sources_installation.branch }}.tar.gz"
state: absent
- name: Cleanup created folders
file: "/tmp/wazuh-{{ wazuh_agent_sources_installation.branch }}"
state: absent

View File

@ -18,6 +18,14 @@
- tar
state: present
- name: Removing old files
file: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
state: absent
- name: Removing old folders
file: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
state: absent
- name: Installing policycoreutils-python (RedHat families)
package:
name:
@ -88,6 +96,15 @@
changed_when: installation_result == 0
args:
chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
- name: Cleanup downloaded files
file: "/tmp/{{ wazuh_manager_sources_installation.branch }}.tar.gz"
state: absent
- name: Cleanup created folders
file: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}"
state: absent
when:
- not wazuh_ossec_control.stat.exists
- wazuh_manager_sources_installation.enabled
@ -95,6 +112,7 @@
- manager
# Wazuh API
- name: Check if Wazuh API is already installed
stat:
path: /var/ossec/api/app.js
@ -118,33 +136,6 @@
name: git
state: present
- name: Modify repo url if host is in Debian family
set_fact:
node_js_repo_type: deb
when:
- ansible_os_family | lower == "debian"
- name: Download script to install Nodejs repository
get_url:
url: "https://{{ node_js_repo_type }}.{{ node_js_repo_url }}"
dest: "/tmp/setup_nodejs_repo.sh"
mode: "0700"
- name: Execute downloaded script to install Nodejs repo
command: /tmp/setup_nodejs_repo.sh
register: node_repo_installation_result
changed_when: node_repo_installation_result.rc == 0
- name: Install Nodejs
package:
name: nodejs
state: present
- name: Run NPM under root account
command: npm config set user 0
register: allow_root_npm
changed_when: allow_root_npm.rc == 0
- name: Remove old repository folder
file:
path: /tmp/wazuh-api
@ -176,4 +167,6 @@
- not wazuh_api.stat.exists
- wazuh_api_sources_installation.enabled
tags:
- api
- api