hi all,

quick question, i'm trying to add some aix specific facts using the 
BaseFactCollector. for some reason the facts to not show up in the setup 
output. whats kind of wizardy has to be done do make this working?

i also added the new script to the following files.

facts/default_collectors.py:from ansible.module_utils.facts.system.aix 
import AIXFactCollector
facts/default_collectors.py:    AIXFactCollector

test code

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import sys
import shlex
import os
import platform
import re
import itertools
import commands
import subprocess
    import json
except ImportError:
    import simplejson as json

from ansible.module_utils.facts.utils import get_file_content

from ansible.module_utils.facts.collector import BaseFactCollector

class AIXFactCollector(BaseFactCollector):
    Some handy AIX facts, more or less nice to haves
    name = 'aix_goodies'
    _fact_ids = set()
    _platform = 'AIX'

    def get_oslevel(self):
        get_oslevel function delivers oslevel -s output
        <OS Ver>-<TL>-<SP>-<BUILD DATE>
        OS Version, Technology Level, Servicepack and Build Date
        rc, out, err = module.run_command(["/usr/bin/oslevel", "-s"])
        if rc != 0:
            module.fail_json(msg="could not determine oslevel", rc=rc, err=
        oslevel = {'oslevel_s': out.strip('\n')}
        keys = ('OS_Ver', 'TL', 'SP', 'BUILD_DATE')
        values = out.split('-')
        v_stript = [v.rstrip('0\n') for v in values]
        adict = dict(itertools.izip(keys, v_stript))

        return oslevel

ansible run

ansible all -i 'AIXBUILDHOSTNG,' -m setup -a 'gather_subset=aix_goodies' --tree 

You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to