Foreman auto-updating host operating system

I'm running Foreman + Puppet, and I'm trying to track down some
customization that's been done in our environment. I'm having trouble
pinpointing exactly where the change is occurring. I'm assuming it's
something unique to our environment, but I can't tell if the change has
been made in Puppet, or in Foreman. I apologize if this isn't directly
related, but I thought it might be a good place to get some assistance.

Here's what happens. I notice on each puppet run, the host's operating
system in Foreman is updated. For example, if I have a Red Hat 6.7 server
and manually change it to "Red Hat 5.11" in the Foreman WebUI, after the
following puppet run, the host record is changed back to "Red Hat 6.7".
Facts on the client appear to be used to change the operating system type
within Foreman.

I can see this from a puppet run on the client as follows:

  1. puppet agent --test --debug

  2. Info: Loading facts in /var/lib/puppet/lib/facter/hosts_additional.rb
  3. Info: Loading facts in /var/lib/puppet/lib/facter/hardware_hostname.rb
  4. *** redacted lots of facts loading ***
  5. Info: Loading facts in /var/lib/puppet/lib/facter/ip6tables_version.rb
  6. Debug: catalog supports formats: pson b64_zlib_yaml yaml dot raw
  7. Debug: Executing '/bin/rpm --version'
  8. Debug: Executing '/bin/rpm --version'
  9. Debug: Executing '/bin/rpm --version'
  10. Debug: Executing '/bin/rpm --version'
  11. Debug: Executing '/bin/rpm -ql rpm'
  12. Info: Caching catalog for myhost.mydomain.com
  13. …catalog applied…

The OS change happens around, or just after, execution of line #6.

I started by looking through all of our Puppet code, including the
manifests, and any customized Puppet functions. After literally a day of
pouring over that code, I don't see anything I think is making the change.
Next, I looked at our ENC script to verify it wasn't responsible.
Afterwards, I went through our Foreman hooks (we run the Foreman hooks
plugin). I was even looking for things like triggers/stored procedures on
our database. Nada. I can't figure out what's doing it.

I know there are a lot of possibilities here, but I'm wondering if I'm
missing an obvious place to look for something (in Foreman) that has been
customized in this way.

It's Foreman itself - it parses the incoming fact data as the ENC uploads
it, to update the host attributes. See

and

for the entry point, although off the top of my head, I forget how
import_facts gets defined. Hopefully it's a pointer for you, if not poke me
again and I'll dig some more :wink:

Greg

Gotcha, thanks Greg.

··· On Thursday, March 10, 2016 at 8:30:45 AM UTC-8, Greg Sutcliffe wrote: > > It's Foreman itself - it parses the incoming fact data as the ENC uploads > it, to update the host attributes. See > > > https://github.com/theforeman/foreman/blob/develop/app/services/puppet_fact_parser.rb > > and > > > https://github.com/theforeman/foreman/blob/develop/app/models/host/managed.rb#L470 > > for the entry point, although off the top of my head, I forget how > import_facts gets defined. Hopefully it's a pointer for you, if not poke me > again and I'll dig some more ;) > > Greg >

Greg, I take it there isn't a way to disable updating of the operating
system from facts via a setting? I didn't see anything.

I've had a provisioning related issue occur a couple times. I haven't been
able to confirm for sure, but here's what I think is happening:

I want to rebuild a host with a new OS, so I edit the host and change the
OS (say, from Xenserver 6.5 to Redhat 6.7). I then click "Build" from
within the host details page. The dialog box pops up to confirm the build,
and I click the "Build" button there as well. Foreman pushes out the
DHCP/TFTP information, and the host is then in the build state. However,
when I look at the OS type in the "Properties" box, it has reverted to the
old OS "XenServer 6.5".

We have 100 subnets on our smart proxy, and I had posted awhile back that
this was really slowing down certain functions in the interface that
require Foreman to talk to the DHCP server (changing IP's, putting a host
into build, etc). In particular, it takes a couple minutes to get past the
two "Build" steps above. I think what happens is, occasionally, puppet
runs while I'm waiting for that dialog to return and updates the OS before
Foreman pushes down the TFTP files.

I'm wondering if anyone else has experienced this. Assuming that's what's
actually happening here, it'd be nice to be able to disable updating of the
OS fact. It doesn't seem like that would be something that would need
constant updating anyways, except during host rebuilds.

