Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature package locking #1243

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions roles/wazuh/ansible-wazuh-agent/tasks/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@
- include_tasks: "Debian.yml"
when: ansible_os_family == "Debian"

- name: Linux | Get installed wazuh-agent version
ansible.builtin.package_facts:
manager: auto

- include_tasks: "installation_from_custom_packages.yml"
when:
- wazuh_custom_packages_installation_agent_enabled

- name: Linux CentOS/RedHat | Version unlock wazuh-agent
community.general.yum_versionlock:
name: "wazuh-agent"
state: absent
when:
- ansible_os_family|lower == "redhat"
- "'wazuh-agent' in ansible_facts.packages"
- not ansible_facts.packages['wazuh-agent'][0]['version'].startswith(wazuh_agent_version)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be computed in a fact since it is used twice.


- name: Linux CentOS/RedHat | Install wazuh-agent
yum:
name: wazuh-agent-{{ wazuh_agent_version }}
Expand All @@ -20,6 +33,22 @@
tags:
- init

- name: Linux CentOS/RedHat | Version lock wazuh-agent
community.general.yum_versionlock:
name: "wazuh-agent"
state: present
when:
- ansible_os_family|lower == "redhat"

- name: Linux Debian | Version unlock wazuh-agent
dpkg_selections:
name: "wazuh-agent"
selection: install
when:
- ansible_os_family|lower != "redhat"
- "'wazuh-agent' in ansible_facts.packages"
- not ansible_facts.packages['wazuh-agent'][0]['version'].startswith(wazuh_agent_version)

- name: Linux Debian | Install wazuh-agent
apt:
name: "wazuh-agent={{ wazuh_agent_version }}-*"
Expand All @@ -32,6 +61,13 @@
tags:
- init

- name: Linux Debian | Version lock wazuh-agent
dpkg_selections:
name: "wazuh-agent"
selection: hold
when:
- ansible_os_family|lower != "redhat"

- name: Linux | Check if client.keys exists
stat:
path: "{{ wazuh_dir }}/etc/client.keys"
Expand Down
5 changes: 0 additions & 5 deletions roles/wazuh/ansible-wazuh-agent/tasks/RMDebian.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
---
- name: Remove Wazuh repository (and clean up left-over metadata)
apt_repository:
repo: "{{ wazuh_agent_config.repo.apt }}"
state: absent
changed_when: false
5 changes: 0 additions & 5 deletions roles/wazuh/ansible-wazuh-agent/tasks/RMRedHat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
---
- name: Remove Wazuh repository (and clean up left-over metadata)
yum_repository:
name: wazuh_repo
state: absent
changed_when: false
5 changes: 5 additions & 0 deletions roles/wazuh/ansible-wazuh-agent/tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
tags:
- init

- name: RedHat/CentOS/Fedora | Install yum-plugin-versionlock
yum: name=yum-plugin-versionlock state=present
tags:
- init

- name: Set Distribution CIS filename for RHEL5
set_fact:
cis_distribution_filename: cis_rhel5_linux_rcl.txt
Expand Down