zabbix: remove set_facts, add vars to each api call

Signed-off-by: David Kirwan <davidkirwanirl@gmail.com>
This commit is contained in:
David Kirwan 2024-02-20 16:43:51 +00:00
parent 725498464f
commit efa7047d3b
No known key found for this signature in database
GPG key ID: A5893AB6474AC37D
7 changed files with 37 additions and 16 deletions

View file

@ -29,7 +29,7 @@
- rkhunter
- nagios_client
- zabbix/zabbix_agent
# - zabbix/zabbix_templates
- zabbix/zabbix_templates
- collectd/base
- sudo
- role: keytab/service

View file

@ -91,7 +91,6 @@
name: "rawhide"
gid: 265
state: present
local: true
# rawhide user 265
- name: add rawhide user
@ -103,7 +102,6 @@
create_home: false
comment: "rawhide compose account"
state: present
local: true
- name: make a bunch of dirs
file: state=directory path={{ item }}

View file

@ -8,3 +8,12 @@
with_items: "{{ zabbix_templates }}"
tags:
- zabbix_add_hosts_to_hostgroups
vars:
ansible_zabbix_auth_key: "{{ (env == 'staging')|ternary(zabbix_stg_apikey, zabbix_apikey) }}"
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_host: "{{ (env == 'staging')|ternary(zabbix_stg_hostname, zabbix_hostname) }}"
ansible_zabbix_url_path: "" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu

View file

@ -8,3 +8,12 @@
with_items: "{{ zabbix_templates }}"
tags:
- zabbix_add_templates_to_hosts
vars:
ansible_zabbix_auth_key: "{{ (env == 'staging')|ternary(zabbix_stg_apikey, zabbix_apikey) }}"
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_host: "{{ (env == 'staging')|ternary(zabbix_stg_hostname, zabbix_hostname) }}"
ansible_zabbix_url_path: "" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu

View file

@ -8,3 +8,12 @@
run_once: True
tags:
- zabbix_hostgroups
vars:
ansible_zabbix_auth_key: "{{ (env == 'staging')|ternary(zabbix_stg_apikey, zabbix_apikey) }}"
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_host: "{{ (env == 'staging')|ternary(zabbix_stg_hostname, zabbix_hostname) }}"
ansible_zabbix_url_path: "" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu

View file

@ -1,17 +1,4 @@
---
- name: Set API token
tags: always
set_fact:
ansible_zabbix_auth_key: "{{ (env == 'staging')|ternary(zabbix_stg_apikey, zabbix_apikey) }}"
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_host: "{{ (env == 'staging')|ternary(zabbix_stg_hostname, zabbix_hostname) }}"
ansible_zabbix_url_path: "" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
- include_tasks: hostgroups.yml
tags:
- zabbix_hostgroups

View file

@ -19,3 +19,12 @@
with_items: "{{ zabbix_templates }}" # Templates specific to an ansible group, can be overwridden in inventory/group_vars/group_name
tags:
- zabbix_templates
vars:
ansible_zabbix_auth_key: "{{ (env == 'staging')|ternary(zabbix_stg_apikey, zabbix_apikey) }}"
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_host: "{{ (env == 'staging')|ternary(zabbix_stg_hostname, zabbix_hostname) }}"
ansible_zabbix_url_path: "" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu