# facts gathering question

**URL:** <https://forum.ansible.com/t/facts-gathering-question/31404>\
**Category:** Ansible Developer\
**Created:** [October 2, 2019, 7:39am UTC](https://forum.ansible.com/t/facts-gathering-question/31404 "2019-10-02T07:39:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.tremel](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@christian.tremel](https://forum.ansible.com/u/christian.tremel)\
**Post date:** [October 2, 2019, 7:39am UTC](https://forum.ansible.com/t/facts-gathering-question/31404/1 "2019-10-02T07:39:29Z")

</div>

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

`

---

<div class="post-metadata">

**Author:** ![christian.tremel](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@christian.tremel](https://forum.ansible.com/u/christian.tremel)\
**Post date:** [October 3, 2019, 12:03pm UTC](https://forum.ansible.com/t/facts-gathering-question/31404/2 "2019-10-03T12:03:31Z")

</div>

nobody?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 11, 2019, 9:44pm UTC](https://forum.ansible.com/t/facts-gathering-question/31404/3 "2019-11-11T21:44:42Z")

</div>

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