Move the 'become' for privilege escalation to appropiate hosts only

This commit is contained in:
Jesus Garcia 2026-03-11 16:58:40 -05:00
parent 9704b6e790
commit 45d7a2357d
No known key found for this signature in database
GPG Key ID: 8461CA78326C96C9
4 changed files with 33 additions and 12 deletions

View File

@ -1,7 +1,5 @@
--- ---
- hosts: <your wazuh agents hosts> - hosts: <your wazuh agents hosts>
become: yes
become_user: root
roles: roles:
- ../roles/wazuh/ansible-wazuh-agent - ../roles/wazuh/ansible-wazuh-agent
vars: vars:

View File

@ -1,9 +1,11 @@
--- ---
- name: restart wazuh-agent - name: restart wazuh-agent
service: name=wazuh-agent state=restarted enabled=yes service: name=wazuh-agent state=restarted enabled=yes
become: yes
- name: Windows | Restart Wazuh Agent - name: Windows | Restart Wazuh Agent
win_service: name=WazuhSvc start_mode=auto state=restarted win_service: name=WazuhSvc start_mode=auto state=restarted
- name: macOS | Restart Wazuh Agent - name: macOS | Restart Wazuh Agent
command: /Library/Ossec/bin/wazuh-control restart command: /Library/Ossec/bin/wazuh-control restart
become: yes

View File

@ -1,11 +1,20 @@
--- ---
- include_tasks: "RedHat.yml" - include_tasks:
file: "RedHat.yml"
apply:
become: yes
when: ansible_facts.os_family == "RedHat" when: ansible_facts.os_family == "RedHat"
- include_tasks: "Debian.yml" - include_tasks:
file: "Debian.yml"
apply:
become: yes
when: ansible_facts.os_family == "Debian" when: ansible_facts.os_family == "Debian"
- include_tasks: "installation_from_custom_packages.yml" - include_tasks:
file: "installation_from_custom_packages.yml"
apply:
become: yes
when: when:
- wazuh_custom_packages_installation_agent_enabled - wazuh_custom_packages_installation_agent_enabled
@ -262,10 +271,16 @@
state: started state: started
tags: config tags: config
- include_tasks: "RMRedHat.yml" - include_tasks:
file: "RMRedHat.yml"
apply:
become: yes
when: when:
- ansible_facts.os_family == "RedHat" - ansible_facts.os_family == "RedHat"
- include_tasks: "RMDebian.yml" - include_tasks:
file: "RMDebian.yml"
apply:
become: yes
when: when:
- ansible_facts.os_family == "Debian" - ansible_facts.os_family == "Debian"

View File

@ -21,8 +21,14 @@
- include_tasks: "Windows.yml" - include_tasks: "Windows.yml"
when: ansible_facts.os_family == "Windows" when: ansible_facts.os_family == "Windows"
- include_tasks: "Linux.yml" - include_tasks:
file: "Linux.yml"
apply:
become: yes
when: ansible_facts.system == "Linux" when: ansible_facts.system == "Linux"
- include_tasks: "macOS.yml" - include_tasks:
file: "macOS.yml"
apply:
become: yes
when: ansible_facts.system == "Darwin" when: ansible_facts.system == "Darwin"