500 Server Error: Internal Server Error for url: https://ansible01.localhost.local/api/v2/hosts/facts

Getting 500 Server Error: Internal Server Error for url: https://ansible01.localhost.local/api/v2/hosts/facts error message when trying to run ansible roles from foreman. This is issue is not alowing roles to server facts for the ansible role running.

Foreman 1.17
Ansible 2.5.2

A traceback from production.log would most likely help to debug, see Troubleshooting - Foreman for more info

Hi Marek,

Thank you for you help. I turned on Debug more for foreman and foreman-proxy. More information about my setup.

ansible01.localhost.local and ubuntu16.localhost.local are to virtual servers running on virtualbox. They bot have to network interfaces, the interfaces on subnet 10.0.2.x are using nat and the interface 192.168.56.x are host only back to my system that is running virtualbox. I’m using local host file instead of DNS.

I uploaded the the production.log file out of debug mode after running ansible role on ubuntu16 host.

I also see that the facts for ubunt16 get wiped out after running ansible role from foreman. I can import the facts again if I run ansible ubuntu16.localhost.local -m setup from command line.

production.log.save.tar.gz (27.6 KB)

Hello,

I quickly looked at the log, the exception is

2018-05-04 06:54:44  [dynflow] [D]          Step b995acd1-13d1-4b4b-8681-12ab97d84751: 3   running >> suspended in phase      Run ForemanRemoteExecutionCore::Actions::RunScript
2018-05-04 06:54:44 81cc6796 [app] [W] Action failed
 | ActiveRecord::RecordInvalid: Validation failed: Major is not a number, Major Operating System version is required, Name can't be blank, Title can't be blank

which in other words says, uploaded facts do not include all required values. Looking at the facts we received, it’s opensuse 12 box which does not seem to report OS information in expected format. Seems like a RFE for opensuse hosts, would you mind opening issue at our tracker? I don’t know many people using foreman_ansible with opensuse, would you be interested in working on the patch?

Hi Marek,

Thanks for taking a look. I’m actually running ansible on CentOS 7 (ansible01.localhost.local) not opensuse and the ubuntu16 server is running Ubuntu 16.04.

I thought “ActiveRecord::RecordInvalid: Validation failed: Major is not a number, Major Operating System version is required, Name can’t be blank, Title can’t be blank” error was being caused because foreman could not see the system facts hence the error “500 Server Error: Internal Server Error for url: https://ansible01.localhost.local/api/v2/hosts/facts

I’m a fairly new to Foreman though I do use version 1.15 with Puppet in production. I’ll open a tracker if you think that is the way to go.

Interesting, then the facts are perhaps somehow modified by some role. I’ve seen that before at some motd role. Could you try running some very small playbook with just one task or something on the same client and see if that works?

Hi Marek,

I ran a one task playbook that did not require any imported facts and it was successful. see the attachment.

I’m interested to know if anyone has been able to get ansible 2.5.2 and Foreman 1.17 installed and able to run playbooks that use facts for a variable to work. I can’t seem to figure out what is causing the 500 Server error and think it may be a bug.

Every time run an ansible role from Foreman all the facts for the system get deleted except for one that the running role creates. I’m not sure how to trouble shoot this any further. Does anyone have any suggestions?

We’re working on new release of foreman_ansible and we’d like to test the whole setup as there were observed some issues with the callback. Unfortunately the callback lives in ansible and we don’t have a good control over it’s release cycle. We’re just discussing how to improve it long term.

Thanks for the update. I’d be happy to test any future patch or update.

1 Like

So I tested the newest foreman_ansible and it seems to work fine (as longs as the callback is configured manually). The behavior is that we always only keep facts that appear during the ansible run. So let’s say you do first run and get facts a,b,c with respective values 1,2,3. Second run produces only facts a,c,d with values 1,4,5. The facts we keep in Foreman would be a => 1, c => 4, d => 5. We’re updating existing ones, removing those that are no longer available and add new ones.

My understanding is that you don’t get some OS related facts but only when you use some specific ansible role. If that’s the case, could you share the role which causes it?

I’m getting the same error since the demo last week - will check what happened in the parser.

Thanks for the report @flaporta , we are tracking it at Bug #23715: Facts are not parsed for the OS - Ansible - Foreman

2 Likes

https://github.com/theforeman/foreman_ansible/pull/174 fix incoming :smile:

1 Like

Awesome… Can’t wait to get this working.

Sorry for missing this question. The problem I’m seeing appears to happen with any role that needs to gather system facts and after the role fails and I check the system facts. the facts will all be gone except for maybe one that the role played imported. One role for example is dj-wasabi.zabbix-agent retrieved from ansible galaxy. The host has all the facts gathered by ansible -m setup then I run the zabbix-agent role and after it fails the only fact I see is " zabbix_short_version".

Any traction on this issue?

Hi,

Simply stop gathers facts in a playbook, just modify job templates with the below line.


  • hosts: all
    gather_facts: no