Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply the same logic of renaming parameters #495

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions docs/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ use the new ones.

The following properties are renamed in the `zabbix_agent` role.

| From | To |
|----------------------------|---------------------------------|
| zabbix_server_url | zabbix_api_server_url |
| zabbix_http_user | zabbix_api_http_user |
| zabbix_http_password | zabbix_api_http_password |
| zabbix_login_user | zabbix_api_login_user |
| zabbix_login_pass | zabbix_api_login_pass |
| From | To |
|-------------------------------|-------------------------------|
| zabbix_url | zabbix_api_server_url |
| zabbix_agent_server_url | zabbix_api_server_url |
| zabbix_http_user | zabbix_api_http_user |
| zabbix_http_password | zabbix_api_http_password |
| zabbix_api_user | zabbix_api_login_user |
| zabbix_api_pass | zabbix_api_login_pass |
| zabbix_validate_certs | zabbix_api_validate_certs |
| zabbix_create_hostgroup | zabbix_agent_hostgroups_state |
| zabbix_macros | zabbix_agent_macros |
| zabbix_inventory_mode | zabbix_agent_inventory_mode |
| zabbix_link_templates | zabbix_agent_link_templates |
| zabbix_proxy | zabbix_agent_proxy |
| zabbix_update_host | zabbix_agent_host_update |
| zabbix_create_host | zabbix_agent_host_state |
| zabbix_visible_hostname | zabbix_agent_visible_hostname |

NOTE: the old parameters are still valid but it's suggested to update to use the
new ones.
Expand All @@ -63,11 +73,13 @@ The following properties are renamed in the `zabbix_proxy` role.
| zabbix_server_port | zabbix_proxy_serverport |
| zabbix_proxy_localbuffer | zabbix_proxy_proxylocalbuffer |
| zabbix_proxy_offlinebuffer | zabbix_proxy_proxyofflinebuffer |
| zabbix_server_url | zabbix_api_server_url |
| zabbix_create_proxy | zabbix_proxy_state |
| zabbix_url | zabbix_api_server_url |
| zabbix_http_user | zabbix_api_http_user |
| zabbix_http_password | zabbix_api_http_password |
| zabbix_login_user | zabbix_api_login_user |
| zabbix_login_pass | zabbix_api_login_pass |
| zabbix_api_user | zabbix_api_login_user |
| zabbix_api_pass | zabbix_api_login_pass |
| zabbix_validate_certs | zabbix_api_validate_certs |

NOTE: the old parameters are still valid but it's suggested to update to use the
new ones.
Expand Down
32 changes: 16 additions & 16 deletions docs/ZABBIX_AGENT_ROLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,21 @@ When `zabbix_api_create_hostgroup` or `zabbix_api_create_hosts` is set to `True`
* `zabbix_api_server_url`: The url on which the Zabbix webpage is available. Example: http://zabbix.example.com
* `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth
* `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth
* `zabbix_api_create_hosts`: Default: `False`. When you want to enable the Zabbix API to create/delete the host. This has to be set to `True` if you want to make use of `zabbix_create_host`.
* `zabbix_api_create_hostgroup`: When you want to enable the Zabbix API to create/delete the hostgroups. This has to be set to `True` if you want to make use of `zabbix_create_hostgroup`.Default: `False`
* `zabbix_api_create_hosts`: Default: `False`. When you want to enable the Zabbix API to create/delete the host. This has to be set to `True` if you want to make use of `zabbix_agent_host_state`.
* `zabbix_api_create_hostgroup`: When you want to enable the Zabbix API to create/delete the hostgroups. This has to be set to `True` if you want to make use of `zabbix_agent_hostgroups_state`.Default: `False`
* `zabbix_api_login_user`: Username of user which has API access.
* `zabbix_api_login_pass`: Password for the user which has API access.
* `zabbix_create_hostgroup`: present (Default) if the hostgroup needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_hostgroup` is set to `True`.
* `zabbix_agent_hostgroups_state`: present (Default) if the hostgroup needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_hostgroup` is set to `True`.
* `zabbix_host_status`: enabled (Default) when host in monitored, disabled when host is disabled for monitoring.
* `zabbix_create_host`: present (Default) if the host needs to be created or absent is you want to delete it. This only works when `zabbix_api_create_hosts` is set to `True`.
* `zabbix_update_host`: yes (Default) if the host should be updated if already present. This only works when `zabbix_api_create_hosts` is set to `True`.
* `zabbix_agent_host_state`: present (Default) if the host needs to be created or absent is you want to delete it. This only works when `zabbix_api_create_hosts` is set to `True`.
* `zabbix_agent_host_update`: yes (Default) if the host should be updated if already present. This only works when `zabbix_api_create_hosts` is set to `True`.
* `zabbix_useuip`: 1 if connection to zabbix-agent is made via ip, 0 for fqdn.
* `zabbix_host_groups`: A list of hostgroups which this host belongs to.
* `zabbix_link_templates`: A list of templates which needs to be link to this host. The templates should exist.
* `zabbix_macros`: A list with macro_key and macro_value for creating hostmacro's.
* `zabbix_inventory_mode`: Configure Zabbix inventory mode. Needed for building inventory data, manually when configuring a host or automatically by using some automatic population options. This has to be set to `automatic` if you want to make automatically building inventory data.
* `zabbix_visible_hostname` : Configure Zabbix visible name inside Zabbix web UI for the node.
* `zabbix_validate_certs` : yes (Default) if we need to validate tls certificates of the API. Use `no` in case self-signed certificates are used
* `zabbix_agent_link_templates`: A list of templates which needs to be link to this host. The templates should exist.
* `zabbix_agent_macros`: A list with macro_key and macro_value for creating hostmacro's.
* `zabbix_agent_inventory_mode`: Configure Zabbix inventory mode. Needed for building inventory data, manually when configuring a host or automatically by using some automatic population options. This has to be set to `automatic` if you want to make automatically building inventory data.
* `zabbix_agent_visible_hostname` : Configure Zabbix visible name inside Zabbix web UI for the node.
* `zabbix_api_validate_certs` : yes (Default) if we need to validate tls certificates of the API. Use `no` in case self-signed certificates are used
* `zabbix_agent_description`: Description of the host in Zabbix.
* `zabbix_agent_inventory_zabbix`: Adds Facts for a zabbix inventory

