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

Debian 7 : The reported error was: float() argument must be a string or a number #56

Closed
romainrbr opened this issue Feb 1, 2016 · 11 comments

Comments

@romainrbr
Copy link

Getting an error while trying to generate a report for any number of servers.
Same command is working on OSX without any issue.


ansible-cmdb -d out/
data_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data
tpl_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl
static_dir = /usr/lib/ansible-cmdb/ansiblecmdb/data/static
Parsing fact dir: out/
Reading host facts from out/test.server.com
template file = /usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl
Template params: {'lib_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data', 'version': '1.11', 'data_dir': '/usr/lib/ansible-cmdb/ansiblecmdb/data', 'log': <logging.RootLogger object at 0x2163210>, 'columns': None}
Rendering host overview for test.server.com


Traceback (most recent call last):
  File "/usr/bin/ansible-cmdb", line 108, in <module>
    out = mytemplate.render(hosts=ansible.hosts, **params)
  File "/usr/lib/ansible-cmdb/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 803, in _render
    **_kwargs_for_callable(callable_, data))
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 487, in render_body
    <td>${col["func"](host)}</td>
  File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 0, in col_mem_usage

  File "/usr/lib/ansible-cmdb/ansiblecmdb/data/tpl/html_fancy.tpl", line 106, in render_col_mem_usage
    <span style="display:none">${'%f' % (float(i["nocache"]["used"]) / i["real"]["total"])}</span>
TypeError: float() argument must be a string or a number

Whoops, it looks like something went wrong while rendering the template.

The reported error was: float() argument must be a string or a number

The output is probably not correct.
You can report a bug on the issue tracker:

  https://github.com/fboender/ansible-cmdb/issues

Please include the debugging output (-d switch) in the report!

Additional infos

cat /etc/debian_version
7.9

ansible-cmdb --version
ansible-cmdb v1.11

ansible --version
ansible 2.1.0
  configured module search path = library/
@fboender
Copy link
Owner

fboender commented Feb 1, 2016

Hey Romain!

Thanks for the bug report. It's weird, cause I can't reproduce it with Debian v7.9. I'm running Ansible 2.0.0.2, so it could be that the problem is somewhere in between v2.0 and v2.1.

Can you paste the ""ansible_memory_mb" section from the offending host (looks like it's test.server.com)? That's where the problem should be located.

@romainrbr
Copy link
Author

 "ansible_memory_mb": {
      "nocache": {
        "free": null,
        "used": null
      }

Running ansible-cmdb on OSX with the same Json file doesn't trigger any error.

@fboender
Copy link
Owner

fboender commented Feb 1, 2016

Hm, that is very strange. It should look like this:

"nocache": { "used": 41, "free": 961 }

@romainrbr
Copy link
Author

The host on which I ran ansible -m setup is an OpenVZ VM, which is why there is no cache value.

cat /proc/meminfo | grep Buffers
Buffers:               0 kB

@fboender
Copy link
Owner

fboender commented Feb 1, 2016

Ah, that makes sense! Is there a valid "real" action with proper numbers, or is that also unavailable?

@fboender
Copy link
Owner

fboender commented Feb 1, 2016

Sorry, I meant "section" instead of "action"

@romainrbr
Copy link
Author

I don't think so.

Would it be possible to set the value to 0 if it's returned as "null" ?

@fboender
Copy link
Owner

fboender commented Feb 1, 2016

I've just pushed a fix that returns "n/a" for that column in the host overview. It should be able to handle those hosts now. I'ts not a great fix, but the best I can do right now.

@romainrbr
Copy link
Author

Thanks a lot!

@fboender
Copy link
Owner

fboender commented Feb 1, 2016

You're welcome! Thanks for reporting the bug!

@fboender
Copy link
Owner

fboender commented Feb 1, 2016

Oh, if the swap column is also not available, you may also get an error on that. I would be helpful if I had the whole output of ansible setup, so I can check everything. Could you send that to my email address (ferry.boender@gmail.com), or is it too sensitive?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants