--- - name: Template Create Template zbx_template: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ template.name }}" register: created_template - set_fact: lzbx_item_applications: "{{ template.zitems | default([], True) | oo_select_keys_from_list(['applications']) | oo_flatten | unique }}" lzbx_itemprototype_applications: "{{ template.zitemprototypes | default([], True) | oo_select_keys_from_list(['applications']) | oo_flatten | unique }}" - name: Create Application zbx_application: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item }}" template_name: "{{ template.name }}" with_items: - "{{ lzbx_item_applications }}" - "{{ lzbx_itemprototype_applications }}" register: created_application when: template.zitems is defined or template.zitemprototypes is defined - name: Create Items zbx_item: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" key: "{{ item.key }}" name: "{{ item.name | default(item.key, true) }}" value_type: "{{ item.value_type | default('int') }}" data_type: "{{ item.data_type | default('decimal') }}" description: "{{ item.description | default('', True) }}" multiplier: "{{ item.multiplier | default('', True) }}" units: "{{ item.units | default('', True) }}" template_name: "{{ template.name }}" applications: "{{ item.applications }}" zabbix_type: "{{ item.zabbix_type | default('trapper') }}" interval: "{{ item.interval | default(60, True) }}" delta: "{{ item.delta | default(0, True) }}" with_items: template.zitems register: created_items when: template.zitems is defined - name: Create Triggers zbx_trigger: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item.name }}" description: "{{ item.description | default('', True) }}" dependencies: "{{ item.dependencies | default([], True) }}" expression: "{{ item.expression }}" priority: "{{ item.priority }}" url: "{{ item.url | default(None, True) }}" status: "{{ item.status | default('', True) }}" with_items: template.ztriggers when: template.ztriggers is defined - name: Create Actions zbx_action: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" state: "{{ item.state | default('present', True) }}" name: "{{ item.name }}" status: "{{ item.status | default('enabled', True) }}" escalation_time: "{{ item.escalation_time }}" conditions_filter: "{{ item.conditions_filter }}" operations: "{{ item.operations }}" with_items: template.zactions when: template.zactions is defined - name: Create Discoveryrules zbx_discoveryrule: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item.name }}" key: "{{ item.key }}" lifetime: "{{ item.lifetime }}" template_name: "{{ template.name }}" description: "{{ item.description | default('', True) }}" with_items: template.zdiscoveryrules when: template.zdiscoveryrules is defined - name: Create Item Prototypes zbx_itemprototype: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item.name }}" key: "{{ item.key }}" discoveryrule_key: "{{ item.discoveryrule_key }}" value_type: "{{ item.value_type }}" data_type: "{{ item.data_type | default('decimal') }}" template_name: "{{ template.name }}" applications: "{{ item.applications }}" description: "{{ item.description | default('', True) }}" multiplier: "{{ item.multiplier | default('', True) }}" units: "{{ item.units | default('', True) }}" interval: "{{ item.interval | default(60, True) }}" delta: "{{ item.delta | default(0, True) }}" with_items: template.zitemprototypes when: template.zitemprototypes is defined - name: Create Trigger Prototypes zbx_triggerprototype: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item.name }}" expression: "{{ item.expression }}" url: "{{ item.url | default('', True) }}" priority: "{{ item.priority | default('average', True) }}" description: "{{ item.description | default('', True) }}" with_items: template.ztriggerprototypes when: template.ztriggerprototypes is defined - name: Create Graphs zbx_graph: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item.name }}" height: "{{ item.height }}" width: "{{ item.width }}" graph_items: "{{ item.graph_items }}" with_items: template.zgraphs when: template.zgraphs is defined - name: Create Graph Prototypes zbx_graphprototype: zbx_server: "{{ server }}" zbx_user: "{{ user }}" zbx_password: "{{ password }}" name: "{{ item.name }}" height: "{{ item.height }}" width: "{{ item.width }}" graph_items: "{{ item.graph_items }}" with_items: template.zgraphprototypes when: template.zgraphprototypes is defined