Expand Down Expand Up @@ -429,13 +429,13 @@ Including an example of how to use your role (for instance, with variables passe
zabbix_api_use: true # use zabbix_api_create_hosts and/or zabbix_api_create_hostgroup from 0.8.0
zabbix_api_login_user: Admin
zabbix_api_login_pass: zabbix
zabbix_create_host: present
zabbix_agent_host_state: present
zabbix_host_groups:
- Linux Servers
zabbix_link_templates:
zabbix_agent_link_templates:
- Template OS Linux
- Apache APP Template
zabbix_macros:
zabbix_agent_macros:
- macro_key: apache_type
macro_value: reverse_proxy
```
Expand All @@ -450,13 +450,13 @@ You can also use the group_vars or the host_vars files for setting the variables
zabbix_api_use: true # use zabbix_api_create_hosts and/or zabbix_api_create_hostgroup from 0.8.0
zabbix_api_login_user: Admin
zabbix_api_login_pass: zabbix
zabbix_create_host: present
zabbix_agent_host_state: present
zabbix_host_groups:
- Linux Servers
zabbix_link_templates:
zabbix_agent_link_templates:
- Template OS Linux
- Apache APP Template
zabbix_macros:
zabbix_agent_macros:
- macro_key: apache_type
macro_value: reverse_proxy
```
Expand Down
4 changes: 2 additions & 2 deletions docs/ZABBIX_PROXY_ROLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ When `zabbix_api_create_proxy` is set to `True`, it will install on the host exe
* `zabbix_api_server_url`: The url on which the Zabbix webpage is available. Example: http://zabbix.example.com
* `zabbix_api_http_user`: The http user to access zabbix url with Basic Auth
* `zabbix_api_http_password`: The http password to access zabbix url with Basic Auth
* `zabbix_api_create_proxy`: When you want to enable the Zabbix API to create/delete the proxy. This has to be set to `True` if you want to make use of `zabbix_create_proxy`. Default: `False`
* `zabbix_api_create_proxy`: When you want to enable the Zabbix API to create/delete the proxy. This has to be set to `True` if you want to make use of `zabbix_proxy_state`. Default: `False`
* `zabbix_api_login_user`: Username of user which has API access.
* `zabbix_api_login_pass`: Password for the user which has API access.
* `zabbix_create_proxy`: present (Default) if the proxy needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_proxy` is set to `True`.
* `zabbix_proxy_state`: present (Default) if the proxy needs to be created or absent if you want to delete it. This only works when `zabbix_api_create_proxy` is set to `True`.
* `zabbix_proxy_status`: active (Default) if the proxy needs to be active or passive.
* `zabbix_api_timeout`: timeout for API calls (default to 30 seconds)

Expand Down
24 changes: 18 additions & 6 deletions roles/zabbix_agent/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ zabbix_repo_yum:
state: present

# Zabbix API stuff
zabbix_validate_certs: true # Will be deprecated in 2.0.0
zabbix_api_validate_certs: "{{ zabbix_validate_certs }}"
zabbix_agent_server_url: http://localhost # Will be deprecated in 2.0.0
zabbix_url: "{{ zabbix_agent_server_url }}" # Will be deprecated in 2.0.0
zabbix_api_server_url: "{{ zabbix_agent_server_url }}"
# zabbix_http_user: admin # Will be deprecated in 2.0.0
# zabbix_http_password: admin # Will be deprecated in 2.0.0
# zabbix_api_http_user: admin
# zabbix_api_http_password: admin
zabbix_api_user: Admin # Will be deprecated in 2.0.0
Expand All @@ -76,17 +80,23 @@ zabbix_api_login_pass: "{{ zabbix_api_pass }}"
zabbix_api_create_hostgroup: false
zabbix_api_create_hosts: false
zabbix_api_timeout: 30
zabbix_create_hostgroup: present # or absent
zabbix_create_host: present # or absent
zabbix_update_host: true
zabbix_create_hostgroup: present # or absent # Will be deprecated in 2.0.0
zabbix_agent_hostgroups_state: "{{ zabbix_create_hostgroup }}"
zabbix_create_host: present # or absent # Will be deprecated in 2.0.0
zabbix_agent_host_state: "{{ zabbix_create_host }}"
zabbix_update_host: true # Will be deprecated in 2.0.0
zabbix_agent_host_update: "{{ zabbix_update_host }}"
zabbix_host_status: enabled # or disabled
zabbix_proxy: null
zabbix_inventory_mode: disabled
zabbix_proxy: null # Will be deprecated in 2.0.0
zabbix_agent_proxy: "{{ zabbix_proxy }}"
zabbix_inventory_mode: disabled # Will be deprecated in 2.0.0
zabbix_agent_inventory_mode: "{{ zabbix_inventory_mode }}"
zabbix_useuip: 1
zabbix_host_groups:
- Linux servers
zabbix_link_templates:
zabbix_link_templates: # Will be deprecated in 2.0.0
- Template OS Linux by Zabbix agent
zabbix_agent_link_templates: "{{ zabbix_link_templates }}"

zabbix_agent_interfaces:
- type: 1
Expand Down Expand Up @@ -141,6 +151,8 @@ zabbix_agent_loadmodule:
zabbix_agent_become_on_localhost: true
zabbix_agent_description:
zabbix_agent_inventory_zabbix: {}
zabbix_macros: [] # Will be deprecated in 2.0.0
zabbix_agent_macros: "{{ zabbix_macros }}"

# TLS settings
zabbix_agent_tlsconnect:
Expand Down
60 changes: 30 additions & 30 deletions roles/zabbix_agent/tasks/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
- zabbix_install_pip_packages | bool
- (zabbix_api_create_hostgroup | bool) or (zabbix_api_create_hosts | bool)

- name: "API | Create hostgroups"
- name: "API | Create host groups"
zabbix_group:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(omit) }}"
http_login_password: "{{ zabbix_api_http_password | default(omit) }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_group: "{{ zabbix_host_groups }}"
state: "{{ zabbix_create_hostgroup }}"
validate_certs: "{{ zabbix_validate_certs|default(omit) }}"
state: "{{ zabbix_agent_hostgroups_state }}"
validate_certs: "{{ zabbix_api_validate_certs|default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
when:
- zabbix_api_create_hostgroup | bool
Expand All @@ -36,27 +36,27 @@
- name: "API | Create a new host or update an existing host's info"
zabbix_host:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(omit) }}"
http_login_password: "{{ zabbix_api_http_password | default(omit) }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_name: "{{ zabbix_agent_hostname }}"
host_groups: "{{ zabbix_host_groups }}"
link_templates: "{{ zabbix_link_templates }}"
link_templates: "{{ zabbix_agent_link_templates }}"
status: "{{ zabbix_host_status }}"
state: "{{ zabbix_create_host }}"
force: "{{ zabbix_update_host }}"
proxy: "{{ zabbix_proxy }}"
inventory_mode: "{{ zabbix_inventory_mode }}"
state: "{{ zabbix_agent_host_state }}"
force: "{{ zabbix_agent_host_update }}"
proxy: "{{ zabbix_agent_proxy }}"
inventory_mode: "{{ zabbix_agent_inventory_mode }}"
interfaces: "{{ zabbix_agent_interfaces }}"
visible_name: "{{ zabbix_visible_hostname | default(zabbix_agent_hostname) }}"
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}"
tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}"
tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}"
tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}"
tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}"
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}"
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}"
validate_certs: "{{ zabbix_validate_certs | default(omit) }}"
validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
description: "{{ zabbix_agent_description | default(omit) }}"
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
Expand All @@ -77,27 +77,27 @@
- name: "API | Create a new host using agent2 or update an existing host's info"
zabbix_host:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(omit) }}"
http_login_password: "{{ zabbix_api_http_password | default(omit) }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_name: "{{ zabbix_agent_hostname }}"
host_name: "{{ zabbix_agent2_hostname }}"
host_groups: "{{ zabbix_host_groups }}"
link_templates: "{{ zabbix_link_templates }}"
link_templates: "{{ zabbix_agent_link_templates }}"
status: "{{ zabbix_host_status }}"
state: "{{ zabbix_create_host }}"
force: "{{ zabbix_update_host }}"
proxy: "{{ zabbix_proxy }}"
inventory_mode: "{{ zabbix_inventory_mode }}"
state: "{{ zabbix_agent_host_state }}"
force: "{{ zabbix_agent_host_update }}"
proxy: "{{ zabbix_agent_proxy }}"
inventory_mode: "{{ zabbix_agent_inventory_mode }}"
interfaces: "{{ zabbix_agent_interfaces }}"
visible_name: "{{ zabbix_visible_hostname | default(zabbix_agent_hostname) }}"
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent2_hostname) }}"
tls_psk: "{{ zabbix_agent2_tlspsk_secret | default(omit) }}"
tls_psk_identity: "{{ zabbix_agent2_tlspskidentity | default(omit) }}"
tls_issuer: "{{ zabbix_agent2_tlsservercertissuer | default(omit) }}"
tls_subject: "{{ zabbix_agent2_tls_subject | default(omit) }}"
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsaccept if zabbix_agent2_tlsaccept else 'unencrypted'] }}"
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsconnect if zabbix_agent2_tlsconnect else 'unencrypted'] }}"
validate_certs: "{{ zabbix_validate_certs | default(omit) }}"
validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
description: "{{ zabbix_agent_description | default(omit) }}"
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
Expand All @@ -118,18 +118,18 @@
- name: "API | Updating host configuration with macros"
zabbix_hostmacro:
server_url: "{{ zabbix_api_server_url }}"
http_login_user: "{{ zabbix_api_http_user | default(omit) }}"
http_login_password: "{{ zabbix_api_http_password | default(omit) }}"
http_login_user: "{{ zabbix_api_http_user | default(zabbix_http_user | default(omit)) }}"
http_login_password: "{{ zabbix_api_http_password | default(zabbix_http_password | default(omit)) }}"
login_user: "{{ zabbix_api_login_user }}"
login_password: "{{ zabbix_api_login_pass }}"
host_name: "{{ zabbix_agent_hostname }}"
host_name: "{{ (zabbix_agent2 | bool) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname) }}"
macro_name: "{{ item.macro_key }}"
macro_value: "{{ item.macro_value }}"
validate_certs: "{{ zabbix_validate_certs | default(omit) }}"
validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
timeout: "{{ zabbix_api_timeout }}"
with_items: "{{ zabbix_macros | default([]) }}"
with_items: "{{ zabbix_agent_macros | default([]) }}"
when:
- zabbix_macros is defined
- zabbix_agent_macros is defined
- item.macro_key is defined
register: zabbix_api_hostmarcro_created
until: zabbix_api_hostmarcro_created is succeeded
Expand Down
4 changes: 2 additions & 2 deletions roles/zabbix_agent/tasks/tlspsk_auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
- name: AutoPSK | Generate new TLS PSK identity
set_fact:
zabbix_agent_tlspskidentity: >
zabbix_visible_hostname
| default(zabbix_agent_hostname)
zabbix_agent_visible_hostname
| ((zabbix_agent2 == True) | default(ternary(zabbix_agent2_hostname, zabbix_agent_hostname)))
+ '_'
+ lookup('password', '/dev/null chars=hexdigits length=4')
when: not zabbix_agent_tlspskidentity_check.stat.exists
Expand Down
4 changes: 2 additions & 2 deletions roles/zabbix_agent/tasks/tlspsk_auto_agent2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
- name: AutoPSK | Generate new TLS PSK identity
set_fact:
zabbix_agent2_tlspskidentity: >
zabbix_visible_hostname
| default(zabbix_agent_hostname)
zabbix_agent_visible_hostname
| ((zabbix_agent2 == True) | default(ternary(zabbix_agent2_hostname, zabbix_agent_hostname)))
+ '_'
+ lookup('password', '/dev/null chars=hexdigits length=4')
when: not zabbix_agent2_tlspskidentity_check.stat.exists
Expand Down
Loading