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

[BUG] Register Agent for TLS directly skipped on CRE #715

Open
arthur-lbchn opened this issue Jan 23, 2025 · 0 comments
Open

[BUG] Register Agent for TLS directly skipped on CRE #715

arthur-lbchn opened this issue Jan 23, 2025 · 0 comments
Assignees
Labels
role:agent This affects the agent role

Comments

@arthur-lbchn
Copy link

Describe the bug
When running checkmk.general.agent role over Linux host, "Register Agent for TLS directly." is skipped

TASK [checkmk.general.agent : Linux: Register Agent for TLS directly.] *****************************************************************************************************************
skipping: [REDACTED] => {"changed": false, "false_condition": "__checkmk_agent_controller_binary.stat.exists | bool\nand checkmk_agent_tls | bool\nand not checkmk_agent_delegate_registration | bool\nand (__checkmk_agent_auth is defined and __checkmk_agent_auth | length)\nand not checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_registered_connections.stdout\n", "skip_reason": "Conditional result was False"}

because of the following when cause:

and not checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_registered_connections.stdout

in roles/agent/tasks/Linux.yml

- name: "{{ ansible_system }}: Register Agent for TLS directly."
  become: true
  ansible.builtin.shell: |
    cmk-agent-ctl register -H {{ checkmk_agent_host_name }} \
    -s {{ checkmk_agent_registration_server }} -i {{ checkmk_agent_registration_site }} \
    -U {{ checkmk_agent_user }} -P {{ __checkmk_agent_auth }} --trust-cert
  no_log: "{{ checkmk_agent_no_log | bool }}"
  register: __checkmk_agent_tls_state
  when: |
    __checkmk_agent_controller_binary.stat.exists | bool
    and checkmk_agent_tls | bool
    and not checkmk_agent_delegate_registration | bool
    and (__checkmk_agent_auth is defined and __checkmk_agent_auth | length)
    and not checkmk_agent_registration_server + '/' + checkmk_agent_registration_site in __checkmk_agent_registered_connections.stdout
  changed_when: "'Registration complete' in __checkmk_agent_tls_state.stdout"

This can probably be caused by "__checkmk_agent_registered_connections" not being registered in CRE due to the cmk-update-agent binary not existing, resulting in no respective file at /var/lib/check_mk_agent/cache/plugins_cmk-update-agent.cache:

TASK [checkmk.general.agent : Linux: Read Updater State.] ******************************************************************************************************************************
ok: [REDACTED] => {"changed": false, "cmd": ["cat", "/var/lib/check_mk_agent/cache/plugins_cmk-update-agent.cache"], "delta": "0:00:00.005868", "end": "2025-01-23 13:37:59.456444", "failed_when_result": false, "msg": "non-zero return code", "rc": 1, "start": "2025-01-23 13:37:59.450576", "stderr": "cat: /var/lib/check_mk_agent/cache/plugins_cmk-update-agent.cache: No such file or directory", "stderr_lines": ["cat: /var/lib/check_mk_agent/cache/plugins_cmk-update-agent.cache: No such file or directory"], "stdout": "", "stdout_lines": []

As soon as the reported when cause is removed from the file, the agent is registered just fine:

TASK [checkmk.general.agent : Linux: Register Agent for TLS directly.] *****************************************************************************************************************
changed: [REDACTED] => {"changed": true, "cmd": "cmk-agent-ctl register -H REDACTED -s REDACTED -i monitoring -U automation -P REDACTED --trust-cert\n", "delta": "0:00:01.650492", "end": "2025-01-23 13:54:36.269936", "msg": "", "rc": 0, "start": "2025-01-23 13:54:34.619444", "stderr": "", "stderr_lines": [], "stdout": "Registration complete.", "stdout_lines": ["Registration complete."]}

Component Name

Component Name: registration

Ansible Version

$ ansible --version
ansible [core 2.16.7]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/arthur/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /home/arthur/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Checkmk Version and Edition

2.3.0p24 (CRE)

Collection Version

$ ansible-galaxy collection list
Collection                               Version
---------------------------------------- -------
checkmk.general                          5.4.0  

To Reproduce
Steps to reproduce the behavior:
Run checkmk.general.agent over a Linux-based host.

Expected behavior
Agent TLS registartion passed

Actual behavior
Agent TLS registartion skipped

Minimum reproduction example

Additional context

Configuration:

---
checkmk_agent_version: "2.3.0p24"
checkmk_agent_edition: "cre"
checkmk_agent_server_protocol: 'https'
checkmk_agent_server: 'REDACTED'
checkmk_agent_site: 'monitoring'
checkmk_agent_registration_server_protocol: "{{ checkmk_agent_server_protocol }}"
checkmk_agent_registration_server: "{{ checkmk_agent_server }}"
checkmk_agent_registration_site: "{{ checkmk_agent_site }}"
checkmk_agent_server_validate_certs: 'true'
checkmk_agent_server_port: "{% if checkmk_agent_server_protocol == 'https' %}443{% else %}80{% endif %}"
checkmk_agent_user: 'automation' 
checkmk_agent_port: '6556'
checkmk_agent_secret: 'REDACTED'
checkmk_agent_auto_activate: 'true'
checkmk_agent_add_host: 'true'
checkmk_agent_discover: 'true'
checkmk_agent_discover_max_parallel_tasks: '5'
checkmk_agent_force_foreign_changes: 'false'
checkmk_agent_update: 'true'
checkmk_agent_tls: 'true'
checkmk_agent_configure_firewall: 'false'
checkmk_agent_configure_firewall_zone: 'public'
checkmk_agent_server_ips: []
checkmk_agent_force_install: 'false'
checkmk_agent_prep_legacy: 'false'
checkmk_agent_delegate_api_calls: 'localhost'
checkmk_agent_delegate_download: "{{ inventory_hostname }}"
checkmk_agent_delegate_registration: 'false'
checkmk_agent_delegate_registration_target: "{{ inventory_hostname }}"
checkmk_agent_host_name: "{{ inventory_hostname }}"
checkmk_agent_host_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
checkmk_agent_folder: "{{ checkmk_var_folder_path | default('/') }}"
checkmk_agent_host_attributes:
  ipaddress: "{{ checkmk_agent_host_ip | default(omit) }}"
checkmk_agent_mode: 'pull'
checkmk_agent_no_log: 'false'
@arthur-lbchn arthur-lbchn added the bug Something isn't working label Jan 23, 2025
@robin-checkmk robin-checkmk added the role:agent This affects the agent role label Jan 27, 2025
@robin-checkmk robin-checkmk removed the bug Something isn't working label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
role:agent This affects the agent role
Projects
None yet
Development

No branches or pull requests

2 participants