Skip to content

Commit

Permalink
added certificate data extraction in zabbix agent role
Browse files Browse the repository at this point in the history
  • Loading branch information
atocko committed Aug 28, 2023
1 parent d538bd6 commit e59b026
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions roles/zabbix_agent/tasks/host.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
### Extract cert data for host: requires openssl installation on
- name: 'Prepare certificate data'

Check failure on line 2 in roles/zabbix_agent/tasks/host.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

key-order[task]

You can improve the task key order to: name, when, tags, block
when: >-
(param_tlsconnect == "cert" or "cert" in param_tlsaccept)
and source_tlscertfile is defined
and certificate_extract_data is defined and certificate_extract_data
block:
- name: Get certificate info

Check failure on line 8 in roles/zabbix_agent/tasks/host.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

deprecated-local-action

Do not use 'local_action', use 'delegate_to: localhost'.
local_action: ansible.builtin.command openssl x509 -in {{ source_tlscertfile }} -noout --subject --issuer
changed_when: false
register: zabbix_agent_cert_data
- name: 'SET FACT : Certificate issuer and subject'
ansible.builtin.set_fact:
zabbix_host_tls_issuer: '{{ zabbix_agent_cert_data.stdout | regex_search("issuer=(.*)$", "\1", multiline=True) | first | replace(" ", "") }}'

Check warning on line 14 in roles/zabbix_agent/tasks/host.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

jinja[spacing]

Jinja2 spacing could be improved: {{ zabbix_agent_cert_data.stdout| regex_search("subject=(.*)$", "\1", multiline=True) | first | replace(" ", "") }} -> {{ zabbix_agent_cert_data.stdout | regex_search("subject=(.*)$", "\1", multiline=True) | first | replace(" ", "") }}
zabbix_host_tls_subject: '{{ zabbix_agent_cert_data.stdout| regex_search("subject=(.*)$", "\1", multiline=True) | first | replace(" ", "") }}'
tags: [host]

### Compone list of unique hostgroup names from all hosts, that reached this taks without failures.
- name: 'Prepare hostgroups block'
when: >-
Expand Down

0 comments on commit e59b026

Please sign in to comment.