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

community.zabbix.zabbix_inventory - User credentials required when using auth_token #1348

Open
erichoog opened this issue Jul 19, 2024 · 0 comments
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module

Comments

@erichoog
Copy link
Contributor

SUMMARY

When using community.zabbix.zabbix_inventory you have to create a zabbix_inventory.yml

In zabbix_inventory.yml, you should be able to only provide auth_token without requiring login_user and login_password to be set.

Currently, regardless if the auth_token is set, the login_user and login_password are required. Otherwise, inventory collection will fail to produce results. If you provide dummy values for login_user and login_password values then this will work.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.zabbix.zabbix_inventory

ANSIBLE VERSION
(myenv) ➜  /workdir ansible --version
ansible [core 2.16.9]
  config file = /workdir/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /workdir/myenv/lib/python3.12/site-packages/ansible
  ansible collection location = /workdir/collections:/root/.ansible/collections:/usr/share/ansible/collections
  executable location = /workdir/myenv/bin/ansible
  python version = 3.12.4 (main, Jun  7 2024, 00:00:00) [GCC 14.1.1 20240607 (Red Hat 14.1.1-5)] (/workdir/myenv/bin/python)
  jinja version = 3.1.4
  libyaml = True
CONFIGURATION
(myenv) ➜  /workdir ansible-config dump --only-changed
COLLECTIONS_PATHS(/workdir/ansible.cfg) = ['/workdir/collections', '/root/.ansible/collections', '/usr/share/ansible/collections']
CONFIG_FILE() = /workdir/ansible.cfg
DEFAULT_STDOUT_CALLBACK(/workdir/ansible.cfg) = debug
PAGER(env: PAGER) = less
OS / ENVIRONMENT / Zabbix Version

Target zabbix server is from the docker-compose.yml in the project dir
Version: 6.0

STEPS TO REPRODUCE

Create the zabbix_inventory.yml file with the contents listed below. Only auth_token is set and login_user and login_password are commented out.

Note: Below I am using an env var ZABBIX_API_KEY but it is the same issue if you add the API key in clear text as well.

plugin: community.zabbix.zabbix_inventory
server_url: http://127.0.0.1:8080
auth_token: "{{ lookup('ansible.builtin.env', 'ZABBIX_API_KEY') }}"
#login_user: Admin
#login_password: zabbix
host_zapi_query:
  selectApplications: ['name', 'applicationid']
  selectParentTemplates: ['name']
  selectGroups: ['name']
validate_certs: false
EXPECTED RESULTS

When only auth_token is provided and login_user and login_password are omitted then the inventory plugin should work and provide the same results as if login_user and login_password were provided instead of failing.

ACTUAL RESULTS

Does not work when using only auth_token in zabbix_inventory.yml file. Even when using auth_token, you must provide a dummy login_user and login_password value to prevent this error.

(myenv) ➜  /workdir ansible-inventory --list all -i zabbix_inventory.yml
[WARNING]:  * Failed to parse /workdir/zabbix_inventory.yml with auto plugin: No setting was provided for required configuration plugin_type: inventory plugin:
ansible_collections.community.zabbix.plugins.inventory.zabbix_inventory setting: login_user
[WARNING]:  * Failed to parse /workdir/zabbix_inventory.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /workdir/zabbix_inventory.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port.
[WARNING]: Unable to parse /workdir/zabbix_inventory.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    }
}
@pyrodie18 pyrodie18 added bug Something isn't working module The issue or pull request is related to Zabbix module labels Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module
Projects
None yet
Development

No branches or pull requests

2 participants