facts gathering question

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
try:
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 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=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))
oslevel.update(adict)

return oslevel

`

ansible run

`
ansible all -i ‘AIXBUILDHOSTNG,’ -m setup -a ‘gather_subset=aix_goodies’ --tree /tmp/facts

`

nobody?

defining the collector is not enough, you need to call it with all the
other collectors see 'default_collectors.py'