-
Notifications
You must be signed in to change notification settings - Fork 284
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
Fix zabbix_agent role on Windows #1290
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution. A few comments but looks good.
@@ -3,17 +3,21 @@ | |||
- name: AutoPSK | Check for existing TLS PSK identity | Windows | |||
ansible.windows.win_stat: | |||
path: "{{ zabbix_agent_tlspskidentity_file }}" | |||
register: zabbix_agent_tlspskidentity_check | |||
register: zabbix_agent_tlspskidentity_check_windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how zabbix_agent_tlspskidentity_check
could be set twice since the two choices for the ansible_os_family
variable are mutually exclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original code, there is two tasks that use the "register" keyword for the same variable. This two task are, indeed, mutual exclusive. But Ansible also set the variable if the task is skipped.
If a task fails or is skipped, Ansible still registers a variable with a failure or skipped status, unless the task is skipped based on tags.
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html
@@ -12,17 +12,21 @@ | |||
- name: AutoPSK | Check for existing TLS PSK file | Windows | |||
ansible.windows.win_stat: | |||
path: "{{ zabbix_agent_tlspskfile }}" | |||
register: zabbix_agent_tlspskcheck | |||
register: zabbix_agent_tlspskcheck_windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how zabbix_agent_tlspskcheck
could be set twice since the two choices for the ansible_os_family
variable are mutually exclusive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original code, there is two tasks that use the "register" keyword for the same variable. This two task are, indeed, mutual exclusive. But Ansible also set the variable if the task is skipped.
If a task fails or is skipped, Ansible still registers a variable with a failure or skipped status, unless the task is skipped based on tags.
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html
@@ -3,7 +3,8 @@ _logfile: /var/log/zabbix/zabbix_agent2.log | |||
_include: /etc/zabbix/zabbix_agent2.d | |||
_tls_subject: "{{ zabbix_agent_tlsservercertsubject | default(omit) }}" # FIXME this is not correct and should be removed with 2.0.0, here only to prevent regression | |||
_win_package: zabbix_agent2-{{ zabbix_version_long }}-windows-amd64-openssl-static.zip | |||
_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix2_win_package }}" | |||
_win_logfile: "{{ zabbix_win_install_dir }}\\zabbix_agent2.log" | |||
_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix2_win_package | default('_win_package') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the latest changes. Support for zabbix2_win_package
has been removed with the release of 3.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you suggest as an alternative?
The code below uses the variable _win_download_link
when the variables zabbix_agent_win_download_link
and zabbix_agent2_win_download_link
are not set.
community.zabbix/roles/zabbix_agent/tasks/Windows.yml
Lines 1 to 4 in 45ed88b
--- | |
- name: "Windows | Set some variables" | |
ansible.builtin.set_fact: | |
zabbix_agent_win_download_link: "{{ zabbix_agent_win_download_link is defined | ternary(zabbix_agent_win_download_link, zabbix_agent2_win_download_link) | default(_win_download_link) }}" |
On the other hand, the code below uses the variable zabbix2_win_package
that is not set by default.
_win_download_link: "{{ zabbix_win_download_url }}/{{ zabbix_version_long | regex_search('^\\d+\\.\\d+') }}/{{ zabbix_version_long }}/{{ zabbix2_win_package }}" |
Therefore, the script will fail if none of these variables are set when the Role is applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstood your comment. Do you just want to unify the parameter for Zabbix_agent and Zabbix_agent2?
|
||
- name: "Set Include Path Info" | ||
ansible.builtin.set_fact: | ||
zabbix_agent_include: "{{ zabbix_agent_win_include is defined | ternary(zabbix_agent_win_include, zabbix_agent2_win_include) | default(_win_include) }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the latest changes. Support for zabbix_agent2_win_include
has been removed with the release of 3.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In template of zabbix_agent.conf, the parameter Include=
will be set because the variable zabbix_agent_include
is defined in the main.yml script.
community.zabbix/roles/zabbix_agent/tasks/main.yml
Lines 27 to 29 in 45ed88b
- name: Set Variables | |
ansible.builtin.set_fact: | |
zabbix_agent_include: "{{ zabbix_agent_include is defined | ternary(zabbix_agent_include, _include) }}" |
{{ (zabbix_agent_include is defined and zabbix_agent_include is not none) | ternary('', '# ') }}Include={{ zabbix_agent_include | default('') }} |
So, for Windows, if the variable zabbix_agent_include
was not explicited defined, the parameter Include
will be set to /etc/zabbix/zabbix_agentd.d
because of the code below.
_include: /etc/zabbix/zabbix_agentd.d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstood your comment. Do you just want to unify the parameter for Zabbix_agent and Zabbix_agent2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! There are no more zabbix_agent2 vars. They are all combined into zabbix_agent vars
roles/zabbix_agent/tasks/Windows.yml
Outdated
@@ -191,8 +192,8 @@ | |||
|
|||
- name: "Windows | Set installation settings (agent 2)" | |||
ansible.builtin.set_fact: | |||
zabbix_win_package: "{{ zabbix2_win_package }}" | |||
zabbix_win_download_link: "{{ zabbix2_win_download_link }}" | |||
zabbix_win_package: "{{ zabbix2_win_package | default('_win_package') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the latest changes. Support for zabbix2_win_package
has been removed with the release of 3.0.0
roles/zabbix_agent/tasks/Windows.yml
Outdated
zabbix_win_package: "{{ zabbix2_win_package }}" | ||
zabbix_win_download_link: "{{ zabbix2_win_download_link }}" | ||
zabbix_win_package: "{{ zabbix2_win_package | default('_win_package') }}" | ||
zabbix_win_download_link: "{{ zabbix2_win_download_link | default('_win_download_link') }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the latest changes. Support for zabbix2_win_download_link
has been removed with the release of 3.0.0
Are there any news here? |
the agent role is fixed by commit b0f05b4 but the version 3.0.1 is not released. see #1301 (comment) |
I was a little busy this week, but I will take a look soo n. |
The code below in zabbix_agent role still include the role zabbix_repo for Windows hosts. community.zabbix/roles/zabbix_agent/tasks/main.yml Lines 43 to 52 in 28c4921
In my view, the correct logic in the "when" statement shoud be: when:
- zabbix_manage_repo | default(true)
- not (zabbix_agent_docker | bool)
- ansible_os_family != "Windows" In the role zabbix_repo, the code below tries to load the Windows.yml file that do not exists in role zabbix_repo. community.zabbix/roles/zabbix_repo/tasks/main.yml Lines 7 to 8 in 28c4921
For this reason, the script still does not work for Windows Hosts. |
Yes mate, you're right. Can u open a PR? |
@david-sieg I remove some "zabbix2_*" variables. But not all. The code below is necessary because the script tries to remove old versions and need to test both zabbix agents (1 and 2). community.zabbix/roles/zabbix_agent/tasks/Windows.yml Lines 28 to 35 in 28c4921
|
That‘s ok for me, thx! |
please add merge into main and release 3.0.2 - momentary we cant install zabbix agent on windows with release 3.x |
a895a99
to
6fb2f2d
Compare
OK, this looks good to me. The only thing still needed is change fragment(s). |
I didn't understand. What do you mean by "fragments"? Do I need to change anything else? |
You need to create a file describing your changes here https://github.com/ansible-collections/community.zabbix/tree/main/changelogs/fragments Here you can read instructions about how to create changelog fragments https://docs.ansible.com/ansible/latest/community/development_process.html#creating-a-changelog-fragment |
ok...merge is done. please add tag for the new version 3.0.2 and publish to galaxy |
SUMMARY
Role zabbix_agent is not working on Windows.
ISSUE TYPE
COMPONENT NAME
Role zabbix_agent
ADDITIONAL INFORMATION