Skip to content

Commit

Permalink
change installation directory (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
cadoming authored and jesuslinares committed Dec 27, 2018
1 parent 9327f05 commit e94a0cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
5 changes: 4 additions & 1 deletion roles/wazuh/ansible-wazuh-agent/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ wazuh_notify_time: '10'
wazuh_time_reconnect: '60'
wazuh_crypto_method: 'aes'
wazuh_winagent_config:
install_dir: 'C:\wazuh-agent\'
install_dir: 'C:\Program Files\ossec-agent\'
install_dir_x86: 'C:\Program Files (x86)\ossec-agent\'
auth_path: C:\'Program Files'\ossec-agent\agent-auth.exe
auth_path_x86: C:\'Program Files (x86)'\ossec-agent\agent-auth.exe
version: '3.7.0'
revision: '1'
repo: https://packages.wazuh.com/3.x/windows/
Expand Down
25 changes: 16 additions & 9 deletions roles/wazuh/ansible-wazuh-agent/tasks/Windows.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
---
- name: Windows | Check if Program Files (x86) exists
win_stat:
path: C:\Program Files (x86)
register: check_path

- name: Windows | Get current installed version
win_shell: "{{ wazuh_winagent_config.install_dir }}ossec-agent.exe -h"
win_shell: "{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.install_dir_x86 }}{% else %}
{{ wazuh_winagent_config.install_dir }}{% endif %}ossec-agent.exe -h"
args:
removes: "{{ wazuh_winagent_config.install_dir }}ossec-agent.exe"
removes: "{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.install_dir_x86 }}{% else %}
{{ wazuh_winagent_config.install_dir }}{% endif %}ossec-agent.exe"
register: agent_version
failed_when: False
changed_when: False
Expand Down Expand Up @@ -34,12 +41,11 @@
- name: Windows | Install Wazuh agent
win_package:
path: C:\wazuh-agent-installer.msi
arguments: APPLICATIONFOLDER={{ wazuh_winagent_config.install_dir }}
when:
- correct_version is not defined

- name: Windows | Check if client.keys exists
win_stat: path="{{ wazuh_winagent_config.install_dir }}client.keys"
win_stat: path="{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.install_dir_x86 }}{% else %}{{ wazuh_winagent_config.install_dir }}{% endif %}client.keys"
register: check_windows_key
notify: restart wazuh-agent windows
tags:
Expand All @@ -52,12 +58,13 @@

- name: Windows | Register agent
win_shell: >
{{ wazuh_winagent_config.install_dir }}agent-auth.exe
{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.auth_path_x86 }}{% else %}
{{ wazuh_winagent_config.auth_path }}{% endif %}
-m {{ wazuh_managers.0.address }}
-p {{ wazuh_agent_authd.port }}
{% if authd_pass is defined %}-P {{ authd_pass }}{% endif %}
{% if authd_pass is defined %} -P {{ authd_pass }}{% endif %}
args:
chdir: "{{ wazuh_winagent_config.install_dir }}"
chdir: "{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.install_dir_x86 }}{% else %}{{ wazuh_winagent_config.install_dir }}{% endif %}"
register: agent_auth_output
notify: restart wazuh-agent windows
when:
Expand All @@ -70,15 +77,15 @@
- name: Windows | Installing agent configuration (ossec.conf)
win_template:
src: var-ossec-etc-ossec-agent.conf.j2
dest: "{{ wazuh_winagent_config.install_dir }}ossec.conf"
dest: "{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.install_dir_x86 }}{% else %}{{ wazuh_winagent_config.install_dir }}{% endif %}ossec.conf"
notify: restart wazuh-agent windows
tags:
- config

- name: Windows | Installing local_internal_options.conf
win_template:
src: var-ossec-etc-local-internal-options.conf.j2
dest: "{{ wazuh_winagent_config.install_dir }}local_internal_options.conf"
dest: "{% if check_path.stat.exists == true %}{{ wazuh_winagent_config.install_dir_x86 }}{% else %}{{ wazuh_winagent_config.install_dir }}{% endif %}local_internal_options.conf"
notify: restart wazuh-agent windows
tags:
- config
Expand Down

0 comments on commit e94a0cf

Please sign in to comment.