··· On Friday, March 11, 2016 at 5:38:14 PM UTC-8, Kyle Flavin wrote: > > Gotcha, thanks Greg. > > On Thursday, March 10, 2016 at 8:30:45 AM UTC-8, Greg Sutcliffe wrote: >> >> It's Foreman itself - it parses the incoming fact data as the ENC uploads >> it, to update the host attributes. See >> >> >> https://github.com/theforeman/foreman/blob/develop/app/services/puppet_fact_parser.rb >> >> and >> >> >> https://github.com/theforeman/foreman/blob/develop/app/models/host/managed.rb#L470 >> >> for the entry point, although off the top of my head, I forget how >> import_facts gets defined. Hopefully it's a pointer for you, if not poke me >> again and I'll dig some more ;) >> >> Greg >> >

> Greg, I take it there isn't a way to disable updating of the operating
> system from facts via a setting? I didn't see anything.
>
> I've had a provisioning related issue occur a couple times. I haven't
> been able to confirm for sure, but here's what I think is happening:
>
> I want to rebuild a host with a new OS, so I edit the host and change the
> OS (say, from Xenserver 6.5 to Redhat 6.7). I then click "Build" from
> within the host details page. The dialog box pops up to confirm the build,
> and I click the "Build" button there as well. Foreman pushes out the
> DHCP/TFTP information, and the host is then in the build state. However,
> when I look at the OS type in the "Properties" box, it has reverted to the
> old OS "XenServer 6.5".
>
> We have 100 subnets on our smart proxy, and I had posted awhile back that
> this was really slowing down certain functions in the interface that
> require Foreman to talk to the DHCP server (changing IP's, putting a host
> into build, etc). In particular, it takes a couple minutes to get past the
> two "Build" steps above. I think what happens is, occasionally, puppet
> runs while I'm waiting for that dialog to return and updates the OS before
> Foreman pushes down the TFTP files.
>

Yeah if Puppet runs i nthat window, it would explain it - obviously, one
possible workaround is to run "puppet agent --disable" on the host before
rebuilding it.

> I'm wondering if anyone else has experienced this. Assuming that's what's
> actually happening here, it'd be nice to be able to disable updating of the
> OS fact. It doesn't seem like that would be something that would need
> constant updating anyways, except during host rebuilds.
>

It seems a valid feature request -
Bug #6006: OS facts should not overwrite the OS selected to provision with - Foreman might be related too.

Greg

··· On 14 March 2016 at 18:22, Kyle Flavin wrote:

Hello

I hope that the new facet system will fix this common issue. I wonder if it
would be a good idea to introduce new setting to disable automatic OS update
meanwhile. We have the same for network interface updates already.

··· -- Marek

On Tuesday 15 of March 2016 21:40:59 Greg Sutcliffe wrote:

On 14 March 2016 at 18:22, Kyle Flavin kyle.flavin@gmail.com wrote:

Greg, I take it there isn’t a way to disable updating of the operating
system from facts via a setting? I didn’t see anything.

I’ve had a provisioning related issue occur a couple times. I haven’t
been able to confirm for sure, but here’s what I think is happening:

I want to rebuild a host with a new OS, so I edit the host and change the
OS (say, from Xenserver 6.5 to Redhat 6.7). I then click “Build” from
within the host details page. The dialog box pops up to confirm the
build,
and I click the “Build” button there as well. Foreman pushes out the
DHCP/TFTP information, and the host is then in the build state. However,
when I look at the OS type in the “Properties” box, it has reverted to the
old OS “XenServer 6.5”.

We have 100 subnets on our smart proxy, and I had posted awhile back that
this was really slowing down certain functions in the interface that
require Foreman to talk to the DHCP server (changing IP’s, putting a host
into build, etc). In particular, it takes a couple minutes to get past
the
two “Build” steps above. I think what happens is, occasionally, puppet
runs while I’m waiting for that dialog to return and updates the OS before
Foreman pushes down the TFTP files.

Yeah if Puppet runs i nthat window, it would explain it - obviously, one
possible workaround is to run “puppet agent --disable” on the host before
rebuilding it.

I’m wondering if anyone else has experienced this. Assuming that’s what’s
actually happening here, it’d be nice to be able to disable updating of
the
OS fact. It doesn’t seem like that would be something that would need
constant updating anyways, except during host rebuilds.

It seems a valid feature request -
Bug #6006: OS facts should not overwrite the OS selected to provision with - Foreman might be related too.

Greg