deepops icon indicating copy to clipboard operation
deepops copied to clipboard

AnsibleUndefinedVariable: ''ansible.utils.unsafe_proxy.AnsibleUnsafeText object'' has no attribute ''total_mb'''

Open jbonato1 opened this issue 11 months ago • 7 comments

OS on each node Ubuntu 22.04 lts

I'm installing slurm on a cluster made of login node and 3 comp. nodes (node 1,node2 and node4). I have the following error during slurm installation

ansible-playbook -l slurm-cluster playbooks/slurm-cluster.yml

when this part is executed:

Install Slurm

  • include: slurm-cluster/slurm.yml

Image

jbonato1 avatar Feb 18 '25 14:02 jbonato1

try manually running the memory fact gathering script to see if it produces unexpected output:

bash roles/facts/files/memory.fact

dholt avatar Feb 18 '25 23:02 dholt

These are the outcomes:

login -> { "total_mb": 60799 } node1 -> { "total_mb": 60768 } node2 -> { "total_mb": 244559 } node4-> { "total_mb": 244559 }

Moreover in hostvars for each node memory : total_mb varibale is defined.

jbonato1 avatar Feb 19 '25 08:02 jbonato1

does it work if you comment out the memory variable in your hostvars file?

dholt avatar Feb 19 '25 18:02 dholt

I tried using a custom slurm.conf where memory is defined for each node and without using hostvars. The error is still present

jbonato1 avatar Feb 19 '25 21:02 jbonato1

Im wondering if the memory fact is coming back as a json string such that the dictionary parsing isn't working? I could be wrong but I remember running into Ansible type coercion unexpectedly leading to UnsafeText for something else. For the repo I ran grep -R "memory.total_mb" . and got back ./roles/slurm/templates/etc/slurm/slurm.conf: RealMemory={{ memory.total_mb|int }}{{ " " -}} Im wondering in your slurm.conf after line 135 (the {% set memory = hostvars[node_name]["ansible_local"]["memory"] -%} line) if you added specific casting {% set mem = memory if memory is mapping else (memory | from_json) %} it would work?

RohanAdwankar avatar Feb 21 '25 03:02 RohanAdwankar

Actually memory is defined manually for each node

Image

jbonato1 avatar Feb 21 '25 08:02 jbonato1

In that case if you just want to work around it, you could comment out the lines in slurm.conf that reference memory.total_mb. I haven't been able to reproduce this issue, so you could also try removing any customization you've done and see if that helps.

dholt avatar Feb 21 '25 21:02 dholt

This issue is stale because it has been open for 60 days with no activity. Please update the issue or it will be closed in 7 days.

github-actions[bot] avatar Apr 23 '25 01:04 github-actions[bot]