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

Ansible Tower Generated Json Output unable to generate report #242

Open
sivanamurugesan opened this issue Jan 4, 2022 · 1 comment
Open

Comments

@sivanamurugesan
Copy link

Ansible Tower Generated Json Output unable to generate report. I tried to generate report by genrate all facts gathered via ansible tower and placed

  • name: Fact dump
    hosts: all
    vars:
    ansible_python_interpreter: "/usr/bin/python"
    tasks:
    • name: Discover Facts
      copy:
      content: "{{ ansible_facts }}"
      dest: "{{ ansible_fqdn }}"

Tried generate Report as below

ansible-cmdb af/ > new-overview.html

Reports are not generated as expected. Any workaround for this ?

@fredjupp
Copy link

fredjupp commented Mar 6, 2024

Hello,
I have the same issue. It's probably related to the fact, that the ansible-cmdb expects the variables with names like ansible_distribution...
I (as a really bad python programmerr) also used the facts file from either the setup-module or an ansible plabyook where the ansible -m setup produces vars like above and the playbook / setup doesn't.
Here is my (most likely not nice) python code:
with open(myfile, encoding="utf-8") as json_file:
my_basename = os.path.basename(myfile)
counter[my_tab_name] += 1
data = json.load(json_file)
# if facts where gethered by ansible -m setup. then all
# facts will be prefixed
# by ansible_ and the dict starts with ansible_facts
if data.get('ansible_facts'):
facts = data.get('ansible_facts')
prefix = 'ansible_'
else:
facts = data
prefix = ''
Perhaps we can encourage one of the developers, to includes someting like this in the code

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