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

@ -10,6 +10,14 @@
- tar - tar
state: present 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) - name: Installing policycoreutils-python (RedHat families)
package: package:
name: name:
@ -76,3 +84,11 @@
changed_when: installation_result == 0 changed_when: installation_result == 0
args: 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 - tar
state: present 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) - name: Installing policycoreutils-python (RedHat families)
package: package:
name: name:
@ -88,6 +96,15 @@
changed_when: installation_result == 0 changed_when: installation_result == 0
args: args:
chdir: "/tmp/wazuh-{{ wazuh_manager_sources_installation.branch }}" 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: when:
- not wazuh_ossec_control.stat.exists - not wazuh_ossec_control.stat.exists
- wazuh_manager_sources_installation.enabled - wazuh_manager_sources_installation.enabled
@ -95,6 +112,7 @@
- manager - manager
# Wazuh API # Wazuh API
- name: Check if Wazuh API is already installed - name: Check if Wazuh API is already installed
stat: stat:
path: /var/ossec/api/app.js path: /var/ossec/api/app.js
@ -118,33 +136,6 @@
name: git name: git
state: present 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 - name: Remove old repository folder
file: file:
path: /tmp/wazuh-api path: /tmp/wazuh-api
@ -177,3 +168,5 @@
- wazuh_api_sources_installation.enabled - wazuh_api_sources_installation.enabled
tags: tags:
- api - api