From bf5dcd8edb37ff670d5137872d4b7ae0ba6101ed Mon Sep 17 00:00:00 2001 From: David Kirwan Date: Mon, 12 Feb 2024 13:53:54 +0000 Subject: [PATCH] zabbix: set releng_compose_stg zabbix_templates to empty list add zabbix hostgroup create task Signed-off-by: David Kirwan --- inventory/group_vars/releng_compose | 4 +++- inventory/group_vars/releng_compose_stg | 3 ++- roles/zabbix/zabbix_templates/tasks/hostgroups.yml | 9 +++++++++ roles/zabbix/zabbix_templates/tasks/main.yml | 13 +++++++++++++ roles/zabbix/zabbix_templates/tasks/templates.yml | 12 ------------ 5 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 roles/zabbix/zabbix_templates/tasks/hostgroups.yml diff --git a/inventory/group_vars/releng_compose b/inventory/group_vars/releng_compose index 164a61d055..e686ab9b2a 100644 --- a/inventory/group_vars/releng_compose +++ b/inventory/group_vars/releng_compose @@ -54,4 +54,6 @@ num_cpus: 16 primary_auth_source: ipa virt_install_command: "{{ virt_install_command_two_nic_unsafe }}" zabbix_templates: - - zabbix_templates/releng_compose_cronjobs.json + - "zabbix_templates/releng_compose_cronjobs.json" +zabbix_hostgroups: + - "fedora releng compose" diff --git a/inventory/group_vars/releng_compose_stg b/inventory/group_vars/releng_compose_stg index c559fd78f1..7b2ff99988 100644 --- a/inventory/group_vars/releng_compose_stg +++ b/inventory/group_vars/releng_compose_stg @@ -11,4 +11,5 @@ koji_weburl: "https://koji.stg.fedoraproject.org/koji" mem_size: 8192 nfs_mount_opts: "rw,hard,bg,intr,noatime,nodev,nosuid,sec=sys,nfsvers=3" num_cpus: 4 -zabbix_templates: "{{ default([]) }}" +zabbix_templates: "{{ [] }}" +zabbix_hostgroups: "{{ [] }}" diff --git a/roles/zabbix/zabbix_templates/tasks/hostgroups.yml b/roles/zabbix/zabbix_templates/tasks/hostgroups.yml new file mode 100644 index 0000000000..698f071061 --- /dev/null +++ b/roles/zabbix/zabbix_templates/tasks/hostgroups.yml @@ -0,0 +1,9 @@ +--- +- name: Create host groups + # set task level variables as we change ansible_connection plugin here + community.zabbix.zabbix_group: + state: present + host_groups: "{{ item }}" + with_items: "{{ zabbix_hostgroups }}" # Hostgroups specific to an ansible group can be overridden in inventory/group_vars/group_name + tags: + - zabbix_hostgroups diff --git a/roles/zabbix/zabbix_templates/tasks/main.yml b/roles/zabbix/zabbix_templates/tasks/main.yml index 677848d71b..17f1db7a41 100644 --- a/roles/zabbix/zabbix_templates/tasks/main.yml +++ b/roles/zabbix/zabbix_templates/tasks/main.yml @@ -1,4 +1,17 @@ --- +- 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:///zabbixeu + + - include_tasks: templates.yml tags: - zabbix_templates diff --git a/roles/zabbix/zabbix_templates/tasks/templates.yml b/roles/zabbix/zabbix_templates/tasks/templates.yml index 93d78c7867..38279013fb 100644 --- a/roles/zabbix/zabbix_templates/tasks/templates.yml +++ b/roles/zabbix/zabbix_templates/tasks/templates.yml @@ -1,16 +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:///zabbixeu - #- name: Get Zabbix template as JSON # community.zabbix.zabbix_template_info: # template_name: fedora releng compose cronjobs