GithubHelp home page GithubHelp logo

KeyError: 'size_total' about ansible-cmdb HOT 12 CLOSED

fboender avatar fboender commented on July 4, 2024
KeyError: 'size_total'

from ansible-cmdb.

Comments (12)

fboender avatar fboender commented on July 4, 2024

Hmm, strange. There seem to be some mount points with no available size_total. Could you try to find out the mount point that's causing the problem? If you save the following to a file called find.py:

import json
import os
import sys
for f in os.listdir(sys.argv[1]):
    j = json.load(open(os.path.join(sys.argv[1], f), 'r'));
    for m in j['ansible_facts']['ansible_mounts']:
        if not 'size_total' in m:
            print f
            print m

and run it like:

$ python find.py /path/to/ansible/out

It should print the host and mount points causing the problems. If you could copy-paste the results, I can probably figure out what's wrong.

Thanks for your help Cory!

from ansible-cmdb.

coryrwagner avatar coryrwagner commented on July 4, 2024

I ran find.py against the fact files and it kept failing, but it didn't tell me which file was the problem, so I moved "print f" after the first for loop. The find script then threw errors on files that had SSH or json error messages, rather than inventory info. After I removed the files w/o inventory info, the find.py script ran through all of the files w/o any errors, but almost every mount was listed. Only 105 devices have size_total vs 13,847 that don't.

It looks like Linux hosts are OK, but Solaris hosts are not. I will send you some Solaris inventory files to your gmail account.

Here's a sample of some of the mounts from a Solaris host:

        "ansible_mounts": [
            {
                "device": "rpool/ROOT/20150113_host1",
                "fstype": "zfs",
                "mount": "/",
                "options": "dev=4010002",
                "time": "0"
            },
            {
                "device": "/devices",
                "fstype": "devfs",
                "mount": "/devices",
                "options": "dev=62c0000",
                "time": "1437988345"
            },
            {
                "device": "swap",
                "fstype": "tmpfs",
                "mount": "/var/run",
                "options": "xattr,dev=63c0003",
                "time": "1437988368"
            },
            {
                "device": "rpool/export",
                "fstype": "zfs",
                "mount": "/export",
                "options": "rw,devices,setuid,nonbmand,exec,rstchown,xattr,atime,dev=4010003",
                "time": "1437988370"
            },
            {
                "device": "rpool/export/home",
                "fstype": "zfs",
                "mount": "/export/home",
                "options": "rw,devices,setuid,nonbmand,exec,rstchown,xattr,atime,dev=4010004",
                "time": "1437988370"
            },
            {
                "device": "rpool",
                "fstype": "zfs",
                "mount": "/rpool",
                "options": "rw,devices,setuid,nonbmand,exec,rstchown,xattr,atime,dev=4010005",
                "time": "1437988370"
            },
            {
                "device": "rpool/usr_log",
                "fstype": "zfs",
                "mount": "/usr/log",
                "options": "rw,devices,setuid,nonbmand,exec,rstchown,xattr,atime,dev=4010006",
                "time": "1437988370"
            },
            {
                "device": "host1:vold(pid444)",
                "fstype": "nfs",
                "mount": "/vol",
                "options": "ignore,noquota,dev=6600002",
                "time": "1437988374"
            },
            {
                "device": "strg-01:/cnos",
                "fstype": "nfs",
                "mount": "/cnos",
                "options": "bg,intr,xattr,dev=6600001",
                "time": "1437988374"
            },
            {
                "device": "auto_home",
                "fstype": "autofs",
                "mount": "/home",
                "options": "indirect,ignore,nobrowse,dev=6640001",
                "time": "1437988379"
            },
        ],

from ansible-cmdb.

muffl0n avatar muffl0n commented on July 4, 2024

It looks like the facts-module just does not get the sizes of the mounts in SunOSHardware.get_mount_facts():
https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts.py#L1186

Compare with the method LinuxHardware.get_mount_facts(): https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts.py#L938

from ansible-cmdb.

fboender avatar fboender commented on July 4, 2024

Nice find Sven!

I received some samples from Cory, and it looks like the disk size information is not available anywhere in the generated facts files. I'd consider this a bug (shortcoming?) in Ansible.

For now I'm going to write a fix so that ansible-cmdb doens't barf on missing sizes.

from ansible-cmdb.

muffl0n avatar muffl0n commented on July 4, 2024

The code was added in PR ansible/ansible#10292. It does not look like there were any real problems that prevented those measurements to be included.
Normally I would get a PR ready to fix that. But we are finally ditching our last Solaris machines soon, so I won't invest time in that. :)

from ansible-cmdb.

fboender avatar fboender commented on July 4, 2024

I've commited a fix for the KeyError. I'm going to close this issue, even though I don't feel it's been fixed properly. But the problem is in Ansible, not ansible-cmdb. I'm going to look into fixing the problem in Ansible itself and making a PR. I'll have to set up a solaris machine first though.

Thank you all for your help and information!

from ansible-cmdb.

muffl0n avatar muffl0n commented on July 4, 2024

At least there seems to be the same possibility to get the fs sizes like on Linux:

> python
Python 2.6.4 (r264:75706, Jun 26 2012, 21:27:36) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.statvfs('/var/log')
posix.statvfs_result(f_bsize=131072, f_frsize=512, f_blocks=708532116L, f_bfree=703980079L, f_bavail=703980079L, f_files=703980116L, f_ffree=703980079L, f_favail=703980079L, f_flag=4, f_namemax=255)
>>> ^D

> df /var/log
/var/log           (/var/log          ):703980079 blocks 703980079 files

from ansible-cmdb.

h0lzi avatar h0lzi commented on July 4, 2024

@fboender did you have the time to open a PR to sort this. I pinged @dago (colleague of mine) to have a look and improve his code when he has time so we get some size back :)

from ansible-cmdb.

dago avatar dago commented on July 4, 2024

In Solaris mnttab(4) data does not include filesystem sizes:
special mount_point fstype options time
As in the Linux implementation the fact gathering would need to go through all the filesystems to get the usage data.

from ansible-cmdb.

fboender avatar fboender commented on July 4, 2024

@h0lzi, @dago I haven't had time to open a PR to Ansible for this yet. I've got some time right now, so I'll look into it. Depending on how difficult it's going to be it might have to wait until after christmas, when I've got some vacation time coming.

from ansible-cmdb.

fboender avatar fboender commented on July 4, 2024

Looks like solaris support is now completely broken in the last (master) version of ansible:

./ansible -m ping -i ~/Projects/ansible-solaris/hosts all
sol.local | UNREACHABLE! => {
    "changed": false, 
    "msg": "ERROR! SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", 
    "unreachable": true
}

With an older version, the same hosts file still works though:

ansible -m ping -i ~/Projects/ansible-solaris/hosts all
sol.local | success >> {
    "changed": false,
    "ping": "pong"
}

I'm gonna see if I can fix this first.

from ansible-cmdb.

fboender avatar fboender commented on July 4, 2024

ansible/ansible#13410

from ansible-cmdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.