Open enidvx opened 10 months ago
Hi @enidvx
Can you please provide your members
variable (anonymized)?
Do you know which user/item of the list is affected?
As I understand it, the problem is that the target user doesn't have an email address. But how is that possible? :D
Hi @Nemental These are some of the vars that are used to loop on users list:
'uid': 'username',
'description': 'User Name',
'email': 'user.name@whatever.com',
'password': 'hashed_passwd'
From all the config all vars seem to be fine because this used to work on another older instance of grafana and community.grafana.
Hey @enidvx I'm sorry but I can't recreate this... I tried several things, even edited the Grafana database manually but without success.
I even tested it with grafana version 10.2.0
which according to the community.grafana
Readme is the last supported version and I do get the exact same error:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'get'
fatal: [grafana-1.domain.io]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 107, in <module>\n File \"<stdin>\", line 99, in _ansiballz_main\n File \"<stdin>\", line 47, in invoke_module\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_community.grafana.grafana_user_payload_ed5er12q/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 304, in <module>\n File \"/tmp/ansible_community.grafana.grafana_user_payload_ed5er12q/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 286, in main\n File \"/tmp/ansible_community.grafana.grafana_user_payload_ed5er12q/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 232, in is_user_update_required\nAttributeError: 'NoneType' object has no attribute 'get'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
I even tested with and without mitogen enabled (strategy: linear
, and strategy: mitogen_linear
)
with the same error :disappointed:
Hello,
I have the same issue when creating or updating new users. I have a fresh install of grafana 9.2.20, but I'm using the PMM version and I don't know if it is related.
Ansible 9.3.0 Ansible-core 2.16.4 community.grafana 1.8.0
I tried again with the latest versions and also a fresh install in hope to have some fix but unfortunately again the same output:
community.grafana 1.8.0
grafana version 10.2.2
ansible==8.6.0
ansible-core==2.15.6
still error is:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'get' fatal: [grafana-1.host.domain]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 107, in <module>\n File \"<stdin>\", line 99, in _ansiballz_main\n File \"<stdin>\", line 47, in invoke_module\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_community.grafana.grafana_user_payload_rj6zf5tf/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 323, in <module>\n File \"/tmp/ansible_community.grafana.grafana_user_payload_rj6zf5tf/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 303, in main\n File \"/tmp/ansible_community.grafana.grafana_user_payload_rj6zf5tf/ansible_community.grafana.grafana_user_payload.zip/ansible_collections/community/grafana/plugins/modules/grafana_user.py\", line 247, in is_user_update_required\nAttributeError: 'NoneType' object has no attribute 'get'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
I can reproduce a similar bug:
run grafana
> docker run -d -p 3000:3000 grafana/grafana:10.2.2
run the following playbook:
---
- hosts: localhost
gather_facts: no
vars:
grafana_admin_user: grafana
grafana_admin_password: grafana
members:
- uid: username
description: 'User Name'
email: 'user.name@whatever.com'
password: 'hashed_passwd'
- uid: username2
description: 'User Name1'
email: 'user.name2@whatever.com'
password: 'hashed_passwd'
tasks:
- name: Create Grafana users
community.grafana.grafana_user:
url: "https://127.0.0.1" # ## notice this is wrong
url_username: "{{ grafana_admin_user }}"
url_password: "{{ grafana_admin_password }}"
login: "{{ member.uid }}"
email: "{{ member.email }}"
name: "{{ member.description }}"
password: "{{ member.password }}"
state: "present"
loop: "{{ members }}"
loop_control:
loop_var: member
result:
ansible-playbook test2.yml [WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
< PLAY [localhost] >
\ ^^ \ (oo)_____ (__)\ )\/\ ----w
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'read'
failed: [localhost] (item={'uid': 'username', 'description': 'User Name', 'email': 'user.name@whatever.com', 'password': 'hashed_passwd'}) => {"ansible_loop_var": "member", "changed": false, "member": {"description": "User Name", "email": "user.name@whatever.com", "password": "hashed_passwd", "uid": "username"}, "module_stderr": "Traceback (most recent call last):\n File \"/home/segu/.ansible/tmp/ansible-tmp-1713969893.8799918-1346142-270361372579429/AnsiballZ_grafana_user.py\", line 107, in
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
I've stumbled upon this error as well and could reproduce it. If I have a password that contains an exclamation mark, the invocation fails. To simulate this, I've changed my normal invocation to the following (basically replacing the password with a static one):
- name: Configure Users
community.grafana.grafana_user:
url: "https://{{ grafana_fqdn }}"
url_username: "{{ grafana_admin_user }}"
url_password: "{{ grafana_admin_password }}"
name: "{{ item.name }}"
email: "{{ item.email }}"
login: "{{ item.login }}"
password: "te!hst" #"{{ item.password }}"
is_admin: "{{ item.is_admin }}"
state: present
loop: "{{ grafana_users }}"
loop_control:
label: "{{ item.login }}"
The configuration above fails. If I'm using a password without an exclamation mark it works well:
- name: Configure Users
community.grafana.grafana_user:
url: "https://{{ grafana_fqdn }}"
url_username: "{{ grafana_admin_user }}"
url_password: "{{ grafana_admin_password }}"
name: "{{ item.name }}"
email: "{{ item.email }}"
login: "{{ item.login }}"
password: "test" #"{{ item.password }}"
is_admin: "{{ item.is_admin }}"
state: present
loop: "{{ grafana_users }}"
loop_control:
label: "{{ item.login }}"
It should be noted, that invoking it with the password "te!hst" fails (which actually is a typo) and with "te!st" actually succeeds.
Hello, I am getting this error when trying to execute grafana_user module:
I am using:
I cannot execute this task at all:
Is there anything I can do to solve the issue? Thanks