Ansible custom facts not registering but others facts do

Problem:
custom facts from Ansible do not show up in the Foreman database. The do show up in my cached fact files - in other words, I see fact files show up in ~/workspace/fact_cache after Ansible runs. But they don’t show up in Foreman UI or the database currently. I believe I was able to do this before.

Expected outcome:

  • when I run “hammer host facts | grep ansible_local” I should see the custom facts from several hosts show up.
  • when I go to the fact values web, I should be able to successfully search “type = ansible_local”

Foreman and Proxy versions:
Foreman 2.5.1

Foreman and Proxy plugin versions:

Distribution and version:
Ubuntu 20.04.2

Other relevant data:

From my cached fact files - I can observe the custom facts are there:

    "ansible_local": {
        "dynamic": {
            "docker_ce_version": [
                "17.09.1~ce-0~ubuntu"
            ]
        },
        "static": {
            "environment": "web-125"
        }
    },

Also:

  • I can see all other facts show up in the Foreman UI
  • I cannot see the custom facts in the database – no luck with # hammer host facts | grep ansible_local
  • current setup is fresh - re-ran Terraform for the Ubuntu 20 EC2, and redeployed Foreman 2.5
  • From a previous round of testing I was able to type in the fact values UI and successfully search “type = ansible_local” IIRC

For my testbed I’ll look into Facter for custom facts. I like how it includes ec2 metadata out of the box. The tradeoff is the installation of Ruby and it’s dependencies, but if I really care about it, probably a dockerized Facter will work.

The odd part is I know I had ansible_local showing up in the Foreman UI. I was so happy to see for that one moment that I will cherish.

Just so that I fully understand, are you able to see other Ansible facts? Or other facts, meaning Puppet, subscription-manager facts etc? The Ansible callback that sends facts does not differentiate between custom and non-custom facts AFAICT. Since you talk about some terraform setup, does it run foreman-installer as part of the configuration? If not, how did you configure ansible.cfg for the foreman_proxy that runs Ansible?

Just so that I fully understand, are you able to see other Ansible facts? Or other facts, meaning Puppet, subscription-manager facts etc? The Ansible callback that sends facts does not differentiate between custom and non-custom facts AFAICT.

Yes all other facts I can see in the Foreman UI and database. For my playbook I’m just doing gather_facts: yes and when I have the cache turned on, I can see the custom facts (ansible_local) in my filesystem. But for some reason they don’t end up in Foreman.

Since you talk about some terraform setup, does it run foreman-installer as part of the configuration? If not, how did you configure ansible.cfg for the foreman_proxy that runs Ansible?

My Terraform is only for the AWS resources, the rest are bash snippets I copy/paste in. For the callback configuration I’m using environment variables:

export FOREMAN_URL=https://foreman-dev2.asdf.com
export FOREMAN_SSL_CERT=$HOME/.ansible/certs/foreman-dev2-public.pem
export FOREMAN_SSL_KEY=$HOME/.ansible/certs/foreman-dev2-private.pem
export FOREMAN_SSL_VERIFY=False

Since Foreman is receiving facts (just not ansible_local) then I guess the callback is configured correctly.