Skip to content

Commit

Permalink
Move the autopsk variable tasks before setting variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Thulium-Drake committed Oct 7, 2024
1 parent ceff9d3 commit e593843
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions roles/zabbix_agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@
- name: Load Appropriate Defaults
ansible.builtin.include_vars: "agent{{ '2' if zabbix_agent2 is defined and zabbix_agent2|bool }}_vars.yml"

- block:
- name: AutoPSK | Default tlsconnect to enforce PSK
ansible.builtin.set_fact:
zabbix_agent_tlsconnect: psk

- name: AutoPSK | Default tlsaccept to enforce PSK when zabbix_agent_tlsaccept is not defined
ansible.builtin.set_fact:
zabbix_agent_tlsaccept: psk
when: not zabbix_agent_tlsaccept is defined

- name: AutoPSK | Default tlsaccept to enforce PSK when zabbix_agent_tlsaccept is defined
ansible.builtin.set_fact:
zabbix_agent_tlsaccept: "{{ 'psk,' + zabbix_agent_tlsaccept }}"
when:
- zabbix_agent_tlsaccept is defined
- not 'psk' in zabbix_agent_tlsaccept

when: zabbix_agent_tlspsk_auto | bool
tags:
- config

- name: Set Variables
ansible.builtin.set_fact:
zabbix_agent_include_dir: "{{ zabbix_agent_include_dir is defined | ternary(zabbix_agent_include_dir, _include) }}"
Expand Down Expand Up @@ -57,27 +78,6 @@
when:
- not (zabbix_agent_docker | bool)

- block:
- name: AutoPSK | Default tlsconnect to enforce PSK
ansible.builtin.set_fact:
zabbix_agent_tlsconnect: psk

- name: AutoPSK | Default tlsaccept to enforce PSK when zabbix_agent_tlsaccept is not defined
ansible.builtin.set_fact:
zabbix_agent_tlsaccept: psk
when: not zabbix_agent_tlsaccept is defined

- name: AutoPSK | Default tlsaccept to enforce PSK when zabbix_agent_tlsaccept is defined
ansible.builtin.set_fact:
zabbix_agent_tlsaccept: "{{ 'psk,' + zabbix_agent_tlsaccept }}"
when:
- zabbix_agent_tlsaccept is defined
- not 'psk' in zabbix_agent_tlsaccept

when: zabbix_agent_tlspsk_auto | bool
tags:
- config

- name: Configure PSK
when: "( 'psk' in zabbix_agent_tlsaccept ) or (zabbix_agent_tlsconnect == 'psk')"
block:
Expand Down

0 comments on commit e593843

Please sign in to comment.